[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / lld / test / COFF / arm64ec-import.test
blob033c27884be02c305bbd4b6644b80f6db48c7a37
1 REQUIRES: aarch64, x86
2 RUN: split-file %s %t.dir && cd %t.dir
4 RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test.s -o test.obj
5 RUN: llvm-mc -filetype=obj -triple=arm64ec-windows icall.s -o icall.obj
6 RUN: llvm-mc -filetype=obj -triple=arm64ec-windows hybmp.s -o hybmp.obj
7 RUN: llvm-mc -filetype=obj -triple=x86_64-windows test.s -o test-x86_64.obj
8 RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
9 RUN: llvm-lib -machine:arm64ec -def:test.def -out:test-arm64ec.lib
10 RUN: llvm-lib -machine:arm64ec -def:test2.def -out:test2-arm64ec.lib
11 RUN: llvm-lib -machine:x64 -def:test.def -out:test-x86_64.lib
13 Link using ARM64EC import library:
14 RUN: lld-link -machine:arm64ec -dll -noentry -out:out.dll loadconfig-arm64ec.obj icall.obj hybmp.obj \
15 RUN:          test.obj test-arm64ec.lib test2-arm64ec.lib -map
17 Link using x86_64 import library:
18 RUN: lld-link -machine:arm64ec -dll -noentry -out:out2.dll loadconfig-arm64ec.obj icall.obj hybmp.obj \
19 RUN:          test.obj test-x86_64.lib test2-arm64ec.lib -map
21 Link using x86_64 object file:
22 RUN: lld-link -machine:arm64ec -dll -noentry -out:out3.dll loadconfig-arm64ec.obj icall.obj hybmp.obj \
23 RUN:          test-x86_64.obj test-arm64ec.lib test2-arm64ec.lib -map
25 RUN: llvm-readobj --coff-imports out.dll | FileCheck --check-prefix=IMPORTS %s
26 RUN: llvm-readobj --coff-imports out2.dll | FileCheck --check-prefix=IMPORTS %s
27 RUN: llvm-readobj --coff-imports out3.dll | FileCheck -check-prefix=IMPORTS %s
28 IMPORTS:      Import {
29 IMPORTS-NEXT:   Name: test.dll
30 IMPORTS-NEXT:   ImportLookupTableRVA: 0x4218
31 IMPORTS-NEXT:   ImportAddressTableRVA: 0x3000
32 IMPORTS-NEXT:   Symbol: data (0)
33 IMPORTS-NEXT:   Symbol: func (0)
34 IMPORTS-NEXT:   Symbol: func2 (0)
35 IMPORTS-NEXT: }
36 IMPORTS-NEXT: Import {
37 IMPORTS-NEXT:   Name: test2.dll
38 IMPORTS-NEXT:   ImportLookupTableRVA:
39 IMPORTS-NEXT:   ImportAddressTableRVA: 0x3020
40 IMPORTS-NEXT:   Symbol: t2func (0)
41 IMPORTS-NEXT: }
43 RUN: llvm-objdump -d out.dll | FileCheck --check-prefix=DISASM %s
44 RUN: llvm-objdump -d out2.dll | FileCheck --check-prefix=DISASM %s
45 RUN: llvm-objdump -d out3.dll | FileCheck -check-prefix=DISASM %s
47 DISASM:      180001000: 52800000     mov     w0, #0x0                // =0
48 DISASM-NEXT: 180001004: d65f03c0     ret
49 DISASM-NEXT: 180001008: 90000030     adrp    x16, 0x180005000
50 DISASM-NEXT: 18000100c: f9400610     ldr     x16, [x16, #0x8]
51 DISASM-NEXT: 180001010: d61f0200     br      x16
52 DISASM-NEXT: 180001014: d000000b     adrp    x11, 0x180003000
53 DISASM-NEXT: 180001018: f940056b     ldr     x11, [x11, #0x8]
54 DISASM-NEXT: 18000101c: 9000000a     adrp    x10, 0x180001000 <.text>
55 DISASM-NEXT: 180001020: 9101714a     add     x10, x10, #0x5c
56 DISASM-NEXT: 180001024: 17fffff7     b       0x180001000 <.text>
57 DISASM-NEXT: 180001028: d000000b     adrp    x11, 0x180003000
58 DISASM-NEXT: 18000102c: f940096b     ldr     x11, [x11, #0x10]
59 DISASM-NEXT: 180001030: f0ffffea     adrp    x10, 0x180000000
60 DISASM-NEXT: 180001034: 9100014a     add     x10, x10, #0x0
61 DISASM-NEXT: 180001038: 17fffff2     b       0x180001000 <.text>
62 DISASM-NEXT: 18000103c: 90000030     adrp    x16, 0x180005000
63 DISASM-NEXT: 180001040: f9401210     ldr     x16, [x16, #0x20]
64 DISASM-NEXT: 180001044: d61f0200     br      x16
65 DISASM-NEXT: 180001048: d000000b     adrp    x11, 0x180003000
66 DISASM-NEXT: 18000104c: f940116b     ldr     x11, [x11, #0x20]
67 DISASM-NEXT: 180001050: 9000000a     adrp    x10, 0x180001000 <.text>
68 DISASM-NEXT: 180001054: 9101914a     add     x10, x10, #0x64
69 DISASM-NEXT: 180001058: 17ffffea     b       0x180001000 <.text>
70 DISASM-NEXT: 18000105c: 52800020     mov     w0, #0x1                // =1
71 DISASM-NEXT: 180001060: d65f03c0     ret
72 DISASM-NEXT: 180001064: 52800040     mov     w0, #0x2                // =2
73 DISASM-NEXT: 180001068: d65f03c0     ret
74 DISASM-NEXT:                 ...
75 DISASM-NEXT: 180002000: ff 25 02 10 00 00            jmpq    *0x1002(%rip)           # 0x180003008
77 RUN: llvm-readobj --hex-dump=.test out.dll | FileCheck --check-prefix=TESTSEC %s
78 RUN: llvm-readobj --hex-dump=.test out2.dll | FileCheck --check-prefix=TESTSEC %s
79 TESTSEC:      0x180008000 08500000 00300000 10500000 20500000
80 TESTSEC-NEXT: 0x180008010 08300000 00500000 10300000 20300000
81 TESTSEC-NEXT: 0x180008020 14100000 28100000 00200000 08100000
82 TESTSEC-NEXT: 0x180008030 3c100000 88420000
84 RUN: llvm-readobj --hex-dump=.test out3.dll | FileCheck -check-prefix=TESTSEC-X64 %s
85 TESTSEC-X64:      0x180008000 08300000 00300000 10300000 20300000
86 TESTSEC-X64-NEXT: 0x180008010 08300000 00500000 10300000 20300000
87 TESTSEC-X64-NEXT: 0x180008020 14100000 28100000 00200000 08100000
88 TESTSEC-X64-NEXT: 0x180008030 3c100000 88420000
90 RUN: FileCheck --check-prefix=MAP %s < out.map
91 RUN: FileCheck --check-prefix=MAP %s < out2.map
92 RUN: FileCheck --check-prefix=MAP %s < out3.map
93 MAP:      0001:00000008       #func                      0000000180001008     test{{.*}}:test.dll
94 MAP-NEXT: 0001:00000014       __impchk_func              0000000180001014     test{{.*}}:test.dll
95 MAP-NEXT: 0001:00000028       __impchk_func2             0000000180001028     test{{.*}}:test.dll
96 MAP-NEXT: 0001:0000003c       #t2func                    000000018000103c     test2{{.*}}:test2.dll
97 MAP-NEXT: 0001:00000048       __impchk_t2func            0000000180001048     test2{{.*}}:test2.dll
98 MAP:      0001:00001000       func                       0000000180002000     test{{.*}}:test.dll
99 MAP-NEXT: 0002:00000000       __imp_data                 0000000180003000     test{{.*}}:test.dll
100 MAP-NEXT: 0002:00000008       __imp_aux_func             0000000180003008     test{{.*}}:test.dll
101 MAP-NEXT: 0002:00000010       __imp_aux_func2            0000000180003010     test{{.*}}:test.dll
102 MAP-NEXT: 0002:00000020       __imp_aux_t2func           0000000180003020     test2{{.*}}:test2.dll
103 MAP:      0002:00001280       __auximpcopy_data          0000000180004280     test{{.*}}:test.dll
104 MAP-NEXT: 0002:00001288       __auximpcopy_func          0000000180004288     test{{.*}}:test.dll
105 MAP-NEXT: 0002:00001290       __auximpcopy_func2         0000000180004290     test{{.*}}:test.dll
106 MAP-NEXT: 0002:000012a0       __auximpcopy_t2func        00000001800042a0     test2{{.*}}:test2.dll
107 MAP:      0002:00002000       __imp_aux_data             0000000180005000     test{{.*}}:test.dll
108 MAP-NEXT: 0002:00002008       __imp_func                 0000000180005008     test{{.*}}:test.dll
109 MAP-NEXT: 0002:00002010       __imp_func2                0000000180005010     test{{.*}}:test.dll
110 MAP-NEXT: 0002:00002020       __imp_t2func               0000000180005020     test2{{.*}}:test2.dll
112 RUN: llvm-readobj --headers out.dll | FileCheck -check-prefix=HEADERS %s
113 RUN: llvm-readobj --headers out2.dll | FileCheck -check-prefix=HEADERS %s
114 RUN: llvm-readobj --headers out3.dll | FileCheck -check-prefix=HEADERS %s
115 HEADERS:  LoadConfigTableRVA: 0x4010
116 HEADERS:  IATRVA: 0x3000
117 HEADERS:  IATSize: 0x1000
119 RUN: llvm-readobj --coff-load-config out.dll | FileCheck -check-prefix=LOADCONFIG %s
120 RUN: llvm-readobj --coff-load-config out2.dll | FileCheck -check-prefix=LOADCONFIG %s
121 RUN: llvm-readobj --coff-load-config out3.dll | FileCheck -check-prefix=LOADCONFIG %s
122 LOADCONFIG: AuxiliaryIAT: 0x5000
123 LOADCONFIG: AuxiliaryIATCopy: 0x4280
125 RUN: llvm-readobj --hex-dump=.rdata out.dll | FileCheck -check-prefix=RDATA %s
126 RUN: llvm-readobj --hex-dump=.rdata out2.dll | FileCheck -check-prefix=RDATA %s
127 RUN: llvm-readobj --hex-dump=.rdata out3.dll | FileCheck -check-prefix=RDATA %s
128 RDATA:      0x180004280 00000000 00000000 14100080 01000000
129 RDATA-NEXT: 0x180004290 28100080 01000000 00000000 00000000
130 RDATA-NEXT: 0x1800042a0 48100080 01000000 00000000 00000000
131 RDATA:      0x180005000 00000000 00000000 14100080 01000000
132 RDATA-NEXT: 0x180005010 28100080 01000000 00000000 00000000
133 RDATA-NEXT: 0x180005020 48100080 01000000 00000000 00000000
135 RUN: llvm-readobj --coff-basereloc out.dll | FileCheck -check-prefix=BASERELOC %s
136 RUN: llvm-readobj --coff-basereloc out2.dll | FileCheck -check-prefix=BASERELOC %s
137 RUN: llvm-readobj --coff-basereloc out3.dll | FileCheck -check-prefix=BASERELOC %s
138 BASERELOC:      BaseReloc [
139 Aux IAT copy:
140 BASERELOC:          Address: 0x4288
141 BASERELOC-NEXT:   }
142 BASERELOC-NEXT:   Entry {
143 BASERELOC-NEXT:     Type: DIR64
144 BASERELOC-NEXT:     Address: 0x4290
145 BASERELOC-NEXT:   }
146 BASERELOC-NEXT:   Entry {
147 BASERELOC-NEXT:     Type: DIR64
148 BASERELOC-NEXT:     Address: 0x42A0
149 BASERELOC-NEXT:   }
150 Aux IAT:
151 BASERELOC-NOT:      Address: 0x5000
152 BASERELOC:          Address: 0x5008
153 BASERELOC-NEXT:   }
154 BASERELOC-NEXT:   Entry {
155 BASERELOC-NEXT:     Type: DIR64
156 BASERELOC-NEXT:     Address: 0x5010
157 BASERELOC-NEXT:   }
158 BASERELOC-NEXT:   Entry {
159 BASERELOC-NEXT:     Type: DIR64
160 BASERELOC-NEXT:     Address: 0x5020
161 BASERELOC-NEXT:   }
163 #--- test.s
164     .section .test, "r"
165     .globl arm64ec_data_sym
166     .p2align 2, 0x0
167 arm64ec_data_sym:
168     .rva __imp_func
169     .rva __imp_data
170     .rva __imp_func2
171     .rva __imp_t2func
172     .rva __imp_aux_func
173     .rva __imp_aux_data
174     .rva __imp_aux_func2
175     .rva __imp_aux_t2func
176     .rva __impchk_func
177     .rva __impchk_func2
178     .rva func
179     .rva "#func"
180     .rva "#t2func"
181     .rva __auximpcopy_func
183 #--- icall.s
184     .text
185     .globl __icall_helper_arm64ec
186     .p2align 2, 0x0
187 __icall_helper_arm64ec:
188     mov w0, #0
189     ret
191 #--- hybmp.s
192     .section .hybmp$x, "yi"
193     // __imp_func exit thunk is ignored when func is defined as well
194     .symidx __imp_func
195     .symidx dead_exit_thunk
196     .word 4
197     .symidx func
198     .symidx func_exit_thunk
199     .word 4
200     .symidx __imp_t2func
201     .symidx t2func_exit_thunk
202     .word 4
204     .section .wowthk$aa,"xr",discard,func_exit_thunk
205     .globl func_exit_thunk
206 func_exit_thunk:
207     mov w0, #1
208     ret
210     .section .wowthk$aa,"xr",discard,t2func_exit_thunk
211     .globl t2func_exit_thunk
212 t2func_exit_thunk:
213     mov w0, #2
214     ret
216     .section .wowthk$aa,"xr",discard,dead_exit_thunk
217     .globl dead_exit_thunk
218 dead_exit_thunk:
219     mov w0, #0xdead
220     ret
222 #--- test.def
223 NAME test.dll
224 EXPORTS
225     data DATA
226     func
227     func2
228     unused_func
230 #--- test2.def
231 NAME test2.dll
232 EXPORTS
233     t2func