1 ## Check llvm-readelf is able to dump the content of hash sections correctly.
3 ## Check the output when both .hash and .gnu.hash sections are present.
5 # RUN: yaml2obj --docnum=1 %s -o %t1-32.so
6 # RUN: llvm-readelf --hash-symbols %t1-32.so \
7 # RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix HASH-32
9 # HASH-32: Symbol table of .hash for image:
10 # HASH-32-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name
11 # HASH-32-NEXT: 1 0: 00000000 0 NOTYPE GLOBAL DEFAULT UND ccc
12 # HASH-32-NEXT: 5 0: 00001001 0 NOTYPE WEAK DEFAULT 1 bbb
13 # HASH-32-NEXT: 3 0: 00000001 0 NOTYPE GLOBAL DEFAULT ABS ddd
14 # HASH-32-NEXT: 2 0: 00001000 0 NOTYPE GLOBAL DEFAULT 1 aaa
15 # HASH-32-NEXT: 4 0: 00000000 0 NOTYPE GLOBAL DEFAULT 2 eee
17 # HASH-32: Symbol table of .gnu.hash for image:
18 # HASH-32-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name
19 # HASH-32-NEXT: 2 1: 00001000 0 NOTYPE GLOBAL DEFAULT 1 aaa
20 # HASH-32-NEXT: 3 1: 00000001 0 NOTYPE GLOBAL DEFAULT ABS ddd
21 # HASH-32-NEXT: 4 2: 00000000 0 NOTYPE GLOBAL DEFAULT 2 eee
22 # HASH-32-NEXT: 5 2: 00001001 0 NOTYPE WEAK DEFAULT 1 bbb
32 ## The contents of .hash and .gnu.hash were generated by a linker.
37 Content: '0300000006000000010000000000000000000000000000000500000004000000020000000000000003000000'
42 Content: 0300000002000000010000000500000048991200000000000200000004000000685C880B9169880BF46D880BCB60880B
48 ## PT_LOAD's p_vaddr is 0x0. PT_LOAD's p_offset = 0x1bc. DT_HASH value is 0x0.
49 ## llvm-readelf will read .hash content from p_offset + (p_vaddr - DT_HASH value) = 0x1bc.
50 ## This matches the file offset of the .hash section.
52 Value: 0x0000000000000000
54 ## PT_LOAD's p_vaddr is 0x0. PT_LOAD's p_offset = 0x1bc. DT_GNU_HASH value is 0x2c (size of .hash = 0x2c).
55 ## llvm-readelf will read .gnu.hash content from p_offset + (p_vaddr - DT_GNU_HASH value) = 0x1e8.
56 ## This matches the file offset of the .gnu.hash section.
57 Value: 0x000000000000002C
59 Value: 0x0000000000000000
66 Value: 0x0000000000001000
70 Value: 0x0000000000000001
77 Value: 0x0000000000001001
86 # RUN: yaml2obj --docnum=2 %s -o %t1-64.so
87 # RUN: llvm-readelf --hash-symbols %t1-64.so | FileCheck %s --check-prefix HASH-64
89 # HASH-64: Symbol table of .hash for image:
90 # HASH-64-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name
91 # HASH-64-NEXT: 1 0: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND ccc
92 # HASH-64-NEXT: 5 0: 0000000000001001 0 NOTYPE WEAK DEFAULT 1 bbb
93 # HASH-64-NEXT: 3 0: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS ddd
94 # HASH-64-NEXT: 2 0: 0000000000001000 0 NOTYPE GLOBAL DEFAULT 1 aaa
95 # HASH-64-NEXT: 4 0: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 2 eee
97 # HASH-64-NEXT: Symbol table of .gnu.hash for image:
98 # HASH-64-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name
99 # HASH-64-NEXT: 2 1: 0000000000001000 0 NOTYPE GLOBAL DEFAULT 1 aaa
100 # HASH-64-NEXT: 3 1: 0000000000000001 0 NOTYPE GLOBAL DEFAULT ABS ddd
101 # HASH-64-NEXT: 4 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 2 eee
102 # HASH-64-NEXT: 5 2: 0000000000001001 0 NOTYPE WEAK DEFAULT 1 bbb
112 ## The contents of .hash and .gnu.hash were generated by a linker.
117 Content: '0300000006000000010000000000000000000000000000000500000004000000020000000000000003000000'
122 Content: 030000000200000001000000060000000808020040019200000000000200000004000000685C880B9169880BF46D880BCB60880B
129 ## PT_LOAD's p_vaddr is 0x0. PT_LOAD's p_offset = 0x2b8. DT_HASH value is 0x0.
130 ## llvm-readelf will read .hash content from p_offset + (p_vaddr - DT_HASH value) = 0x2b8.
131 ## This matches the file offset of the .hash section.
132 Value: 0x0000000000000000
134 ## PT_LOAD's p_vaddr is 0x0. PT_LOAD's p_offset = 0x2b8. DT_GNU_HASH value is 0x2c (size of .hash = 0x2c).
135 ## llvm-readelf will read .gnu.hash content from p_offset + (p_vaddr - DT_GNU_HASH value) = 0x2e4.
136 ## This matches the file offset of the .gnu.hash section.
137 Value: 0x000000000000002c
139 Value: 0x0000000000000000
146 Value: 0x0000000000001000
150 Value: 0x0000000000000001
157 Value: 0x0000000000001001
160 Flags: [ PF_R, PF_X ]
166 ## Check the output when only .hash section is present.
168 # RUN: yaml2obj --docnum=3 %s -o %t2-32.so
169 # RUN: llvm-readelf --hash-symbols %t2-32.so \
170 # RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix ONLY-HASH-32
172 # ONLY-HASH-32: Symbol table of .hash for image:
173 # ONLY-HASH-32-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name
174 # ONLY-HASH-32-NEXT: 1 0: 00000000 0 NOTYPE GLOBAL DEFAULT UND ccc
175 # ONLY-HASH-32-NEXT: 5 0: 00001001 0 NOTYPE WEAK DEFAULT 1 bbb
176 # ONLY-HASH-32-NEXT: 3 0: 00000001 0 NOTYPE GLOBAL DEFAULT ABS ddd
177 # ONLY-HASH-32-NEXT: 2 0: 00001000 0 NOTYPE GLOBAL DEFAULT 1 aaa
178 # ONLY-HASH-32-NEXT: 4 0: 00000000 0 NOTYPE GLOBAL DEFAULT 2 eee
179 # ONLY-HASH-32-NOT: {{.}}
188 ## The contents of .hash was generated by a linker.
193 Content: '0300000006000000010000000000000000000000000000000500000004000000020000000000000003000000'
200 Value: 0x0000000000000000
202 Value: 0x0000000000000000
209 Value: 0x0000000000001000
213 Value: 0x0000000000000001
220 Value: 0x0000000000001001
223 Flags: [ PF_R, PF_X ]
228 ## Check the output when only .gnu.hash section is present.
230 # RUN: yaml2obj --docnum=4 %s -o %t3-32.so
231 # RUN: llvm-readelf --hash-symbols %t3-32.so \
232 # RUN: | FileCheck %s --strict-whitespace --match-full-lines --check-prefix ONLY-GNUHASH-32
234 # ONLY-GNUHASH-32: Symbol table of .gnu.hash for image:
235 # ONLY-GNUHASH-32-NEXT: Num Buc: Value Size Type Bind Vis Ndx Name
236 # ONLY-GNUHASH-32-NEXT: 2 1: 00001000 0 NOTYPE GLOBAL DEFAULT 2 aaa
237 # ONLY-GNUHASH-32-NEXT: 3 1: 00000001 0 NOTYPE GLOBAL DEFAULT ABS ddd
238 # ONLY-GNUHASH-32-NEXT: 4 2: 00000000 0 NOTYPE GLOBAL DEFAULT 1 eee
239 # ONLY-GNUHASH-32-NEXT: 5 2: 00001001 0 NOTYPE WEAK DEFAULT 2 bbb
240 # ONLY-GNUHASH-32-NOT: {{.}}
249 ## The contents of .gnu.hash was generated by a linker.
254 Content: 0300000002000000010000000500000048991200000000000200000004000000685C880B9169880BF46D880BCB60880B
261 Value: 0x0000000000000000
263 Value: 0x0000000000000000
270 Value: 0x0000000000001000
274 Value: 0x0000000000000001
281 Value: 0x0000000000001001
284 Flags: [ PF_R, PF_X ]
289 ## Show that if there are no hash sections, we do not print anything.
290 # RUN: yaml2obj --docnum=5 %s -o %t4.so
291 # RUN: llvm-readelf --hash-symbols %t4.so \
292 # RUN: | FileCheck %s --check-prefix NO-HASH --allow-empty
296 ## Sanity check that we can still find the dynamic symbols (i.e. the above test
297 ## doesn't pass due to a mistake in the dynamic section).
298 # RUN: llvm-readelf --dyn-symbols %t4.so | FileCheck %s --check-prefix DYNSYMS
300 # DYNSYMS: Symbol table '.dynsym' contains 2 entries:
324 Address: 0x0000000000001000
326 AddressAlign: 0x0000000000001000
327 EntSize: 0x0000000000000010
330 Value: 0x0000000000000000
332 Value: 0x0000000000000009
334 Value: 0x0000000000000100
336 Value: 0x0000000000000018
338 Value: 0x0000000000000000
341 Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
350 Flags: [ PF_R, PF_X ]