brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 35c7cfd Raw
68 lines · yaml
1## Test cases related to the value of the e_shnum field of the ELF header live here.2 3## Normally an object that does not have sections has e_shnum == 0.4## Also, e_shnum might be 0, when the the number of entries in the section5## header table is larger than or equal to SHN_LORESERVE (0xff00). In this case6## the real number of entries in the section header table is held in the sh_size7## member of the initial entry in the section header table.8 9## In the test case below we have an object that has e_shnum = 0 and the real10## number of sections is written to the sh_size member of the initial entry in11## the section header table. Check that we emit the `EShNum` key properly.12 13# RUN: yaml2obj %s -o %t114# RUN: obj2yaml %t1 | FileCheck %s --check-prefix=PRESERVE15 16# PRESERVE:      --- !ELF17# PRESERVE-NEXT: FileHeader:18# PRESERVE-NEXT:   Class:  ELFCLASS6419# PRESERVE-NEXT:   Data:   ELFDATA2LSB20# PRESERVE-NEXT:   Type:   ET_REL21# PRESERVE-NEXT:   EShNum: 0x022# PRESERVE-NEXT: Sections:23# PRESERVE-NEXT:   - Type: SHT_NULL24# PRESERVE-NEXT:     Size: 0x325# PRESERVE-NEXT: ...26 27--- !ELF28FileHeader:29  Class:  ELFCLASS6430  Data:   ELFDATA2LSB31  Type:   ET_REL32  EShNum: 0x033  EShOff: [[ESHOFF=<none>]]34Sections:35 - Type: SHT_NULL36## 3 sections total: SHT_NULL + 2 implicit sections: .strtab and .shstrtab.37   Size: [[SIZE=0x3]]38 39## In the test case below we have an object with a non-zero section header table40## file offset and an initial entry in the section header table with sh_size of 0.41## Here we check that we are able to dump such objects properly.42 43# RUN: yaml2obj %s -DSIZE=0x0 -o %t244# RUN: obj2yaml %t2 | FileCheck %s --check-prefix=NO-SECTIONS45 46# NO-SECTIONS:      --- !ELF47# NO-SECTIONS-NEXT: FileHeader:48# NO-SECTIONS-NEXT:   Class:  ELFCLASS6449# NO-SECTIONS-NEXT:   Data:   ELFDATA2LSB50# NO-SECTIONS-NEXT:   Type:   ET_REL51# NO-SECTIONS-NEXT:   EShNum: 0x052## Note: yaml2obj will create the SHT_NULL section with sh_size = 0 implicitly.53# NO-SECTIONS-NEXT: ...54 55## In the test case below we have an object without a section header table and e_shnum == 0.56## Document how we dump it.57## FIXME: we should emit the `SectionHeaderTable` key with `NoHeaders=true` for this case.58 59# RUN: yaml2obj %s -DESHOFF=0x0 -o %t360# RUN: obj2yaml %t3 | FileCheck %s --check-prefix=NO-HEADERS61 62# NO-HEADERS:      --- !ELF63# NO-HEADERS-NEXT: FileHeader:64# NO-HEADERS-NEXT:   Class: ELFCLASS6465# NO-HEADERS-NEXT:   Data:  ELFDATA2LSB66# NO-HEADERS-NEXT:   Type:  ET_REL67# NO-HEADERS-NEXT: ...68