1 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %S/Inputs/shared2.s -o %t1.o
2 // RUN: ld.lld %t1.o --shared -o %t.so
3 // RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
4 // RUN: ld.lld %t.so %t.o -o %tout
5 // RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DISASM
6 // RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT
7 // RUN: llvm-readobj -r -dynamic-table %tout | FileCheck %s
10 // Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
11 // CHECK: Relocations [
12 // CHECK-NEXT: Section (4) .rela.plt {
13 // CHECK: 0x40018 R_AARCH64_JUMP_SLOT bar2 0x0
14 // CHECK-NEXT: 0x40020 R_AARCH64_JUMP_SLOT zed2 0x0
15 // CHECK-NEXT: 0x40028 R_AARCH64_IRELATIVE - 0x20000
16 // CHECK-NEXT: 0x40030 R_AARCH64_IRELATIVE - 0x20004
20 // Check that .got.plt entries point back to PLT header
21 // GOTPLT: Contents of section .got.plt:
22 // GOTPLT-NEXT: 40000 00000000 00000000 00000000 00000000
23 // GOTPLT-NEXT: 40010 00000000 00000000 20000200 00000000
24 // GOTPLT-NEXT: 40020 20000200 00000000 20000200 00000000
25 // GOTPLT-NEXT: 40030 20000200 00000000
27 // Check that the PLTRELSZ tag includes the IRELATIVE relocations
28 // CHECK: DynamicSection [
29 // CHECK: 0x0000000000000002 PLTRELSZ 96 (bytes)
31 // Check that a PLT header is written and the ifunc entries appear last
32 // DISASM: Disassembly of section .text:
34 // DISASM-NEXT: 20000: c0 03 5f d6 ret
36 // DISASM-NEXT: 20004: c0 03 5f d6 ret
38 // DISASM-NEXT: 20008: 16 00 00 94 bl #88
39 // DISASM-NEXT: 2000c: 19 00 00 94 bl #100
40 // DISASM-NEXT: 20010: 0c 00 00 94 bl #48
41 // DISASM-NEXT: 20014: 0f 00 00 94 bl #60
42 // DISASM-NEXT: Disassembly of section .plt:
44 // DISASM-NEXT: 20020: f0 7b bf a9 stp x16, x30, [sp, #-16]!
45 // DISASM-NEXT: 20024: 10 01 00 90 adrp x16, #131072
46 // DISASM-NEXT: 20028: 11 0a 40 f9 ldr x17, [x16, #16]
47 // DISASM-NEXT: 2002c: 10 42 00 91 add x16, x16, #16
48 // DISASM-NEXT: 20030: 20 02 1f d6 br x17
49 // DISASM-NEXT: 20034: 1f 20 03 d5 nop
50 // DISASM-NEXT: 20038: 1f 20 03 d5 nop
51 // DISASM-NEXT: 2003c: 1f 20 03 d5 nop
52 // DISASM-NEXT: 20040: 10 01 00 90 adrp x16, #131072
53 // DISASM-NEXT: 20044: 11 0e 40 f9 ldr x17, [x16, #24]
54 // DISASM-NEXT: 20048: 10 62 00 91 add x16, x16, #24
55 // DISASM-NEXT: 2004c: 20 02 1f d6 br x17
56 // DISASM-NEXT: 20050: 10 01 00 90 adrp x16, #131072
57 // DISASM-NEXT: 20054: 11 12 40 f9 ldr x17, [x16, #32]
58 // DISASM-NEXT: 20058: 10 82 00 91 add x16, x16, #32
59 // DISASM-NEXT: 2005c: 20 02 1f d6 br x17
60 // DISASM-NEXT: 20060: 10 01 00 90 adrp x16, #131072
61 // DISASM-NEXT: 20064: 11 16 40 f9 ldr x17, [x16, #40]
62 // DISASM-NEXT: 20068: 10 a2 00 91 add x16, x16, #40
63 // DISASM-NEXT: 2006c: 20 02 1f d6 br x17
64 // DISASM-NEXT: 20070: 10 01 00 90 adrp x16, #131072
65 // DISASM-NEXT: 20074: 11 1a 40 f9 ldr x17, [x16, #48]
66 // DISASM-NEXT: 20078: 10 c2 00 91 add x16, x16, #48
67 // DISASM-NEXT: 2007c: 20 02 1f d6 br x17
70 .type foo STT_GNU_IFUNC
75 .type bar STT_GNU_IFUNC