brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.1 KiB · bbc682d Raw
299 lines · plain
1REQUIRES: aarch64, x862RUN: split-file %s %t.dir && cd %t.dir3 4RUN: llvm-mc -filetype=obj -triple=arm64-windows arm64-func-sym.s -o arm64-func-sym.obj5RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-func-sym.s -o arm64ec-func-sym.obj6RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-func-sym2.s -o arm64ec-func-sym2.obj7RUN: llvm-mc -filetype=obj -triple=arm64ec-windows data-sec.s -o data-sec.obj8RUN: llvm-mc -filetype=obj -triple=arm64ec-windows data-sec2.s -o data-sec2.obj9RUN: llvm-mc -filetype=obj -triple=arm64ec-windows empty-sec.s -o arm64ec-empty-sec.obj10RUN: llvm-mc -filetype=obj -triple=arm64ec-windows entry-thunk.s -o entry-thunk.obj11RUN: llvm-mc -filetype=obj -triple=x86_64-windows x86_64-func-sym.s -o x86_64-func-sym.obj12RUN: llvm-mc -filetype=obj -triple=x86_64-windows empty-sec.s -o x86_64-empty-sec.obj13RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s -o loadconfig-arm64.obj14RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj15 16Link ARM64EC DLL and verify that the code is arranged as expected.17 18RUN: lld-link -out:test.dll -machine:arm64ec arm64ec-func-sym.obj x86_64-func-sym.obj \19RUN:          loadconfig-arm64ec.obj -dll -noentry20 21RUN: llvm-readobj --coff-load-config test.dll | FileCheck -check-prefix=CODEMAP %s22CODEMAP:       CodeMap [23CODEMAP-NEXT:    0x1000 - 0x1008  ARM64EC24CODEMAP-NEXT:    0x2000 - 0x2006  X6425CODEMAP-NEXT:    0x6000 - 0x6008  ARM64EC26CODEMAP-NEXT:    0x7000 - 0x7006  X6427CODEMAP-NEXT:  ]28 29RUN: llvm-objdump -d test.dll | FileCheck -check-prefix=DISASM %s30DISASM:      Disassembly of section .text:31DISASM-EMPTY:32DISASM-NEXT: 0000000180001000 <.text>:33DISASM-NEXT: 180001000: 52800040     mov     w0, #0x234DISASM-NEXT: 180001004: d65f03c0     ret35DISASM-NEXT:                 ...36DISASM-NEXT: 180002000: b8 03 00 00 00               movl    $0x3, %eax37DISASM-NEXT: 180002005: c3                           retq38DISASM-EMPTY:39DISASM-NEXT: Disassembly of section test:40DISASM-EMPTY:41DISASM-NEXT: 0000000180006000 <test>:42DISASM-NEXT: 180006000: 528000a0     mov     w0, #0x543DISASM-NEXT: 180006004: d65f03c0     ret44DISASM-NEXT:                 ...45DISASM-NEXT: 180007000: b8 06 00 00 00               movl    $0x6, %eax46DISASM-NEXT: 180007005: c3                           retq47 48Order of arguments doesn't matter in this case, chunks are sorted by target type anyway.49 50RUN: lld-link -out:test2.dll -machine:arm64ec x86_64-func-sym.obj arm64ec-func-sym.obj \51RUN:          loadconfig-arm64ec.obj -dll -noentry52RUN: llvm-readobj --coff-load-config test2.dll | FileCheck -check-prefix=CODEMAP %s53RUN: llvm-objdump -d test2.dll | FileCheck -check-prefix=DISASM %s54 55RUN: lld-link -out:testx.dll -machine:arm64x arm64-func-sym.obj arm64ec-func-sym.obj \56RUN:          x86_64-func-sym.obj loadconfig-arm64.obj loadconfig-arm64ec.obj -dll -noentry57 58Adding empty chunks does not affect code map ranges.59 60RUN: lld-link -out:test3.dll -machine:arm64ec x86_64-empty-sec.obj arm64ec-empty-sec.obj \61RUN:          arm64ec-func-sym.obj  x86_64-func-sym.obj loadconfig-arm64ec.obj -dll -noentry62RUN: llvm-readobj --coff-load-config test3.dll | FileCheck -check-prefix=CODEMAP %s63 64Do the same with ARM64X target.65 66RUN: llvm-readobj --coff-load-config testx.dll | FileCheck -check-prefix=CODEMAPX %s67CODEMAPX:       CodeMap [68CODEMAPX-NEXT:    0x1000 - 0x1008  ARM6469CODEMAPX-NEXT:    0x2000 - 0x2008  ARM64EC70CODEMAPX-NEXT:    0x3000 - 0x3006  X6471CODEMAPX-NEXT:    0x7000 - 0x7008  ARM64EC72CODEMAPX-NEXT:    0x8000 - 0x8006  X6473CODEMAPX-NEXT:  ]74 75RUN: llvm-objdump -d testx.dll | FileCheck -check-prefix=DISASMX %s76DISASMX:      Disassembly of section .text:77DISASMX-EMPTY:78DISASMX-NEXT: 0000000180001000 <.text>:79DISASMX-NEXT: 180001000: 528000e0     mov     w0, #0x780DISASMX-NEXT: 180001004: d65f03c0     ret81DISASMX-NEXT:                 ...82DISASMX-NEXT: 180002000: 52800040     mov     w0, #0x283DISASMX-NEXT: 180002004: d65f03c0     ret84DISASMX-NEXT:                 ...85DISASMX-NEXT: 180003000: b8 03 00 00 00               movl    $0x3, %eax86DISASMX-NEXT: 180003005: c3                           retq87DISASMX-EMPTY:88DISASMX-NEXT: Disassembly of section test:89DISASMX-EMPTY:90DISASMX-NEXT: 0000000180007000 <test>:91DISASMX-NEXT: 180007000: 528000a0     mov     w0, #0x592DISASMX-NEXT: 180007004: d65f03c0     ret93DISASMX-NEXT:                 ...94DISASMX-NEXT: 180008000: b8 06 00 00 00               movl    $0x6, %eax95DISASMX-NEXT: 180008005: c3                           retq96 97Test merged sections.98 99RUN: lld-link -out:testm.dll -machine:arm64ec arm64ec-func-sym.obj x86_64-func-sym.obj \100RUN:          loadconfig-arm64ec.obj -dll -noentry -merge:test=.text101 102RUN: llvm-readobj --coff-load-config testm.dll | FileCheck -check-prefix=CODEMAPM %s103CODEMAPM:      CodeMap [104CODEMAPM-NEXT:   0x1000 - 0x1010  ARM64EC105CODEMAPM-NEXT:   0x2000 - 0x200E  X64106CODEMAPM-NEXT: ]107 108RUN: llvm-objdump -d testm.dll | FileCheck -check-prefix=DISASMM %s109DISASMM:      Disassembly of section .text:110DISASMM-EMPTY:111DISASMM-NEXT: 0000000180001000 <.text>:112DISASMM-NEXT: 180001000: 52800040     mov     w0, #0x2113DISASMM-NEXT: 180001004: d65f03c0     ret114DISASMM-NEXT: 180001008: 528000a0     mov     w0, #0x5115DISASMM-NEXT: 18000100c: d65f03c0     ret116DISASMM-NEXT:                 ...117DISASMM-NEXT: 180002000: b8 03 00 00 00               movl    $0x3, %eax118DISASMM-NEXT: 180002005: c3                           retq119DISASMM-NEXT: 180002006: 00 00                        addb    %al, (%rax)120DISASMM-NEXT: 180002008: b8 06 00 00 00               movl    $0x6, %eax121DISASMM-NEXT: 18000200d: c3                           retq122 123Merging data sections into code sections causes data to be separated from the code when sorting chunks.124 125RUN: lld-link -out:testdm.dll -machine:arm64ec arm64ec-func-sym.obj x86_64-func-sym.obj data-sec.obj \126RUN:          data-sec2.obj loadconfig-arm64ec.obj -dll -noentry -merge:.testdata=.text -merge:.rdata=test127 128RUN: llvm-readobj --coff-load-config testdm.dll | FileCheck -check-prefix=CODEMAPDM %s129CODEMAPDM:      CodeMap [130CODEMAPDM-NEXT:     0x2000 - 0x2008  ARM64EC131CODEMAPDM-NEXT:     0x3000 - 0x3006  X64132CODEMAPDM-NEXT:     0x7000 - 0x7008  ARM64EC133CODEMAPDM-NEXT:     0x8000 - 0x8006  X64134CODEMAPDM-NEXT: ]135 136RUN: llvm-objdump -d testdm.dll | FileCheck -check-prefix=DISASMDM %s137DISASMDM:      Disassembly of section .text:138DISASMDM-EMPTY:139DISASMDM-NEXT: 0000000180001000 <.text>:140DISASMDM-NEXT: 180001000: 00000001     udf     #0x1141DISASMDM-NEXT: 180001004: 00000000     udf     #0x0142DISASMDM-NEXT: 180001008: 00000002     udf     #0x2143DISASMDM-NEXT:                 ...144DISASMDM-NEXT: 180002000: 52800040     mov     w0, #0x2145DISASMDM-NEXT: 180002004: d65f03c0     ret146DISASMDM-NEXT:                 ...147DISASMDM-NEXT: 180003000: b8 03 00 00 00               movl    $0x3, %eax148DISASMDM-NEXT: 180003005: c3                           retq149DISASMDM-EMPTY:150DISASMDM-NEXT: Disassembly of section test:151DISASMDM-EMPTY:152DISASMDM-NEXT: 0000000180006000 <test>:153DISASMDM:      180007000: 528000a0     mov     w0, #0x5154DISASMDM-NEXT: 180007004: d65f03c0     ret155DISASMDM-NEXT:                 ...156DISASMDM-NEXT: 180008000: b8 06 00 00 00               movl    $0x6, %eax157DISASMDM-NEXT: 180008005: c3                           retq158 159Merging a code section into data section produces a valid code map.160 161RUN: lld-link -out:testcm.dll -machine:arm64ec x86_64-func-sym.obj data-sec.obj \162RUN:          loadconfig-arm64ec.obj -dll -noentry -merge:test=.testdata -merge:.text=.testdata163 164RUN: llvm-readobj --coff-load-config testcm.dll | FileCheck -check-prefix=CODEMAPCM %s165CODEMAPCM:      CodeMap [166CODEMAPCM-NEXT:     0x4000 - 0x4016  X64167CODEMAPCM-NEXT: ]168 169RUN: llvm-objdump -d testcm.dll | FileCheck -check-prefix=DISASMCM %s170DISASMCM:      Disassembly of section .testdat:171DISASMCM-EMPTY:172DISASMCM-NEXT: 0000000180004000 <.testdat>:173DISASMCM-NEXT: 180004000: 01 00                        addl %eax, (%rax)174DISASMCM-NEXT: 180004002: 00 00                        addb %al, (%rax)175DISASMCM-NEXT: 180004004: 00 00                        addb %al, (%rax)176DISASMCM-NEXT: 180004006: 00 00                        addb %al, (%rax)177DISASMCM-NEXT: 180004008: b8 03 00 00 00               movl    $0x3, %eax178DISASMCM-NEXT: 18000400d: c3                           retq179DISASMCM-NEXT: 18000400e: 00 00                        addb    %al, (%rax)180DISASMCM-NEXT: 180004010: b8 06 00 00 00               movl    $0x6, %eax181DISASMCM-NEXT: 180004015: c3182 183Test code map range entry spanning over multiple sections.184 185RUN: lld-link -out:testms.dll -machine:arm64ec arm64ec-func-sym.obj arm64ec-func-sym2.obj \186RUN:          loadconfig-arm64ec.obj -dll -noentry187 188RUN: llvm-readobj --coff-load-config testms.dll | FileCheck -check-prefix=CODEMAPMS %s189CODEMAPMS:      CodeMap [190CODEMAPMS-NEXT:     0x1000 - 0x1008  ARM64EC191CODEMAPMS-NEXT:     0x5000 - 0x6008  ARM64EC192CODEMAPMS-NEXT: ]193 194RUN: llvm-objdump -d testms.dll | FileCheck -check-prefix=DISASMMS %s195DISASMMS:      Disassembly of section .text:196DISASMMS-EMPTY:197DISASMMS-NEXT: 0000000180001000 <.text>:198DISASMMS-NEXT: 180001000: 52800040     mov     w0, #0x2                // =2199DISASMMS-NEXT: 180001004: d65f03c0     ret200DISASMMS-EMPTY:201DISASMMS-NEXT: Disassembly of section test:202DISASMMS-EMPTY:203DISASMMS-NEXT: 0000000180005000 <test>:204DISASMMS-NEXT: 180005000: 528000a0     mov     w0, #0x5                // =5205DISASMMS-NEXT: 180005004: d65f03c0     ret206DISASMMS-EMPTY:207DISASMMS-NEXT: Disassembly of section test2:208DISASMMS-EMPTY:209DISASMMS-NEXT: 0000000180006000 <test2>:210DISASMMS-NEXT: 180006000: 528000a0     mov     w0, #0x5                // =5211DISASMMS-NEXT: 180006004: d65f03c0     ret212 213Test the code map that includes an ARM64EC function padded by its entry-thunk offset.214 215RUN: lld-link -out:testpad.dll -machine:arm64ec entry-thunk.obj loadconfig-arm64ec.obj -dll -noentry -include:func216RUN: llvm-readobj --coff-load-config testpad.dll | FileCheck -check-prefix=CODEMAPPAD %s217CODEMAPPAD:      CodeMap [218CODEMAPPAD:        0x1000 - 0x1010  ARM64EC219CODEMAPPAD-NEXT: ]220 221 222#--- arm64-func-sym.s223    .text224    .globl arm64_func_sym225    .p2align 2, 0x0226arm64_func_sym:227    mov w0, #7228    ret229 230#--- arm64ec-func-sym.s231    .text232    .globl arm64ec_func_sym233    .p2align 2, 0x0234arm64ec_func_sym:235    mov w0, #2236    ret237 238    .section test, "xr"239    .globl arm64ec_func_sym2240    .p2align 2, 0x0241arm64ec_func_sym2:242    mov w0, #5243    ret244 245#--- arm64ec-func-sym2.s246    .section test2, "xr"247    .globl arm64ec_func_sym3248    .p2align 2, 0x0249arm64ec_func_sym3:250    mov w0, #5251    ret252 253#--- x86_64-func-sym.s254    .text255    .globl x86_64_func_sym256    .p2align 2, 0x0257x86_64_func_sym:258    movl $3, %eax259    retq260 261    .section test, "xr"262    .globl x86_64_func_sym2263    .p2align 2, 0x0264x86_64_func_sym2:265    movl $6, %eax266    retq267 268#--- data-sec.s269    .section .testdata, "rd"270    .xword 1271 272#--- data-sec2.s273    .section .testdata, "rd"274    .xword 2275 276#--- empty-sec.s277    .section .empty1, "xr"278    .section .empty2, "xr"279    .section .empty3, "xr"280 281#--- entry-thunk.s282    .section .text,"xr",discard,func283    .globl func284    .p2align 2, 0x0285func:286    mov w0, #1287    ret288 289    .section .wowthk$aa,"xr",discard,thunk290    .globl thunk291    .p2align 2292thunk:293    ret294 295    .section .hybmp$x,"yi"296    .symidx func297    .symidx thunk298    .word 1  // entry thunk299