1## Here we simulate an object with more than ~65k sections and check how we dump it. 2## When an ELF object has SHN_LORESERVE (0xff00) or more sections, its e_shnum field 3## should be zero and sh_size of the section header at index 0 is used 4## to store the value. If the section name string table section index is 5## greater than or equal to SHN_LORESERVE, then e_shstrndx field 6## should have the value of SHN_XINDEX and sh_link of the section header 7## at index 0 is used to store the value. 8 9# RUN: yaml2obj --docnum=1 %s -o %t1 10# RUN: llvm-readelf --file-headers -S %t1 | FileCheck %s --check-prefix=GNU1 11# GNU1: Number of section headers: 0 (3) 12# GNU1: Section header string table index: 65535 (2) 13# GNU1: There are 3 section headers, starting at offset 0x58 14 15# RUN: llvm-readobj --file-headers %t1 | FileCheck %s --check-prefix=LLVM1 16# LLVM1: SectionHeaderCount: 0 (3) 17# LLVM1: StringTableSectionIndex: 65535 (2) 18 19--- !ELF 20FileHeader: 21 Class: ELFCLASS64 22 Data: ELFDATA2LSB 23 Type: ET_REL 24 EShNum: 0 25 EShStrNdx: 0xffff ## SHN_XINDEX 26Sections: 27 - Type: SHT_NULL 28 Link: .shstrtab 29 Size: 0x3 30 31## Another case is when e_shoff field set to zero, but not e_shstrndx. 32## We want to show that this corrupt case is handled correctly. 33 34# RUN: yaml2obj --docnum=2 %s -o %t2 35 36# RUN: llvm-readelf --file-headers --sections %t2 2>&1 | \ 37# RUN: FileCheck %s -DFILE=%t2 --check-prefix=GNU2 38# RUN: llvm-readelf --file-headers --section-details %t2 2>&1 | \ 39# RUN: FileCheck %s -DFILE=%t2 --check-prefix=GNU2 40# GNU2: Number of section headers: 0 41# GNU2: Section header string table index: 65535 (corrupt: out of range) 42 43# GNU2-EMPTY: 44# GNU2: There are no sections in this file. 45# GNU2-NEXT: warning: '[[FILE]]': e_shstrndx == SHN_XINDEX, but the section header table is empty 46 47# RUN: llvm-readobj --file-headers --sections %t2 | \ 48# RUN: FileCheck %s --check-prefix=LLVM2 --implicit-check-not="warning:" 49# LLVM2: SectionHeaderCount: 0 50# LLVM2: StringTableSectionIndex: 65535 (corrupt: out of range) 51# LLVM2-NEXT: } 52# LLVM2-NEXT: Sections [ 53# LLVM2-NEXT: ] 54 55--- !ELF 56FileHeader: 57 Class: ELFCLASS64 58 Data: ELFDATA2LSB 59 Type: ET_REL 60 EShOff: 0 61 EShNum: 0 62 EShStrNdx: 0xffff ## SHN_XINDEX 63Sections: 64 - Type: SHT_NULL 65 Link: .shstrtab 66 Size: 0x3 67