47
47
# RAW-GNU1-NEXT: 00000000000f0501
48
48
# RAW-GNU1-NEXT: 000a700550400009
49
49
50
- # RUN: llvm-readelf --relocations %t1 | FileCheck --check-prefix=GNU1 %s
51
- # GNU1: Relocation section '.relr.dyn' at offset 0x40 contains 21 entries:
52
- # GNU1: 0000000000010d60 0000000000000008 R_X86_64_RELATIVE
53
- # GNU1-NEXT: 0000000000010d68 0000000000000008 R_X86_64_RELATIVE
54
- # GNU1-NEXT: 0000000000010da0 0000000000000008 R_X86_64_RELATIVE
55
- # GNU1-NEXT: 0000000000020000 0000000000000008 R_X86_64_RELATIVE
56
- # GNU1-NEXT: 0000000000020040 0000000000000008 R_X86_64_RELATIVE
57
- # GNU1-NEXT: 0000000000020050 0000000000000008 R_X86_64_RELATIVE
58
- # GNU1-NEXT: 0000000000020080 0000000000000008 R_X86_64_RELATIVE
59
- # GNU1-NEXT: 0000000000020088 0000000000000008 R_X86_64_RELATIVE
60
- # GNU1-NEXT: 0000000000020090 0000000000000008 R_X86_64_RELATIVE
61
- # GNU1-NEXT: 0000000000020098 0000000000000008 R_X86_64_RELATIVE
62
- # GNU1-NEXT: 0000000000020210 0000000000000008 R_X86_64_RELATIVE
63
- # GNU1-NEXT: 00000000000202a8 0000000000000008 R_X86_64_RELATIVE
64
- # GNU1-NEXT: 00000000000202d8 0000000000000008 R_X86_64_RELATIVE
65
- # GNU1-NEXT: 00000000000202e8 0000000000000008 R_X86_64_RELATIVE
66
- # GNU1-NEXT: 00000000000202f8 0000000000000008 R_X86_64_RELATIVE
67
- # GNU1-NEXT: 0000000000020308 0000000000000008 R_X86_64_RELATIVE
68
- # GNU1-NEXT: 0000000000020358 0000000000000008 R_X86_64_RELATIVE
69
- # GNU1-NEXT: 0000000000020360 0000000000000008 R_X86_64_RELATIVE
70
- # GNU1-NEXT: 0000000000020368 0000000000000008 R_X86_64_RELATIVE
71
- # GNU1-NEXT: 0000000000020380 0000000000000008 R_X86_64_RELATIVE
72
- # GNU1-NEXT: 0000000000020390 0000000000000008 R_X86_64_RELATIVE
50
+ # RUN: llvm-readelf --relocations %t1 | FileCheck --check-prefix=GNU1 --match-full-lines --strict-whitespace %s
51
+ # GNU1:Relocation section '.relr.dyn' at offset 0x40 contains 21 entries:
52
+ # GNU1-NEXT:Index: Entry Address Symbolic Address
53
+ # GNU1-NEXT:0000: 0000000000010d60 0000000000010d60
54
+ # GNU1-NEXT:0001: 0000000000000103 0000000000010d68
55
+ # GNU1-NEXT: 0000000000010da0 base + 0x30
56
+ # GNU1-NEXT:0002: 0000000000020000 0000000000020000 foo
57
+ # GNU1-NEXT:0003: 00000000000f0501 0000000000020040 foo + 0x40
58
+ # GNU1-NEXT: 0000000000020050 foo + 0x50
59
+ # GNU1-NEXT: 0000000000020080 foo + 0x80
60
+ # GNU1-NEXT: 0000000000020088 foo + 0x88
61
+ # GNU1-NEXT: 0000000000020090 foo + 0x90
62
+ # GNU1-NEXT: 0000000000020098 foo + 0x98
63
+ # GNU1-NEXT:0004: 000a700550400009 0000000000020210 bar + 0x10
64
+ # GNU1-NEXT: 00000000000202a8 bar + 0xa8
65
+ # GNU1-NEXT: 00000000000202d8 bar + 0xd8
66
+ # GNU1-NEXT: 00000000000202e8 bar + 0xe8
67
+ # GNU1-NEXT: 00000000000202f8 bar + 0xf8
68
+ # GNU1-NEXT: 0000000000020308 bar + 0x108
69
+ # GNU1-NEXT: 0000000000020358 bar + 0x158
70
+ # GNU1-NEXT: 0000000000020360 bar + 0x160
71
+ # GNU1-NEXT: 0000000000020368 bar + 0x168
72
+ # GNU1-NEXT: 0000000000020380 bar + 0x180
73
+ # GNU1-NEXT: 0000000000020390 bar + 0x190
74
+ # GNU1-NOT:{{.}}
75
+
76
+ ## The addresses are not symbolized in the absence of .symtab.
77
+ # RUN: llvm-objcopy --strip-all %t1 %t1.stripped
78
+ # RUN: llvm-readelf --relocations %t1.stripped | FileCheck --check-prefix=GNU1S --match-full-lines --strict-whitespace %s
79
+ # GNU1S:Relocation section '.relr.dyn' at offset 0x40 contains 21 entries:
80
+ # GNU1S-NEXT:Index: Entry Address Symbolic Address
81
+ # GNU1S-NEXT:0000: 0000000000010d60 0000000000010d60
82
+ # GNU1S-NEXT:0001: 0000000000000103 0000000000010d68
73
83
74
84
--- !ELF
75
85
FileHeader:
@@ -83,6 +93,18 @@ Sections:
83
93
Flags: [ SHF_ALLOC ]
84
94
Entries: [ 0x0000000000010D60, 0x0000000000000103, 0x0000000000020000,
85
95
0x00000000000F0501, 0x000A700550400009 ]
96
+ Symbols:
97
+ - Name: bar
98
+ Value: 0x20200
99
+ Section: .relr.dyn
100
+ - Name: foo
101
+ Value: 0x20000
102
+ Section: .relr.dyn
103
+ - Name: base
104
+ Value: 0x10d70
105
+ Section: .relr.dyn
106
+ - Name: ignored
107
+ Value: 0x20210
86
108
87
109
# RUN: yaml2obj --docnum=2 %s -o %t2
88
110
# RUN: llvm-readobj --relocations --raw-relr %t2 | \
@@ -124,22 +146,24 @@ Sections:
124
146
# RAW-GNU2-NEXT: 000f0501
125
147
# RAW-GNU2-NEXT: 50400009
126
148
127
- # RUN: llvm-readelf --relocations %t2 | FileCheck --check-prefix=GNU2 %s
128
- # GNU2: Relocation section '.relr.dyn' at offset 0x34 contains 14 entries:
129
- # GNU2: 00010d60 00000008 R_386_RELATIVE
130
- # GNU2-NEXT: 00010d64 00000008 R_386_RELATIVE
131
- # GNU2-NEXT: 00010d80 00000008 R_386_RELATIVE
132
- # GNU2-NEXT: 00020000 00000008 R_386_RELATIVE
133
- # GNU2-NEXT: 00020020 00000008 R_386_RELATIVE
134
- # GNU2-NEXT: 00020028 00000008 R_386_RELATIVE
135
- # GNU2-NEXT: 00020040 00000008 R_386_RELATIVE
136
- # GNU2-NEXT: 00020044 00000008 R_386_RELATIVE
137
- # GNU2-NEXT: 00020048 00000008 R_386_RELATIVE
138
- # GNU2-NEXT: 0002004c 00000008 R_386_RELATIVE
139
- # GNU2-NEXT: 00020088 00000008 R_386_RELATIVE
140
- # GNU2-NEXT: 000200d4 00000008 R_386_RELATIVE
141
- # GNU2-NEXT: 000200ec 00000008 R_386_RELATIVE
142
- # GNU2-NEXT: 000200f4 00000008 R_386_RELATIVE
149
+ # RUN: llvm-readelf --relocations %t2 | FileCheck --check-prefix=GNU2 --match-full-lines --strict-whitespace %s
150
+ # GNU2:Relocation section '.relr.dyn' at offset 0x34 contains 14 entries:
151
+ # GNU2-NEXT:Index: Entry Address Symbolic Address
152
+ # GNU2-NEXT:0000: 00010d60 00010d60 .relr.dyn
153
+ # GNU2-NEXT:0001: 00000103 00010d64 .relr.dyn + 0x4
154
+ # GNU2-NEXT: 00010d80 .relr.dyn + 0x20
155
+ # GNU2-NEXT:0002: 00020000 00020000 .relr.dyn + 0xf2a0
156
+ # GNU2-NEXT:0003: 000f0501 00020020 .relr.dyn + 0xf2c0
157
+ # GNU2-NEXT: 00020028 .relr.dyn + 0xf2c8
158
+ # GNU2-NEXT: 00020040 .relr.dyn + 0xf2e0
159
+ # GNU2-NEXT: 00020044 .relr.dyn + 0xf2e4
160
+ # GNU2-NEXT: 00020048 .relr.dyn + 0xf2e8
161
+ # GNU2-NEXT: 0002004c .relr.dyn + 0xf2ec
162
+ # GNU2-NEXT:0004: 50400009 00020088 .relr.dyn + 0xf328
163
+ # GNU2-NEXT: 000200d4 .relr.dyn + 0xf374
164
+ # GNU2-NEXT: 000200ec .relr.dyn + 0xf38c
165
+ # GNU2-NEXT: 000200f4 .relr.dyn + 0xf394
166
+ # GNU2-NOT:{{.}}
143
167
144
168
--- !ELF
145
169
FileHeader:
@@ -156,6 +180,11 @@ Sections:
156
180
EntSize: [[ENTSIZE=<none>]]
157
181
ShType: [[SHTYPE=<none>]]
158
182
Link: [[LINK=<none>]]
183
+ Symbols:
184
+ - Name: .relr.dyn
185
+ Type: STT_SECTION
186
+ Value: 0x10D60
187
+ Section: .relr.dyn
159
188
160
189
## Check we report a warning when we are unable to dump relocations
161
190
## for a SHT_RELR/SHT_ANDROID_RELR/SHT_AARCH64_AUTH_RELR section.
@@ -175,7 +204,6 @@ Sections:
175
204
176
205
# BROKEN-GNU: warning: '[[FILE]]': unable to get the number of relocations in [[SECNAME]] section with index 1: section [index 1] has invalid sh_entsize: expected 4, but got 1
177
206
# BROKEN-GNU: Relocation section '.relr.dyn' at offset 0x34 contains <?> entries:
178
- # BROKEN-GNU-NEXT: Offset Info Type Sym. Value Symbol's Name
179
207
# BROKEN-GNU-NEXT: warning: '[[FILE]]': unable to read relocations from [[SECNAME]] section with index 1: section [index 1] has invalid sh_entsize: expected 4, but got 1
180
208
181
209
## Case B: check the case when relocations can't be read from an SHT_ANDROID_RELR section.
@@ -218,3 +246,36 @@ Sections:
218
246
# RUN: FileCheck -DFILE=%t2.has.link --check-prefix=RAW-LLVM2 %s
219
247
# RUN: llvm-readelf --relocations --raw-relr %t2.has.link 2>&1 | \
220
248
# RUN: FileCheck -DFILE=%t2.has.link --check-prefix=RAW-GNU2 %s
249
+
250
+ ## .symtab is invalid. Check we report a warning and print entries without symbolization.
251
+ # RUN: yaml2obj --docnum=3 -DENTSIZE=1 %s -o %t3.err1
252
+ # RUN: llvm-readelf -r %t3.err1 2>&1 | FileCheck -DFILE=%t3.err1 --check-prefixes=GNU3,GNU3-ERR1 --match-full-lines %s
253
+ # RUN: yaml2obj --docnum=3 -DLINK=0xff %s -o %t3.err2
254
+ # RUN: llvm-readelf -r %t3.err2 2>&1 | FileCheck -DFILE=%t3.err2 --check-prefixes=GNU3,GNU3-ERR2 --match-full-lines %s
255
+
256
+ # GNU3:Index: Entry Address Symbolic Address
257
+ # GNU3-ERR1-NEXT:{{.*}}warning: '[[FILE]]': unable to read symbols from the SHT_SYMTAB section: section [index 2] has invalid sh_entsize: expected 24, but got 1
258
+ # GNU3-ERR2-NEXT:{{.*}}warning: '[[FILE]]': unable to get the string table for the SHT_SYMTAB section: invalid section index: 255
259
+ # GNU3-NEXT:0000: 0000000000010d60 0000000000010d60
260
+ # GNU3-NEXT:0001: 0000000000000103 0000000000010d68
261
+ # GNU3-NEXT: 0000000000010da0
262
+ # GNU3-NOT:{{.}}
263
+
264
+ --- !ELF
265
+ FileHeader:
266
+ Class: ELFCLASS64
267
+ Data: ELFDATA2LSB
268
+ Type: ET_DYN
269
+ Machine: EM_X86_64
270
+ Sections:
271
+ - Name: .relr.dyn
272
+ Type: SHT_RELR
273
+ Flags: [ SHF_ALLOC ]
274
+ Entries: [ 0x0000000000010D60, 0x0000000000000103 ]
275
+ - Name: .symtab
276
+ Type: SHT_SYMTAB
277
+ Link: [[LINK=.strtab]]
278
+ EntSize: [[ENTSIZE=0x18]]
279
+ Symbols:
280
+ - Name: bar
281
+ Value: 0x10D60
0 commit comments