1 ## Check how obj2yaml produces SHT_GNU_HASH section descriptions.
3 ## Check that obj2yaml uses "Header", "BloomFilter", "HashBuckets" and "HashValues"
4 ## tags to describe a SHT_GNU_HASH section when it has content of a correct size.
6 # RUN: yaml2obj --docnum=1 %s -o %t1
7 # RUN: obj2yaml %t1 | FileCheck %s --check-prefix=FIELDS
9 # FIELDS: - Name: .gnu.hash
10 # FIELDS-NEXT: Type: SHT_GNU_HASH
11 # FIELDS-NEXT: Flags: [ SHF_ALLOC ]
12 # FIELDS-NEXT: Header:
13 # FIELDS-NEXT: SymNdx: 0x1
14 # FIELDS-NEXT: Shift2: 0x2
15 # FIELDS-NEXT: BloomFilter: [ 0x3, 0x4 ]
16 # FIELDS-NEXT: HashBuckets: [ 0x5, 0x6, 0x7 ]
17 # FIELDS-NEXT: HashValues: [ 0x8, 0x9, 0xA, 0xB ]
31 BloomFilter: [0x3, 0x4]
32 HashBuckets: [0x5, 0x6, 0x7]
33 HashValues: [0x8, 0x9, 0xA, 0xB]
35 ## Check how we handle broken cases.
37 # RUN: yaml2obj --docnum=2 %s -o %t2
38 # RUN: obj2yaml %t2 | FileCheck %s --check-prefix=INVALID
40 # INVALID: - Name: .gnu.hash.tooshort
41 # INVALID-NEXT: Type: SHT_GNU_HASH
42 # INVALID-NEXT: Flags: [ SHF_ALLOC ]
43 # INVALID-NEXT: Content: 112233445566778899AABBCCDDEEFF
44 # INVALID-NEXT: - Name: .gnu.hash.empty
45 # INVALID-NEXT: Type: SHT_GNU_HASH
46 # INVALID-NEXT: Flags: [ SHF_ALLOC ]
47 # INVALID-NEXT: Address: 0xF
48 # INVALID-NEXT: Header:
49 # INVALID-NEXT: SymNdx: 0x0
50 # INVALID-NEXT: Shift2: 0x0
51 # INVALID-NEXT: BloomFilter: [ ]
52 # INVALID-NEXT: HashBuckets: [ ]
53 # INVALID-NEXT: HashValues: [ ]
54 # INVALID-NEXT: - Name: .gnu.hash.broken.maskwords
55 # INVALID-NEXT: Type: SHT_GNU_HASH
56 # INVALID-NEXT: Content: '00000000000000000100000000000000'
57 # INVALID-NEXT: - Name: .gnu.hash.broken.nbuckets.a
58 # INVALID-NEXT: Type: SHT_GNU_HASH
59 # INVALID-NEXT: Content: '01000000000000000000000000000000'
60 # INVALID-NEXT: - Name: .gnu.hash.broken.nbuckets.b
61 # INVALID-NEXT: Type: SHT_GNU_HASH
62 # INVALID-NEXT: Content: FFFFFFFF000000000100000000000000{{$}}
63 # INVALID-NEXT: - Name: .gnu.hash.hashvalues.ok
64 # INVALID-NEXT: Type: SHT_GNU_HASH
65 # INVALID-NEXT: Header:
66 # INVALID-NEXT: SymNdx: 0x0
67 # INVALID-NEXT: Shift2: 0x0
68 # INVALID-NEXT: BloomFilter: [ ]
69 # INVALID-NEXT: HashBuckets: [ ]
70 # INVALID-NEXT: HashValues: [ 0x0 ]
71 # INVALID-NEXT: - Name: .gnu.hash.hashvalues.fail
72 # INVALID-NEXT: Type: SHT_GNU_HASH
73 # INVALID-NEXT: Content: '000000000000000000000000000000000000000000'
81 ## Case 1: Content is less than 16 bytes.
82 - Name: .gnu.hash.tooshort
85 Content: "112233445566778899AABBCCDDEEFF"
86 ## Case2: Check how we handle a fully empty hash section.
87 ## It is almost technically valid, but uncommon. Modern linkers
88 ## create at least one entry in Bloom filter if they want to disable it.
89 ## Also, the dynamic symbol table has a null entry and having SymNdx = 0
90 ## here is at least strange.
91 - Name: .gnu.hash.empty
102 ## Case 3: MaskWords field is broken: it says that the number of entries
103 ## in the Bloom filter is 1, but the Bloom filter is empty.
104 - Name: .gnu.hash.broken.maskwords
114 ## Case 4(a): NBuckets field is broken, it says that the number of entries
115 ## in the hash buckets is 1, but it is empty.
116 - Name: .gnu.hash.broken.nbuckets.a
126 ## Case 4(b): NBuckets = 0xFFFFFFFF is incorrect. The result will cause 32-bit
127 ## unsigned overflows if we keep intermediate expressions uint32_t.
128 - Name: .gnu.hash.broken.nbuckets.b
138 ## Case 5: Check that we use the various properties to dump the data when it
139 ## has a size that is a multiple of 4, but fallback to dumping the whole section
140 ## using the "Content" property otherwise.
141 - Name: .gnu.hash.hashvalues.ok
143 Content: "0000000000000000000000000000000000000000"
144 - Name: .gnu.hash.hashvalues.fail
146 Content: "000000000000000000000000000000000000000000"