arm-gnu-ifunc.s
4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// REQUIRES: arm
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
// RUN: ld.lld %t.o -o %t
// RUN: llvm-objdump --triple=armv7a-none-linux-gnueabi -d --no-show-raw-insn %t | FileCheck %s --check-prefix=DISASM
// RUN: llvm-readobj -r --symbols --sections %t | FileCheck %s
.syntax unified
.text
.type foo STT_GNU_IFUNC
.globl foo
foo:
bx lr
.type bar STT_GNU_IFUNC
.globl bar
bar:
bx lr
.globl _start
_start:
bl foo
bl bar
movw r0,:lower16:__rel_iplt_start
movt r0,:upper16:__rel_iplt_start
movw r0,:lower16:__rel_iplt_end
movt r0,:upper16:__rel_iplt_end
// CHECK: Sections [
// CHECK: Section {
// CHECK: Section {
// CHECK: Name: .rel.dyn
// CHECK-NEXT: Type: SHT_REL
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x100F4
// CHECK-NEXT: Offset: 0xF4
// CHECK-NEXT: Size: 16
// CHECK-NEXT: Link:
// CHECK-NEXT: Info: 4
// CHECK: Name: .iplt
// CHECK-NEXT: Type: SHT_PROGBITS
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_EXECINSTR
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x20130
// CHECK-NEXT: Offset: 0x130
// CHECK-NEXT: Size: 32
// CHECK: Index: 4
// CHECK-NEXT: Name: .got
// CHECK-NEXT: Type: SHT_PROGBITS
// CHECK-NEXT: Flags [
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x30150
// CHECK-NEXT: Offset: 0x150
// CHECK-NEXT: Size: 8
// CHECK: Relocations [
// CHECK-NEXT: Section (1) .rel.dyn {
// CHECK-NEXT: 0x30150 R_ARM_IRELATIVE
// CHECK-NEXT: 0x30154 R_ARM_IRELATIVE
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK: Symbol {
// CHECK: Name: __rel_iplt_end
// CHECK-NEXT: Value: 0x10104
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
// CHECK-NEXT: Other [
// CHECK-NEXT: STV_HIDDEN
// CHECK-NEXT: ]
// CHECK-NEXT: Section: .rel.dyn
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: __rel_iplt_start
// CHECK-NEXT: Value: 0x100F4
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
// CHECK-NEXT: Type: None
// CHECK-NEXT: Other [
// CHECK-NEXT: STV_HIDDEN
// CHECK-NEXT: ]
// CHECK-NEXT: Section: .rel.dyn
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: _start
// CHECK-NEXT: Value: 0x2010C
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: None
// CHECK-NEXT: Other:
// CHECK-NEXT: Section: .text
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: bar
// CHECK-NEXT: Value: 0x20108
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: GNU_IFunc
// CHECK-NEXT: Other: 0
// CHECK-NEXT: Section: .text
// CHECK-NEXT: }
// CHECK-NEXT: Symbol {
// CHECK-NEXT: Name: foo
// CHECK-NEXT: Value: 0x20104
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global
// CHECK-NEXT: Type: GNU_IFunc
// CHECK-NEXT: Other: 0
// CHECK-NEXT: Section: .text
// CHECK-NEXT: }
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// DISASM-NEXT: <foo>:
// DISASM-NEXT: 20104: bx lr
// DISASM: <bar>:
// DISASM-NEXT: 20108: bx lr
// DISASM: <_start>:
// DISASM-NEXT: 2010c: bl #28
// DISASM-NEXT: 20110: bl #40
// 1 * 65536 + 244 = 0x100f4 __rel_iplt_start
// DISASM-NEXT: 20114: movw r0, #244
// DISASM-NEXT: 20118: movt r0, #1
// 1 * 65536 + 260 = 0x10104 __rel_iplt_end
// DISASM-NEXT: 2011c: movw r0, #260
// DISASM-NEXT: 20120: movt r0, #1
// DISASM-EMPTY:
// DISASM-NEXT: Disassembly of section .iplt:
// DISASM-EMPTY:
// DISASM-NEXT: <$a>:
// DISASM-NEXT: 20130: add r12, pc, #0, #12
// DISASM-NEXT: 20134: add r12, r12, #16
// DISASM-NEXT: 20138: ldr pc, [r12, #24]!
// DISASM: <$d>:
// DISASM-NEXT: 2013c: d4 d4 d4 d4 .word 0xd4d4d4d4
// DISASM: <$a>:
// DISASM-NEXT: 20140: add r12, pc, #0, #12
// DISASM-NEXT: 20144: add r12, r12, #16
// DISASM-NEXT: 20148: ldr pc, [r12, #12]!
// DISASM: <$d>:
// DISASM-NEXT: 2014c: d4 d4 d4 d4 .word 0xd4d4d4d4