1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
## Check how obj2yaml produces SHT_HASH section descriptions.
## Check that obj2yaml uses "Bucket" and "Chain" tags to describe
## a SHT_HASH section when it has content of a correct size.
## I.e. data size == 4 * (2 + nbucket + nchain).
# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=CHAIN-BUCKET
# CHAIN-BUCKET: - Name: .hash1
# CHAIN-BUCKET-NEXT: Type: SHT_HASH
# CHAIN-BUCKET-NEXT: Bucket: [ 3 ]
# CHAIN-BUCKET-NEXT: Chain: [ 4, 5 ]
# CHAIN-BUCKET: - Name: .hash2
# CHAIN-BUCKET-NEXT: Type: SHT_HASH
# CHAIN-BUCKET-NEXT: Bucket: [ ]
# CHAIN-BUCKET-NEXT: Chain: [ ]
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
## Case 1: A non-empty hash table: nbucket == 1, nchain == 2.
- Name: .hash1
Type: SHT_HASH
Content: '0100000002000000030000000400000005000000'
## Case 2: An empty hash table: nbucket == 0, nchain == 0.
- Name: .hash2
Type: SHT_HASH
Content: '0000000000000000'
## Check that obj2yaml falls back to using the "Content" tag when
## hash sections are broken.
# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=CONTENT
# CONTENT: - Name: .empty_hash
# CONTENT-NEXT: Type: SHT_HASH
# CONTENT-NEXT: Content: ''
# CONTENT-NEXT: - Name: .invalid_header
# CONTENT-NEXT: Type: SHT_HASH
# CONTENT-NEXT: Content: '00'
# CONTENT-NEXT: - Name: .truncated
# CONTENT-NEXT: Type: SHT_HASH
# CONTENT-NEXT: Content: '01000000020000000300000004000000'
# CONTENT-NEXT: - Name: .oversized
# CONTENT-NEXT: Type: SHT_HASH
# CONTENT-NEXT: Content: '0100000002000000030000000400000000'
# CONTENT-NEXT: - Name: .overflow1
# CONTENT-NEXT: Type: SHT_HASH
# CONTENT-NEXT: Content: 01000000FFFFFFFF{{$}}
# CONTENT-NEXT: - Name: .overflow2
# CONTENT-NEXT: Type: SHT_HASH
# CONTENT-NEXT: Content: FFFFFFFF01000000{{$}}
# CONTENT-NEXT: ...
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
## Case 1: section has no data.
- Name: .empty_hash
Type: SHT_HASH
Content: ''
## Case 2: section size is less than 2 * 4.
- Name: .invalid_header
Type: SHT_HASH
Content: '00'
## Case 3: nbucket == 1, nchain == 2.
## Section size is less than (2 * nbucket + nchain) * 4.
- Name: .truncated
Type: SHT_HASH
Content: '01000000020000000300000004000000'
## Case 4: nbucket == 1, nchain == 2.
## Section size is greater than (2 * nbucket + nchain) * 4.
- Name: .oversized
Type: SHT_HASH
Content: '0100000002000000030000000400000000'
## Case 5, 6: NChain/NBucket are incorrect and causing 32-bit
## unsigned overflows of intermediate expressions.
- Name: .overflow1
Type: SHT_HASH
Bucket: [ ]
Chain: [ ]
NBucket: 0x1
NChain: 0xffffffff
- Name: .overflow2
Type: SHT_HASH
Bucket: [ ]
Chain: [ ]
NBucket: 0xffffffff
NChain: 0x1
## Check how we dump the "EntSize" field. When the sh_entsize is 4,
## we don't print it, because it is the default value for the SHT_HASH section.
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=ENT-SIZE
# ENT-SIZE: - Name: .hash.entsize.0
# ENT-SIZE-NEXT: Type: SHT_HASH
# ENT-SIZE-NEXT: EntSize: 0x0
# ENT-SIZE-NEXT: Content: ''
# ENT-SIZE-NEXT: - Name: .hash.entsize.4.default
# ENT-SIZE-NEXT: Type: SHT_HASH
# ENT-SIZE-NEXT: Content: ''
# ENT-SIZE-NEXT: - Name: .hash.entsize.255
# ENT-SIZE-NEXT: Type: SHT_HASH
# ENT-SIZE-NEXT: EntSize: 0xFF
# ENT-SIZE-NEXT: Content: ''
--- !ELF
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_DYN
Sections:
- Name: .hash.entsize.0
Type: SHT_HASH
EntSize: 0
Size: 0
- Name: .hash.entsize.4.default
Type: SHT_HASH
EntSize: 4
Size: 0
- Name: .hash.entsize.255
Type: SHT_HASH
EntSize: 255
Size: 0
|