Skip to content

Commit eaa594f

Browse files
author
Georgii Rymar
committed
[llvm-readobj] - Rewrite gnuhash.test test to stop using precompiled objects.
This rewrites the test to use YAML and removes 4 precompiled object. Differential revision: https://reviews.llvm.org/D73096
1 parent c04b9ba commit eaa594f

File tree

5 files changed

+96
-57
lines changed

5 files changed

+96
-57
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 96 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,102 @@
1-
// Check dumping of the GNU Hash section
2-
// The input was generated using the following:
3-
// $ llvm-mc -filetype=obj -triple=i386-pc-linux -o example-i386.o example.s
4-
// $ llvm-mc -filetype=obj -triple=x86_64-pc-linux -o example-x86_64.o example.s
5-
// $ llvm-mc -filetype=obj -triple=powerpc-pc-linux -o example-ppc.o example.s
6-
// $ llvm-mc -filetype=obj -triple=powerpc64-pc-linux -o example-ppc64.o example.s
7-
// $ ld -shared -m elf_i386 -hash-style=gnu -o gnuhash.so.elf-i386 example-i386.o
8-
// $ ld -shared -m elf_x86_64 -hash-style=gnu -o gnuhash.so.elf-x86_64 example-x86_64.o
9-
// $ ld -shared -m elf32ppc -hash-style=gnu -o gnuhash.so.elf-ppc example-ppc.o
10-
// $ ld -shared -m elf64ppc -hash-style=gnu -o gnuhash.so.elf-ppc64 example-ppc64.o
11-
// $ cat example.s
12-
// .globl foo
13-
// foo:
1+
## Check how the GNU Hash section is dumped with --gnu-hash-table.
142

15-
RUN: llvm-readobj --gnu-hash-table %p/Inputs/gnuhash.so.elf-i386 | FileCheck %s -check-prefix I386
16-
RUN: llvm-readobj --gnu-hash-table %p/Inputs/gnuhash.so.elf-x86_64 | FileCheck %s -check-prefix X86_64
17-
RUN: llvm-readobj --gnu-hash-table %p/Inputs/gnuhash.so.elf-ppc | FileCheck %s -check-prefix PPC
18-
RUN: llvm-readobj --gnu-hash-table %p/Inputs/gnuhash.so.elf-ppc64 | FileCheck %s -check-prefix PPC64
3+
# RUN: yaml2obj --docnum=1 %s -o %t.x64
4+
# RUN: yaml2obj --docnum=2 %s -o %t.x32
195

20-
I386: Arch: i386
21-
I386: GnuHashTable {
22-
I386-NEXT: Num Buckets: 3
23-
I386-NEXT: First Hashed Symbol Index: 1
24-
I386-NEXT: Num Mask Words: 1
25-
I386-NEXT: Shift Count: 5
26-
I386-NEXT: Bloom Filter: [0x39004608]
27-
I386-NEXT: Buckets: [1, 4, 0]
28-
I386-NEXT: Values: [0xB887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9]
29-
I386-NEXT: }
6+
# RUN: llvm-readobj --gnu-hash-table %t.x64 | FileCheck %s
7+
# RUN: llvm-readelf --gnu-hash-table %t.x64 | FileCheck %s
308

31-
X86_64: Arch: x86_64
32-
X86_64: GnuHashTable {
33-
X86_64-NEXT: Num Buckets: 3
34-
X86_64-NEXT: First Hashed Symbol Index: 1
35-
X86_64-NEXT: Num Mask Words: 1
36-
X86_64-NEXT: Shift Count: 6
37-
X86_64-NEXT: Bloom Filter: [0x800000001204288]
38-
X86_64-NEXT: Buckets: [1, 4, 0]
39-
X86_64-NEXT: Values: [0xB887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9]
40-
X86_64-NEXT: }
9+
# RUN: llvm-readobj --gnu-hash-table %t.x32 | FileCheck %s
10+
# RUN: llvm-readelf --gnu-hash-table %t.x32 | FileCheck %s
4111

42-
PPC: Arch: powerpc
43-
PPC: GnuHashTable {
44-
PPC-NEXT: Num Buckets: 3
45-
PPC-NEXT: First Hashed Symbol Index: 1
46-
PPC-NEXT: Num Mask Words: 1
47-
PPC-NEXT: Shift Count: 5
48-
PPC-NEXT: Bloom Filter: [0x3D00460A]
49-
PPC-NEXT: Buckets: [1, 5, 0]
50-
PPC-NEXT: Values: [0xEEBEC3A, 0xB887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9]
51-
PPC-NEXT: }
12+
# CHECK: GnuHashTable {
13+
# CHECK-NEXT: Num Buckets: 3
14+
# CHECK-NEXT: First Hashed Symbol Index: 1
15+
# CHECK-NEXT: Num Mask Words: 2
16+
# CHECK-NEXT: Shift Count: 2
17+
# CHECK-NEXT: Bloom Filter: [0x3, 0x4]
18+
# CHECK-NEXT: Buckets: [5, 6, 7]
19+
# CHECK-NEXT: Values: [0x8, 0x9, 0xA, 0xB]
20+
# CHECK-NEXT: }
5221

53-
PPC64: Arch: powerpc64
54-
PPC64: GnuHashTable {
55-
PPC64-NEXT: Num Buckets: 3
56-
PPC64-NEXT: First Hashed Symbol Index: 1
57-
PPC64-NEXT: Num Mask Words: 1
58-
PPC64-NEXT: Shift Count: 6
59-
PPC64-NEXT: Bloom Filter: [0x800000001204288]
60-
PPC64-NEXT: Buckets: [1, 4, 0]
61-
PPC64-NEXT: Values: [0xB887388, 0xECD54542, 0x7C92E3BB, 0x1C5871D9]
62-
PPC64-NEXT: }
22+
--- !ELF
23+
FileHeader:
24+
Class: ELFCLASS64
25+
Data: ELFDATA2LSB
26+
Type: ET_DYN
27+
Machine: EM_X86_64
28+
Sections:
29+
- Name: .gnu.hash
30+
Type: SHT_GNU_HASH
31+
Flags: [ SHF_ALLOC ]
32+
Header:
33+
SymNdx: 0x1
34+
Shift2: 0x2
35+
BloomFilter: [0x3, 0x4]
36+
HashBuckets: [0x5, 0x6, 0x7]
37+
HashValues: [0x8, 0x9, 0xA, 0xB]
38+
- Name: .dynamic
39+
Type: SHT_DYNAMIC
40+
Flags: [ SHF_ALLOC ]
41+
Link: .dynstr
42+
Entries:
43+
- Tag: DT_GNU_HASH
44+
Value: 0x0
45+
- Tag: DT_NULL
46+
Value: 0x0
47+
DynamicSymbols:
48+
- Name: aaa
49+
Binding: STB_GLOBAL
50+
- Name: bbb
51+
Binding: STB_GLOBAL
52+
- Name: ccc
53+
Binding: STB_GLOBAL
54+
- Name: ddd
55+
Binding: STB_GLOBAL
56+
ProgramHeaders:
57+
- Type: PT_LOAD
58+
Flags: [ PF_R, PF_X ]
59+
Sections:
60+
- Section: .gnu.hash
61+
- Section: .dynamic
6362

63+
--- !ELF
64+
FileHeader:
65+
Class: ELFCLASS32
66+
Data: ELFDATA2LSB
67+
Type: ET_DYN
68+
Machine: EM_386
69+
Sections:
70+
- Name: .gnu.hash
71+
Type: SHT_GNU_HASH
72+
Flags: [ SHF_ALLOC ]
73+
Header:
74+
SymNdx: 0x1
75+
Shift2: 0x2
76+
BloomFilter: [0x3, 0x4]
77+
HashBuckets: [0x5, 0x6, 0x7]
78+
HashValues: [0x8, 0x9, 0xA, 0xB]
79+
- Name: .dynamic
80+
Type: SHT_DYNAMIC
81+
Flags: [ SHF_ALLOC ]
82+
Link: .dynstr
83+
Entries:
84+
- Tag: DT_GNU_HASH
85+
Value: 0x0
86+
- Tag: DT_NULL
87+
Value: 0x0
88+
DynamicSymbols:
89+
- Name: aaa
90+
Binding: STB_GLOBAL
91+
- Name: bbb
92+
Binding: STB_GLOBAL
93+
- Name: ccc
94+
Binding: STB_GLOBAL
95+
- Name: ddd
96+
Binding: STB_GLOBAL
97+
ProgramHeaders:
98+
- Type: PT_LOAD
99+
Flags: [ PF_R, PF_X ]
100+
Sections:
101+
- Section: .gnu.hash
102+
- Section: .dynamic

0 commit comments

Comments
 (0)