[LLD][COFF] Ignore DEBUG_S_XFGHASH_TYPE/VIRTUAL
[llvm-project.git] / lld / test / wasm / unresolved-symbols.s
blob5de54d76c6de810d20025e163210172385df445e
1 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t1.o
3 ## Check that %t1.o contains undefined symbol undef_func.
4 # RUN: not wasm-ld %t1.o -o /dev/null 2>&1 | \
5 # RUN: FileCheck -check-prefix=ERRUND %s
6 # ERRUND: error: {{.*}}1.o: undefined symbol: undef_func
8 ## report-all is the default one. Check that we get the same error
9 # RUN: not wasm-ld %t1.o -o /dev/null --unresolved-symbols=report-all 2>&1 | \
10 # RUN: FileCheck -check-prefix=ERRUND %s
12 ## Error out if unknown option value was set.
13 # RUN: not wasm-ld %t1.o -o /dev/null --unresolved-symbols=xxx 2>&1 | \
14 # RUN: FileCheck -check-prefix=ERR1 %s
15 # ERR1: unknown --unresolved-symbols value: xxx
16 ## Check alias.
17 # RUN: not wasm-ld %t1.o -o /dev/null --unresolved-symbols xxx 2>&1 | \
18 # RUN: FileCheck -check-prefix=ERR1 %s
20 ## Ignore all should not produce error and should not produce
21 # any imports. It should create a stub function in the place of the missing
22 # function symbol.
23 # RUN: wasm-ld %t1.o -o %t2.wasm --unresolved-symbols=ignore-all
24 # RUN: obj2yaml %t2.wasm | FileCheck -check-prefix=IGNORE %s
25 # IGNORE-NOT: - Type: IMPORT
26 # IGNORE-NOT: - Type: ELEM
28 # IGNORE: - Type: CODE
29 # IGNORE-NEXT: Functions:
30 # IGNORE-NEXT: - Index: 0
31 # IGNORE-NEXT: Locals: []
32 # IGNORE-NEXT: Body: 000B
33 # IGNORE-NEXT: - Index: 1
34 # IGNORE-NEXT: Locals: []
35 # IGNORE-NEXT: Body: 1080808080001082808080001083808080001A1A0B
36 # IGNORE-NEXT: - Index: 2
37 # IGNORE-NEXT: Locals: []
38 # IGNORE-NEXT: Body: 4180808080000F0B
39 # IGNORE-NEXT: - Index: 3
40 # IGNORE-NEXT: Locals: []
41 # IGNORE-NEXT: Body: 4180808080000F0B
43 # IGNORE: - Type: CUSTOM
44 # IGNORE-NEXT: Name: name
45 # IGNORE-NEXT: FunctionNames:
46 # IGNORE-NEXT: - Index: 0
47 # IGNORE-NEXT: Name: undefined
48 # IGNORE-NEXT: - Index: 1
49 # IGNORE-NEXT: Name: _start
50 # IGNORE-NEXT: - Index: 2
51 # IGNORE-NEXT: Name: get_data_addr
52 # IGNORE-NEXT: - Index: 3
53 # IGNORE-NEXT: Name: get_func_addr
55 ## --import-undefined should handle unresolved funtions symbols
56 # by importing them but still report errors/warning for missing data symbols.
57 # `--allow-undefined` should behave like `--import-undefined` +
58 # `--unresolve-symbols=ignore`
59 # RUN: wasm-ld %t1.o -o %t3.wasm --import-undefined --unresolved-symbols=ignore-all
60 # RUN: obj2yaml %t3.wasm | FileCheck -check-prefix=IMPORT %s
61 # IMPORT: - Type: IMPORT
62 # IMPORT-NEXT: Imports:
63 # IMPORT-NEXT: - Module: env
64 # IMPORT-NEXT: Field: undef_func
65 # IMPORT-NEXT: Kind: FUNCTION
66 # IMPORT-NEXT: SigIndex: 0
67 # IMPORT-NEXT: - Type: FUNCTION
69 ## Check that --import-undefined reports unresolved data symbols.
70 # RUN: not wasm-ld %t1.o -o %t3.wasm --import-undefined --unresolved-symbols=report-all 2>&1 | FileCheck -check-prefix=IMPORTUNDEFINED %s
71 # IMPORTUNDEFINED-NOT: error: {{.*}}1.o: undefined symbol: undef_func
72 # IMPORTUNDEFINED: error: {{.*}}1.o: undefined symbol: undef_data
74 ## Do not report undefines if linking relocatable.
75 # RUN: wasm-ld -r %t1.o -o %t4.wasm --unresolved-symbols=report-all
76 # RUN: llvm-readobj %t4.wasm > /dev/null 2>&1
78 .functype undef_func () -> ()
79 .functype get_data_addr () -> (i32)
80 .functype get_func_addr () -> (i32)
82 ## import-dynamic should fail due to incompatible relocations.
83 # RUN: not wasm-ld %t1.o -o %t5.wasm --unresolved-symbols=import-dynamic 2>&1 | FileCheck -check-prefix=ERRNOPIC %s
84 # ERRNOPIC: relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol `undef_data`; recompile with -fPIC
85 # ERRNOPIC: relocation R_WASM_TABLE_INDEX_SLEB cannot be used against symbol `undef_func`; recompile with -fPIC
87 .globl _start
88 _start:
89 .functype _start () -> ()
90 call undef_func
91 call get_data_addr
92 call get_func_addr
93 drop
94 drop
95 end_function
97 .globl get_data_addr
98 get_data_addr:
99 .functype get_data_addr () -> (i32)
100 i32.const undef_data
101 return
102 end_function
104 .globl get_func_addr
105 get_func_addr:
106 .functype get_func_addr () -> (i32)
107 i32.const undef_func
108 return
109 end_function