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