130 lines · plain
1# RUN: split-file %s %t2# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/main.s -o %t/main.o3# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %t/secondary.s -o %t/secondary.o4 5## Check that both main.o and secondary.o contain references to the same6## undefined function and that both are correctly reported.7# RUN: not wasm-ld --no-gc-sections %t/main.o %t/secondary.o -o /dev/null 2>&1 | \8# RUN: FileCheck -check-prefix=ERRUND %s9# ERRUND: error: {{.*}}main.o: undefined symbol: undef_func10# ERRUND: error: {{.*}}secondary.o: undefined symbol: undef_func11 12## report-all is the default one. Check that we get the same error13# RUN: not wasm-ld --no-gc-sections %t/main.o %t/secondary.o -o /dev/null --unresolved-symbols=report-all 2>&1 | \14# RUN: FileCheck -check-prefix=ERRUND %s15 16## Error out if unknown option value was set.17# RUN: not wasm-ld %t/main.o -o /dev/null --unresolved-symbols=xxx 2>&1 | \18# RUN: FileCheck -check-prefix=ERR1 %s19# ERR1: unknown --unresolved-symbols value: xxx20## Check alias.21# RUN: not wasm-ld %t/main.o -o /dev/null --unresolved-symbols xxx 2>&1 | \22# RUN: FileCheck -check-prefix=ERR1 %s23 24## Ignore all should not produce error and should not produce25## any imports. It should create a stub function in the place of the missing26## function symbol.27# RUN: wasm-ld %t/main.o -o %t2.wasm --unresolved-symbols=ignore-all28# RUN: obj2yaml %t2.wasm | FileCheck -check-prefix=IGNORE %s29 30## --warn-unresolved-symbols should behave the same31# RUN: wasm-ld %t/main.o -o %t2.wasm --warn-unresolved-symbols32# RUN: obj2yaml %t2.wasm | FileCheck -check-prefix=IGNORE %s33 34# IGNORE-NOT: - Type: IMPORT35# IGNORE-NOT: - Type: ELEM36#37# IGNORE: - Type: CODE38# IGNORE-NEXT: Functions:39# IGNORE-NEXT: - Index: 040# IGNORE-NEXT: Locals: []41# IGNORE-NEXT: Body: 000B42# IGNORE-NEXT: - Index: 143# IGNORE-NEXT: Locals: []44# IGNORE-NEXT: Body: 1080808080001082808080001083808080001A1A0B45# IGNORE-NEXT: - Index: 246# IGNORE-NEXT: Locals: []47# IGNORE-NEXT: Body: 4180808080000F0B48# IGNORE-NEXT: - Index: 349# IGNORE-NEXT: Locals: []50# IGNORE-NEXT: Body: 4180808080000F0B51#52# IGNORE: - Type: CUSTOM53# IGNORE-NEXT: Name: name54# IGNORE-NEXT: FunctionNames:55# IGNORE-NEXT: - Index: 056# IGNORE-NEXT: Name: undefined57# IGNORE-NEXT: - Index: 158# IGNORE-NEXT: Name: _start59# IGNORE-NEXT: - Index: 260# IGNORE-NEXT: Name: get_data_addr61# IGNORE-NEXT: - Index: 362# IGNORE-NEXT: Name: get_func_addr63 64## --import-undefined should handle unresolved functions symbols65## by importing them but still report errors/warning for missing data symbols.66## `--allow-undefined` should behave like `--import-undefined` +67## `--unresolve-symbols=ignore`68# RUN: wasm-ld %t/main.o -o %t3.wasm --import-undefined --unresolved-symbols=ignore-all69# RUN: obj2yaml %t3.wasm | FileCheck -check-prefix=IMPORT %s70# IMPORT: - Type: IMPORT71# IMPORT-NEXT: Imports:72# IMPORT-NEXT: - Module: env73# IMPORT-NEXT: Field: undef_func74# IMPORT-NEXT: Kind: FUNCTION75# IMPORT-NEXT: SigIndex: 076# IMPORT-NEXT: - Type: FUNCTION77 78## Check that --import-undefined reports unresolved data symbols.79# RUN: not wasm-ld %t/main.o -o %t3.wasm --import-undefined --unresolved-symbols=report-all 2>&1 | FileCheck -check-prefix=IMPORTUNDEFINED %s80# IMPORTUNDEFINED-NOT: error: {{.*}}main.o: undefined symbol: undef_func81# IMPORTUNDEFINED: error: {{.*}}main.o: undefined symbol: undef_data82 83## Do not report undefines if linking relocatable.84# RUN: wasm-ld -r %t/main.o -o %t4.wasm --unresolved-symbols=report-all85# RUN: llvm-readobj %t4.wasm > /dev/null 2>&186 87## import-dynamic should fail due to incompatible relocations.88# RUN: not wasm-ld %t/main.o -o %t5.wasm --experimental-pic --unresolved-symbols=import-dynamic 2>&1 | FileCheck -check-prefix=ERRNOPIC %s89# ERRNOPIC: relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `undef_data`; recompile with -fPIC90# ERRNOPIC: relocation R_WASM_TABLE_INDEX_SLEB cannot be used against symbol `undef_func`; recompile with -fPIC91 92#--- main.s93 94.functype undef_func () -> ()95.functype get_data_addr () -> (i32)96.functype get_func_addr () -> (i32)97 98.globl _start99_start:100 .functype _start () -> ()101 call undef_func102 call get_data_addr103 call get_func_addr104 drop105 drop106 end_function107 108.globl get_data_addr109get_data_addr:110 .functype get_data_addr () -> (i32)111 i32.const undef_data112 return113 end_function114 115.globl get_func_addr116get_func_addr:117 .functype get_func_addr () -> (i32)118 i32.const undef_func119 return120 end_function121 122#--- secondary.s123 124.functype undef_func () -> ()125.globl foo126foo:127 .functype foo () -> ()128 call undef_func129 end_function130