brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.6 KiB · 3b3c174 Raw
175 lines · plain
1# REQUIRES: aarch642# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t.o3# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-btipac1.s -o %t1.o4# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3.s -o %t3.o5# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/aarch64-func3-btipac.s -o %t3btipac.o6 7## Build shared library with all inputs having BTI and PAC, expect PLT8## entries supporting both PAC and BTI. For a shared library this means:9## PLT[0] has bti c at start10## PLT[n] has autia1716 before br x1711 12# RUN: ld.lld %t1.o %t3btipac.o --shared --soname=t.so -o %t.so13# RUN: llvm-readelf -n %t.so | FileCheck --check-prefix BTIPACPROP %s14# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.5a --no-show-raw-insn %t.so | FileCheck --check-prefix BTIPACSO %s15# RUN: llvm-readelf --dynamic-table %t.so | FileCheck --check-prefix BTIPACDYN %s16 17# BTIPACSO: Disassembly of section .text:18# BTIPACSO: 0000000000010348 <func2>:19# BTIPACSO-NEXT:    10348:              bl      0x10380 <func3@plt>20# BTIPACSO-NEXT:                        ret21# BTIPACSO: 0000000000010350 <func3>:22# BTIPACSO-NEXT:    10350:              ret23# BTIPACSO: Disassembly of section .plt:24# BTIPACSO: 0000000000010360 <.plt>:25# BTIPACSO-NEXT:    10360:              bti     c26# BTIPACSO-NEXT:                        stp     x16, x30, [sp, #-16]!27# BTIPACSO-NEXT:                        adrp    x16, 0x3000028# BTIPACSO-NEXT:                        ldr     x17, [x16, #1144]29# BTIPACSO-NEXT:                        add     x16, x16, #114430# BTIPACSO-NEXT:                        br      x1731# BTIPACSO-NEXT:                        nop32# BTIPACSO-NEXT:                        nop33# BTIPACSO: 0000000000010380 <func3@plt>:34# BTIPACSO-NEXT:    10380:              adrp    x16, 0x3000035# BTIPACSO-NEXT:                        ldr     x17, [x16, #1152]36# BTIPACSO-NEXT:                        add     x16, x16, #115237# BTIPACSO-NEXT:                        br      x1738 39# BTIPACPROP:    Properties:    aarch64 feature: BTI, PAC40 41# BTIPACDYN:   0x0000000070000001 (AARCH64_BTI_PLT)42# BTIPACDYN-NOT:   0x0000000070000003 (AARCH64_PAC_PLT)43 44## Make an executable with both BTI and PAC properties. Expect:45## PLT[0] bti c as first instruction46## PLT[n] bti n as first instruction47 48# RUN: ld.lld %t.o %t3btipac.o %t.so -o %t.exe49# RUN: llvm-readelf -n %t.exe | FileCheck --check-prefix=BTIPACPROP %s50# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.5a --no-show-raw-insn %t.exe | FileCheck --check-prefix BTIPACEX %s51# RUN: llvm-readelf --dynamic-table %t.exe | FileCheck --check-prefix BTIPACDYNEX %s52 53# BTIPACEX: Disassembly of section .text:54# BTIPACEX: 0000000000210370 <func1>:55# BTIPACEX-NEXT:   210370:              bl      0x2103a0 <func2@plt>56# BTIPACEX-NEXT:                        ret57# BTIPACEX-NEXT:                        ret58# BTIPACEX: 000000000021037c <func3>:59# BTIPACEX-NEXT:   21037c:              ret60# BTIPACEX: Disassembly of section .plt:61# BTIPACEX: 0000000000210380 <.plt>:62# BTIPACEX-NEXT:   210380:              bti     c63# BTIPACEX-NEXT:                        stp     x16, x30, [sp, #-16]!64# BTIPACEX-NEXT:                        adrp    x16, 0x23000065# BTIPACEX-NEXT:                        ldr     x17, [x16, #1192]66# BTIPACEX-NEXT:                        add     x16, x16, #119267# BTIPACEX-NEXT:                        br      x1768# BTIPACEX-NEXT:                        nop69# BTIPACEX-NEXT:                        nop70# BTIPACEX: 00000000002103a0 <func2@plt>:71# BTIPACEX-NEXT:   2103a0:              adrp    x16, 0x23000072# BTIPACEX-NEXT:                        ldr     x17, [x16, #1200]73# BTIPACEX-NEXT:                        add     x16, x16, #120074# BTIPACEX-NEXT:                        br      x1775# BTIPACEX-NEXT:                        nop76# BTIPACEX-NEXT:                        nop77 78# BTIPACDYNEX:   0x0000000070000001 (AARCH64_BTI_PLT)79# BTIPACDYNEX-NOT:   0x0000000070000003 (AARCH64_PAC_PLT)80 81## Check that combinations of BTI+PAC with 0 properties results in standard PLT82 83# RUN: ld.lld %t.o %t3.o %t.so -o %t.exe84# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.5a --no-show-raw-insn %t.exe | FileCheck --check-prefix EX %s85# RUN: llvm-readelf --dynamic-table %t.exe | FileCheck --check-prefix=NODYN %s86 87# EX: Disassembly of section .text:88# EX: 00000000002102e0 <func1>:89# EX-NEXT:   2102e0: bl      0x210310 <func2@plt>90# EX-NEXT:           ret91# EX-NEXT:           ret92# EX: 00000000002102ec <func3>:93# EX-NEXT:   2102ec: ret94# EX: Disassembly of section .plt:95# EX: 00000000002102f0 <.plt>:96# EX-NEXT:   2102f0: stp     x16, x30, [sp, #-16]!97# EX-NEXT:           adrp    x16, 0x23000098# EX-NEXT:           ldr     x17, [x16, #1024]99# EX-NEXT:           add     x16, x16, #1024100# EX-NEXT:           br      x17101# EX-NEXT:           nop102# EX-NEXT:           nop103# EX-NEXT:           nop104# EX: 0000000000210310 <func2@plt>:105# EX:        210310: adrp    x16, 0x230000106# EX-NEXT:           ldr     x17, [x16, #1032]107# EX-NEXT:           add     x16, x16, #1032108# EX-NEXT:           br      x17109 110# NODYN-NOT:   0x0000000070000001 (AARCH64_BTI_PLT)111# NODYN-NOT:   0x0000000070000003 (AARCH64_PAC_PLT)112 113## Check that combination of -z pac-plt and -z force-bti warns for the file that114## doesn't contain the BTI property, but generates PAC and BTI PLT sequences.115## The -z pac-plt doesn't warn as it is not required for correctness.116## Expect:117## PLT[0] bti c as first instruction118## PLT[n] bti n as first instruction, autia1716 before br x17119 120# RUN: ld.lld %t.o %t3.o %t.so -z pac-plt -z force-bti -o %t.exe 2>&1 | FileCheck --check-prefix=FORCE-WARN %s121 122# FORCE-WARN: aarch64-feature-btipac.s.tmp3.o: -z force-bti: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_BTI property123 124# RUN: llvm-readelf -n %t.exe | FileCheck --check-prefix=BTIPACPROP %s125# RUN: llvm-objdump --no-print-imm-hex -d --mattr=+v8.5a --no-show-raw-insn %t.exe | FileCheck --check-prefix BTIPACEX2 %s126# RUN: llvm-readelf --dynamic-table %t.exe | FileCheck --check-prefix BTIPACDYN2 %s127.section ".note.gnu.property", "a"128.long 4129.long 0x10130.long 0x5131.asciz "GNU"132 133.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND134.long 4135.long 3          // GNU_PROPERTY_AARCH64_FEATURE_1_BTI and PAC136.long 0137 138.text139.globl _start140.type func1,%function141func1:142  bl func2143  ret144.globl func3145.type func3,%function146  ret147 148# BTIPACEX2: Disassembly of section .text:149# BTIPACEX2: 0000000000210370 <func1>:150# BTIPACEX2-NEXT:   210370:              bl      0x2103a0 <func2@plt>151# BTIPACEX2-NEXT:                        ret152# BTIPACEX2-NEXT:                        ret153# BTIPACEX2: 000000000021037c <func3>:154# BTIPACEX2-NEXT:   21037c:              ret155# BTIPACEX2: Disassembly of section .plt:156# BTIPACEX2: 0000000000210380 <.plt>:157# BTIPACEX2-NEXT:   210380:              bti     c158# BTIPACEX2-NEXT:                        stp     x16, x30, [sp, #-16]!159# BTIPACEX2-NEXT:                        adrp    x16, 0x230000160# BTIPACEX2-NEXT:                        ldr     x17, [x16, #1208]161# BTIPACEX2-NEXT:                        add     x16, x16, #1208162# BTIPACEX2-NEXT:                        br      x17163# BTIPACEX2-NEXT:                        nop164# BTIPACEX2-NEXT:                        nop165# BTIPACEX2: 00000000002103a0 <func2@plt>:166# BTIPACEX2-NEXT:   2103a0:              adrp    x16, 0x230000167# BTIPACEX2-NEXT:                        ldr     x17, [x16, #1216]168# BTIPACEX2-NEXT:                        add     x16, x16, #1216169# BTIPACEX2-NEXT:                        autia1716170# BTIPACEX2-NEXT:                        br      x17171# BTIPACEX2-NEXT:                        nop172 173# BTIPACDYN2:        0x0000000070000001 (AARCH64_BTI_PLT)174# BTIPACDYN2-NEXT:   0x0000000070000003 (AARCH64_PAC_PLT)175