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