• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// REQUIRES: arm
2// RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabihf %S/Inputs/arm-shared.s -o %t1.o
3// RUN: ld.lld %t1.o --shared -soname=t.so -o %t.so
4// RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabihf %s -o %t.o
5// RUN: ld.lld %t.so %t.o -o %tout
6// RUN: llvm-objdump --triple=armv7a-linux-gnueabihf -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 -r --dynamic-table %tout | FileCheck %s
9
10// Check that the IRELATIVE relocations are last in the .got
11// CHECK: Relocations [
12// CHECK-NEXT:   Section (5) .rel.dyn {
13// CHECK-NEXT:     0x302E0 R_ARM_GLOB_DAT bar2 0x0
14// CHECK-NEXT:     0x302E4 R_ARM_GLOB_DAT zed2 0x0
15// CHECK-NEXT:     0x302E8 R_ARM_IRELATIVE - 0x0
16// CHECK-NEXT:     0x302EC R_ARM_IRELATIVE - 0x0
17// CHECK-NEXT:   }
18// CHECK-NEXT:   Section (6) .rel.plt {
19// CHECK-NEXT:     0x402FC R_ARM_JUMP_SLOT bar2 0x0
20// CHECK-NEXT:     0x40300 R_ARM_JUMP_SLOT zed2 0x0
21// CHECK-NEXT:   }
22// CHECK-NEXT: ]
23
24// Check that the GOT entries refer back to the ifunc resolver
25// GOTPLT: Contents of section .got:
26// GOTPLT-NEXT:  302e0 00000000 00000000 dc010200 e0010200
27// GOTPLT: Contents of section .got.plt:
28// GOTPLT-NEXT:  402f0 00000000 00000000 00000000 00020200
29// GOTPLT-NEXT:  40300 00020200
30
31// DISASM: Disassembly of section .text:
32// DISASM-EMPTY:
33// DISASM-NEXT: <foo>:
34// DISASM-NEXT:    201dc:       bx      lr
35// DISASM: <bar>:
36// DISASM-NEXT:    201e0:       bx      lr
37// DISASM: <_start>:
38// DISASM-NEXT:    201e4:       bl      #84
39// DISASM-NEXT:    201e8:       bl      #96
40// DISASM: <$d.1>:
41// DISASM-NEXT:    201ec:       00 00 00 00     .word   0x00000000
42// DISASM-NEXT:    201f0:       04 00 00 00     .word   0x00000004
43// DISASM:         201f4:       bl      #36
44// DISASM-NEXT:    201f8:       bl      #48
45// DISASM-EMPTY:
46// DISASM-NEXT: Disassembly of section .plt:
47// DISASM-EMPTY:
48// DISASM-NEXT: <$a>:
49// DISASM-NEXT:    20200:       str     lr, [sp, #-4]!
50// DISASM-NEXT:    20204:       add     lr, pc, #0, #12
51// DISASM-NEXT:    20208:       add     lr, lr, #32
52// DISASM-NEXT:    2020c:       ldr     pc, [lr, #236]!
53// DISASM: <$d>:
54// DISASM-NEXT:    20210:       d4 d4 d4 d4     .word   0xd4d4d4d4
55// DISASM-NEXT:    20214:       d4 d4 d4 d4     .word   0xd4d4d4d4
56// DISASM-NEXT:    20218:       d4 d4 d4 d4     .word   0xd4d4d4d4
57// DISASM-NEXT:    2021c:       d4 d4 d4 d4     .word   0xd4d4d4d4
58// DISASM: <$a>:
59// DISASM-NEXT:    20220:       add     r12, pc, #0, #12
60// DISASM-NEXT:    20224:       add     r12, r12, #32
61// DISASM-NEXT:    20228:       ldr     pc, [r12, #212]!
62// DISASM: <$d>:
63// DISASM-NEXT:    2022c:       d4 d4 d4 d4     .word   0xd4d4d4d4
64// DISASM: <$a>:
65// DISASM-NEXT:    20230:       add     r12, pc, #0, #12
66// DISASM-NEXT:    20234:       add     r12, r12, #32
67// DISASM-NEXT:    20238:       ldr     pc, [r12, #200]!
68// DISASM: <$d>:
69// DISASM-NEXT:    2023c:       d4 d4 d4 d4     .word   0xd4d4d4d4
70// DISASM: <$a>:
71// DISASM-NEXT:    20240:       add     r12, pc, #0, #12
72// DISASM-NEXT:    20244:       add     r12, r12, #16
73// DISASM-NEXT:    20248:       ldr     pc, [r12, #160]!
74// DISASM: <$d>:
75// DISASM-NEXT:    2024c:       d4 d4 d4 d4     .word   0xd4d4d4d4
76// DISASM: <$a>:
77// DISASM-NEXT:    20250:       add     r12, pc, #0, #12
78// DISASM-NEXT:    20254:       add     r12, r12, #16
79// DISASM-NEXT:    20258:       ldr     pc, [r12, #148]!
80// DISASM: <$d>:
81// DISASM-NEXT:    2025c:	d4 d4 d4 d4 	.word	0xd4d4d4d4
82
83.syntax unified
84.text
85.type foo STT_GNU_IFUNC
86.globl foo
87foo:
88 bx lr
89
90.type bar STT_GNU_IFUNC
91.globl bar
92bar:
93 bx lr
94
95.globl _start
96_start:
97 bl foo
98 bl bar
99 // Create entries in the .got and .rel.dyn so that we don't just have
100 // IRELATIVE
101 .word bar2(got)
102 .word zed2(got)
103 bl bar2
104 bl zed2
105