1// REQUIRES: aarch64 2// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %S/Inputs/shared2.s -o %t1.o 3// RUN: ld.lld %t1.o --shared --soname=t.so -o %t.so 4// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o 5// RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout 6// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM 7// RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT 8// RUN: llvm-readobj --dynamic-table -r %tout | FileCheck %s 9 10// Check that the PLTRELSZ tag does not include the IRELATIVE relocations 11// CHECK: DynamicSection [ 12// CHECK: 0x0000000000000008 RELASZ 48 (bytes) 13// CHECK: 0x0000000000000002 PLTRELSZ 48 (bytes) 14 15// Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt 16// CHECK: Relocations [ 17// CHECK-NEXT: Section (4) .rela.dyn { 18// CHECK-NEXT: 0x230468 R_AARCH64_IRELATIVE - 0x2102D8 19// CHECK-NEXT: 0x230470 R_AARCH64_IRELATIVE - 0x2102DC 20// CHECK-NEXT: } 21// CHECK-NEXT: Section (5) .rela.plt { 22// CHECK-NEXT: 0x230458 R_AARCH64_JUMP_SLOT bar2 0x0 23// CHECK-NEXT: 0x230460 R_AARCH64_JUMP_SLOT zed2 0x0 24// CHECK-NEXT: } 25// CHECK-NEXT: ] 26 27// Check that .got.plt entries point back to PLT header 28// GOTPLT: Contents of section .got.plt: 29// GOTPLT-NEXT: 230440 00000000 00000000 00000000 00000000 30// GOTPLT-NEXT: 230450 00000000 00000000 f0022100 00000000 31// GOTPLT-NEXT: 230460 f0022100 00000000 00000000 00000000 32// GOTPLT-NEXT: 230470 00000000 00000000 33 34// Check that a PLT header is written and the ifunc entries appear last 35// DISASM: Disassembly of section .text: 36// DISASM-EMPTY: 37// DISASM-NEXT: <foo>: 38// DISASM-NEXT: 2102d8: ret 39// DISASM: <bar>: 40// DISASM-NEXT: 2102dc: ret 41// DISASM: <_start>: 42// DISASM-NEXT: 2102e0: bl 0x210330 <zed2+0x210330> 43// DISASM-NEXT: 2102e4: bl 0x210340 <zed2+0x210340> 44// DISASM-NEXT: 2102e8: bl 0x210310 <bar2@plt> 45// DISASM-NEXT: 2102ec: bl 0x210320 <zed2@plt> 46// DISASM-EMPTY: 47// DISASM-NEXT: Disassembly of section .plt: 48// DISASM-EMPTY: 49// DISASM-NEXT: <.plt>: 50// DISASM-NEXT: 2102f0: stp x16, x30, [sp, #-16]! 51// DISASM-NEXT: 2102f4: adrp x16, #131072 52// DISASM-NEXT: 2102f8: ldr x17, [x16, #1104] 53// DISASM-NEXT: 2102fc: add x16, x16, #1104 54// DISASM-NEXT: 210300: br x17 55// DISASM-NEXT: 210304: nop 56// DISASM-NEXT: 210308: nop 57// DISASM-NEXT: 21030c: nop 58// DISASM-EMPTY: 59// DISASM-NEXT: <bar2@plt>: 60// DISASM-NEXT: 210310: adrp x16, #131072 61// DISASM-NEXT: 210314: ldr x17, [x16, #1112] 62// DISASM-NEXT: 210318: add x16, x16, #1112 63// DISASM-NEXT: 21031c: br x17 64// DISASM-EMPTY: 65// DISASM-NEXT: <zed2@plt>: 66// DISASM-NEXT: 210320: adrp x16, #131072 67// DISASM-NEXT: 210324: ldr x17, [x16, #1120] 68// DISASM-NEXT: 210328: add x16, x16, #1120 69// DISASM-NEXT: 21032c: br x17 70// DISASM-EMPTY: 71// DISASM-NEXT: Disassembly of section .iplt: 72// DISASM-EMPTY: 73// DISASM-NEXT: <.iplt>: 74// DISASM-NEXT: 210330: adrp x16, #131072 75// DISASM-NEXT: 210334: ldr x17, [x16, #1128] 76// DISASM-NEXT: 210338: add x16, x16, #1128 77// DISASM-NEXT: 21033c: br x17 78// DISASM-NEXT: 210340: adrp x16, #131072 79// DISASM-NEXT: 210344: ldr x17, [x16, #1136] 80// DISASM-NEXT: 210348: add x16, x16, #1136 81// DISASM-NEXT: 21034c: br x17 82 83.text 84.type foo STT_GNU_IFUNC 85.globl foo 86foo: 87 ret 88 89.type bar STT_GNU_IFUNC 90.globl bar 91bar: 92 ret 93 94.globl _start 95_start: 96 bl foo 97 bl bar 98 bl bar2 99 bl zed2 100