brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · d179451 Raw
92 lines · plain
1# REQUIRES: aarch642# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o3# RUN: llvm-mc -filetype=obj -triple=aarch64 %p/Inputs/aarch64-addrifunc.s -o %t1.o4 5# RUN: ld.lld --shared --soname=t1.so %t1.o -o %t1.so6# RUN: ld.lld --pie %t1.so %t.o -o %t7# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --mattr=+bti --triple=aarch64-linux-gnu %t | FileCheck %s8 9# RUN: ld.lld -shared -Bsymbolic %t1.so %t.o -o %t.so10# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn --mattr=+bti %t.so | FileCheck %s --check-prefix=SHARED11 12# When the address of an ifunc is taken using a non-got reference which clang13# can do, LLD exports a canonical PLT entry that may have its address taken so14# we must use bti c.15 16# CHECK: Disassembly of section .plt:17# CHECK: 00000000000103a0 <.plt>:18# CHECK-NEXT:    103a0:         bti     c19# CHECK-NEXT:                   stp     x16, x30, [sp, #-16]!20# CHECK-NEXT:                   adrp    x16, 0x3000021# CHECK-NEXT:                   ldr     x17, [x16, #1344]22# CHECK-NEXT:                   add     x16, x16, #134423# CHECK-NEXT:                   br      x1724# CHECK-NEXT:                   nop25# CHECK-NEXT:                   nop26# CHECK: 00000000000103c0 <func1@plt>:27# CHECK-NEXT:    103c0:         adrp    x16, 0x3000028# CHECK-NEXT:                   ldr     x17, [x16, #1352]29# CHECK-NEXT:                   add     x16, x16, #135230# CHECK-NEXT:                   br      x1731# CHECK-NEXT:                   nop32# CHECK-NEXT:                   nop33# CHECK-EMPTY:34# CHECK: Disassembly of section .iplt:35# CHECK-EMPTY:36## The address of ifunc1@plt does not escape so it does not need `bti c`,37## but having bti is not wrong.38# CHECK-NEXT: 00000000000103e0 <ifunc2>:39# CHECK-NEXT:    103e0:         bti     c40# CHECK-NEXT:                   adrp    x16, 0x3000041# CHECK-NEXT:                   ldr     x17, [x16, #1360]42# CHECK-NEXT:                   add     x16, x16, #136043# CHECK-NEXT:                   br      x1744# CHECK-NEXT:                   nop45# CHECK-NEXT:    103f8:         bti     c46# CHECK-NEXT:                   adrp    x16, 0x3000047# CHECK-NEXT:                   ldr     x17, [x16, #1368]48# CHECK-NEXT:                   add     x16, x16, #136849# CHECK-NEXT:                   br      x1750# CHECK-NEXT:                   nop51 52## The address of ifunc2 (STT_FUNC) escapes, so it must have `bti c`.53# SHARED:      <ifunc2>:54# SHARED-NEXT:    bti     c55 56# SHARED:         nop57# SHARED-NEXT:    bti     c58 59.section ".note.gnu.property", "a"60.long 461.long 0x1062.long 0x563.asciz "GNU"64 65.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND66.long 467.long 1          // GNU_PROPERTY_AARCH64_FEATURE_1_BTI68.long 069 70.text71.globl ifunc172.type ifunc1,@gnu_indirect_function73ifunc1:74 ret75 76.globl ifunc277.type ifunc2,@gnu_indirect_function78ifunc2:79  ret80 81.globl func182 83.text84.globl _start85.type _start, %function86_start:87  bl func188  bl ifunc189  adrp x8, ifunc290  add x8, x8, :lo12:ifunc291  ret92