brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · cf70149 Raw
67 lines · plain
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 field3## should be zero and sh_size of the section header at index 0 is used4## to store the value. If the section name string table section index is5## greater than or equal to SHN_LORESERVE, then e_shstrndx field6## should have the value of SHN_XINDEX and sh_link of the section header7## at index 0 is used to store the value.8 9# RUN: yaml2obj --docnum=1 %s -o %t110# RUN: llvm-readelf --file-headers -S %t1 | FileCheck %s --check-prefix=GNU111# 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 0x5814 15# RUN: llvm-readobj --file-headers %t1 | FileCheck %s --check-prefix=LLVM116# LLVM1: SectionHeaderCount: 0 (3)17# LLVM1: StringTableSectionIndex: 65535 (2)18 19--- !ELF20FileHeader:21  Class:     ELFCLASS6422  Data:      ELFDATA2LSB23  Type:      ET_REL24  EShNum:    025  EShStrNdx: 0xffff ## SHN_XINDEX26Sections:27  - Type: SHT_NULL28    Link: .shstrtab29    Size: 0x330 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 %t235 36# RUN: llvm-readelf --file-headers --sections %t2 2>&1 | \37# RUN:   FileCheck %s -DFILE=%t2 --check-prefix=GNU238# RUN: llvm-readelf --file-headers --section-details %t2 2>&1 | \39# RUN:   FileCheck %s -DFILE=%t2 --check-prefix=GNU240# GNU2: Number of section headers:         041# 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 empty46 47# RUN: llvm-readobj --file-headers --sections %t2 | \48# RUN:   FileCheck %s --check-prefix=LLVM2 --implicit-check-not="warning:"49# LLVM2:       SectionHeaderCount: 050# LLVM2:       StringTableSectionIndex: 65535 (corrupt: out of range)51# LLVM2-NEXT: }52# LLVM2-NEXT: Sections [53# LLVM2-NEXT: ]54 55--- !ELF56FileHeader:57  Class:     ELFCLASS6458  Data:      ELFDATA2LSB59  Type:      ET_REL60  EShOff:    061  EShNum:    062  EShStrNdx: 0xffff ## SHN_XINDEX63Sections:64  - Type: SHT_NULL65    Link: .shstrtab66    Size: 0x367