1 ## This is a test to test how SHT_RELR sections are dumped.
3 # RUN: yaml2obj --docnum=1 %s -o %t1
4 # RUN: llvm-readobj --relocations --raw-relr %t1 \
5 # RUN: | FileCheck --check-prefix=RAW-LLVM1 %s
6 # RAW-LLVM1: Section (1) .relr.dyn {
7 # RAW-LLVM1-NEXT: 0x10D60
8 # RAW-LLVM1-NEXT: 0x103
9 # RAW-LLVM1-NEXT: 0x20000
10 # RAW-LLVM1-NEXT: 0xF0501
11 # RAW-LLVM1-NEXT: 0xA700550400009
14 # RUN: llvm-readobj --relocations %t1 | \
15 # RUN: FileCheck --match-full-lines --check-prefix=LLVM1 %s
17 # LLVM1: Section (1) .relr.dyn {
18 # LLVM1-NEXT: 0x10D60 R_X86_64_RELATIVE -
19 # LLVM1-NEXT: 0x10D68 R_X86_64_RELATIVE -
20 # LLVM1-NEXT: 0x10DA0 R_X86_64_RELATIVE -
21 # LLVM1-NEXT: 0x20000 R_X86_64_RELATIVE -
22 # LLVM1-NEXT: 0x20040 R_X86_64_RELATIVE -
23 # LLVM1-NEXT: 0x20050 R_X86_64_RELATIVE -
24 # LLVM1-NEXT: 0x20080 R_X86_64_RELATIVE -
25 # LLVM1-NEXT: 0x20088 R_X86_64_RELATIVE -
26 # LLVM1-NEXT: 0x20090 R_X86_64_RELATIVE -
27 # LLVM1-NEXT: 0x20098 R_X86_64_RELATIVE -
28 # LLVM1-NEXT: 0x20210 R_X86_64_RELATIVE -
29 # LLVM1-NEXT: 0x202A8 R_X86_64_RELATIVE -
30 # LLVM1-NEXT: 0x202D8 R_X86_64_RELATIVE -
31 # LLVM1-NEXT: 0x202E8 R_X86_64_RELATIVE -
32 # LLVM1-NEXT: 0x202F8 R_X86_64_RELATIVE -
33 # LLVM1-NEXT: 0x20308 R_X86_64_RELATIVE -
34 # LLVM1-NEXT: 0x20358 R_X86_64_RELATIVE -
35 # LLVM1-NEXT: 0x20360 R_X86_64_RELATIVE -
36 # LLVM1-NEXT: 0x20368 R_X86_64_RELATIVE -
37 # LLVM1-NEXT: 0x20380 R_X86_64_RELATIVE -
38 # LLVM1-NEXT: 0x20390 R_X86_64_RELATIVE -
41 # RUN: llvm-readelf --relocations --raw-relr %t1 \
42 # RUN: | FileCheck --check-prefix=RAW-GNU1 %s
43 # RAW-GNU1: Relocation section '.relr.dyn' at offset 0x40 contains 5 entries:
44 # RAW-GNU1: 0000000000010d60
45 # RAW-GNU1-NEXT: 0000000000000103
46 # RAW-GNU1-NEXT: 0000000000020000
47 # RAW-GNU1-NEXT: 00000000000f0501
48 # RAW-GNU1-NEXT: 000a700550400009
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
84 Entries: [ 0x0000000000010D60, 0x0000000000000103, 0x0000000000020000,
85 0x00000000000F0501, 0x000A700550400009 ]
87 # RUN: yaml2obj --docnum=2 %s -o %t2
88 # RUN: llvm-readobj --relocations --raw-relr %t2 | \
89 # RUN: FileCheck --check-prefix=RAW-LLVM2 %s
90 # RAW-LLVM2: Section (1) .relr.dyn {
91 # RAW-LLVM2-NEXT: 0x10D60
92 # RAW-LLVM2-NEXT: 0x103
93 # RAW-LLVM2-NEXT: 0x20000
94 # RAW-LLVM2-NEXT: 0xF0501
95 # RAW-LLVM2-NEXT: 0x50400009
98 # RUN: llvm-readobj --relocations %t2 | \
99 # RUN: FileCheck --match-full-lines --check-prefix=LLVM2 %s
101 # LLVM2: Section (1) .relr.dyn {
102 # LLVM2-NEXT: 0x10D60 R_386_RELATIVE -
103 # LLVM2-NEXT: 0x10D64 R_386_RELATIVE -
104 # LLVM2-NEXT: 0x10D80 R_386_RELATIVE -
105 # LLVM2-NEXT: 0x20000 R_386_RELATIVE -
106 # LLVM2-NEXT: 0x20020 R_386_RELATIVE -
107 # LLVM2-NEXT: 0x20028 R_386_RELATIVE -
108 # LLVM2-NEXT: 0x20040 R_386_RELATIVE -
109 # LLVM2-NEXT: 0x20044 R_386_RELATIVE -
110 # LLVM2-NEXT: 0x20048 R_386_RELATIVE -
111 # LLVM2-NEXT: 0x2004C R_386_RELATIVE -
112 # LLVM2-NEXT: 0x20088 R_386_RELATIVE -
113 # LLVM2-NEXT: 0x200D4 R_386_RELATIVE -
114 # LLVM2-NEXT: 0x200EC R_386_RELATIVE -
115 # LLVM2-NEXT: 0x200F4 R_386_RELATIVE -
118 # RUN: llvm-readelf --relocations --raw-relr %t2 | \
119 # RUN: FileCheck --check-prefix=RAW-GNU2 %s
120 # RAW-GNU2: Relocation section '.relr.dyn' at offset 0x34 contains 5 entries:
122 # RAW-GNU2-NEXT: 00000103
123 # RAW-GNU2-NEXT: 00020000
124 # RAW-GNU2-NEXT: 000f0501
125 # RAW-GNU2-NEXT: 50400009
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
154 Entries: [ 0x00010D60, 0x00000103, 0x00020000,
155 0x000F0501, 0x50400009 ]
156 EntSize: [[ENTSIZE=<none>]]
157 ShType: [[SHTYPE=<none>]]
158 Link: [[LINK=<none>]]
160 ## Check we report a warning when we are unable to dump relocations
161 ## for a SHT_RELR/SHT_ANDROID_RELR section.
163 ## Case A: check the case when relocations can't be read from an SHT_RELR section.
164 # RUN: yaml2obj --docnum=2 -DENTSIZE=1 %s -o %t2.broken
165 # RUN: llvm-readobj --relocations %t2.broken 2>&1 | \
166 # RUN: FileCheck -DFILE=%t2.broken --check-prefix=BROKEN-LLVM %s -DSECNAME=SHT_RELR
167 # RUN: llvm-readelf --relocations %t2.broken 2>&1 | \
168 # RUN: FileCheck -DFILE=%t2.broken --check-prefix=BROKEN-GNU %s -DSECNAME=SHT_RELR
170 # BROKEN-LLVM: Relocations [
171 # BROKEN-LLVM-NEXT: Section (1) .relr.dyn {
172 # BROKEN-LLVM-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
173 # BROKEN-LLVM-NEXT: }
174 # BROKEN-LLVM-NEXT: ]
176 # 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 # BROKEN-GNU: Relocation section '.relr.dyn' at offset 0x34 contains <?> entries:
178 # BROKEN-GNU-NEXT: Offset Info Type Sym. Value Symbol's Name
179 # 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
181 ## Case B: check the case when relocations can't be read from an SHT_ANDROID_RELR section.
182 ## SHT_ANDROID_RELR = 0x6fffff00.
183 # RUN: yaml2obj --docnum=2 -DENTSIZE=1 -DSHTYPE=0x6fffff00 %s -o %t2.broken.android
184 # RUN: llvm-readobj --relocations %t2.broken.android 2>&1 | \
185 # RUN: FileCheck -DFILE=%t2.broken.android --check-prefix=BROKEN-LLVM %s -DSECNAME=SHT_ANDROID_RELR
186 # RUN: llvm-readelf --relocations %t2.broken.android 2>&1 | \
187 # RUN: FileCheck -DFILE=%t2.broken.android --check-prefix=BROKEN-GNU %s -DSECNAME=SHT_ANDROID_RELR
189 ## Check the behavior when the sh_link field of the SHT_RELR/SHT_ANDROID_RELR section
190 ## is set to an arbitrary value. Normally, it is set to 0, because such sections contains
191 ## only relative relocations and do not have an associated symbol table, like other
192 ## relocation sections.
194 ## Case A: check we do not report warnings when the sh_link field is set to an arbitrary value
195 ## and the --relocations option is requested.
196 # RUN: yaml2obj --docnum=2 -DLINK=0xff %s -o %t2.has.link
197 # RUN: llvm-readobj --relocations %t2.has.link 2>&1 | \
198 # RUN: FileCheck -DFILE=%t2.has.link --check-prefix=LLVM2 %s --implicit-check-not=warning:
199 # RUN: llvm-readelf --relocations %t2.has.link 2>&1 | \
200 # RUN: FileCheck -DFILE=%t2.has.link --check-prefix=GNU2 %s --implicit-check-not=warning:
202 ## Case B: check we do not report warnings when the sh_link field is set to an arbitrary value
203 ## and --relocations and --raw-relr options are requested.
204 # RUN: llvm-readobj --relocations --raw-relr %t2.has.link | \
205 # RUN: FileCheck -DFILE=%t2.has.link --check-prefix=RAW-LLVM2 %s
206 # RUN: llvm-readelf --relocations --raw-relr %t2.has.link 2>&1 | \
207 # RUN: FileCheck -DFILE=%t2.has.link --check-prefix=RAW-GNU2 %s