96 lines · yaml
1## Check how obj2yaml dumps SHT_NOTE sections.2 3## We can dump the Name, Desc and Type fields when the note section is valid.4 5# RUN: yaml2obj --docnum=1 %s -o %t16# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=VALID7 8# VALID: - Name: .note.foo9# VALID-NEXT: Type: SHT_NOTE10# VALID-NEXT: Notes:11# VALID-NEXT: - Name: ''12# VALID-NEXT: Desc: ''13# VALID-NEXT: Type: 0x014# VALID-NEXT: - Name: .note.bar15# VALID-NEXT: Type: SHT_NOTE16# VALID-NEXT: Notes:17# VALID-NEXT: - Name: ABC18# VALID-NEXT: Desc: '001122'19# VALID-NEXT: Type: 0xAABBCCDD20 21--- !ELF22FileHeader:23 Class: ELFCLASS6424 Data: ELFDATA2LSB25 Type: ET_DYN26Sections:27 - Name: .note.foo28 Type: SHT_NOTE29 Size: 1230 - Name: .note.bar31 Type: SHT_NOTE32 Notes:33 - Name: ABC34 Desc: '001122'35 Type: 0xAABBCCDD36 37## Check we dump hex digit pairs if the note section is invalid.38 39# RUN: yaml2obj --docnum=2 %s -o %t240# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=INVALID41 42# INVALID: - Name: .note.tooShortNote43# INVALID-NEXT: Type: SHT_NOTE44# INVALID-NEXT: Content: '0000000000000000000000'45# INVALID-NEXT: - Name: .note.tooLongNameSize46# INVALID-NEXT: Type: SHT_NOTE47# INVALID-NEXT: Content: 0100000000000000FF0000000048# INVALID-NEXT: - Name: .note.tooLongDescSize49# INVALID-NEXT: Type: SHT_NOTE50# INVALID-NEXT: Content: 0000000001000000FF0000000051 52--- !ELF53FileHeader:54 Class: ELFCLASS6455 Data: ELFDATA2LSB56 Type: ET_DYN57Sections:58## Content is less than 12 bytes in size.59## (12 is the size of n_namesz, n_descsz and n_type 4-bytes fields that must always present).60 - Name: .note.tooShortNote61 Type: SHT_NOTE62 Size: 1163## We can't dump the Name, Desc and Type fields when the64## content is shorter than the computed size.65##66## Too long name size.67 - Name: .note.tooLongNameSize68 Type: SHT_NOTE69 Content: "0100000000000000ff00000000"70## Too long description size.71 - Name: .note.tooLongDescSize72 Type: SHT_NOTE73 Content: "0000000001000000ff00000000"74 75## Check we do not crash when dumping a description that has bytes76## on its bounds that do not fit into signed byte.77## This is a completely normal case, but we had a crash before.78 79# RUN: yaml2obj --docnum=3 %s -o %t380# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=HEX-DESC81 82# HEX-DESC: Desc: FE0000FE83 84--- !ELF85FileHeader:86 Class: ELFCLASS6487 Data: ELFDATA2MSB88 Type: ET_DYN89Sections:90 - Name: .note.tag91 Type: SHT_NOTE92 Flags: [ SHF_ALLOC ]93 Notes:94 - Desc: 'FE0000FE'95 Type: 096