diff options
| author | George Rimar <grimar@accesssoftek.com> | 2018-07-18 08:19:58 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2018-07-18 08:19:58 +0000 |
| commit | 6fdac3b23ad9229c953a0cede9c01af6c5605792 (patch) | |
| tree | 41b1c8d67ca734736de9796e46849d5eba2157c4 /llvm/test/tools | |
| parent | ad50ae82ad4dafefdaf0779258bf164d5687e984 (diff) | |
| download | bcm5719-llvm-6fdac3b23ad9229c953a0cede9c01af6c5605792.tar.gz bcm5719-llvm-6fdac3b23ad9229c953a0cede9c01af6c5605792.zip | |
[llvm-readobj] - Teach tool to dump objects with >= SHN_LORESERVE of sections.
http://www.sco.com/developers/gabi/2003-12-17/ch4.eheader.html
says that e_shnum and/or e_shstrndx may have special values if
"the number of sections is greater than or equal to SHN_LORESERVE" or
"the section name string table section index is greater than or equal to SHN_LORESERVE (0xff00)"
Previously llvm-readobj was unable to dump such files, patch changes that.
I had to add a precompiled test case because it does not seem possible to
prepare a test using yaml2obj or llvm-mc (not clear how to make .shstrtab
to have index >= SHN_LORESERVE).
Differential revision: https://reviews.llvm.org/D49369
llvm-svn: 337360
Diffstat (limited to 'llvm/test/tools')
| -rw-r--r-- | llvm/test/tools/llvm-readobj/Inputs/many-sections-stripped.elf-x86_64 | bin | 0 -> 504 bytes | |||
| -rw-r--r-- | llvm/test/tools/llvm-readobj/Inputs/many-sections.elf-x86_64 | bin | 0 -> 504 bytes | |||
| -rw-r--r-- | llvm/test/tools/llvm-readobj/many-sections.s | 36 |
3 files changed, 36 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-readobj/Inputs/many-sections-stripped.elf-x86_64 b/llvm/test/tools/llvm-readobj/Inputs/many-sections-stripped.elf-x86_64 Binary files differnew file mode 100644 index 00000000000..a589dc5d6a9 --- /dev/null +++ b/llvm/test/tools/llvm-readobj/Inputs/many-sections-stripped.elf-x86_64 diff --git a/llvm/test/tools/llvm-readobj/Inputs/many-sections.elf-x86_64 b/llvm/test/tools/llvm-readobj/Inputs/many-sections.elf-x86_64 Binary files differnew file mode 100644 index 00000000000..1abb98a01b8 --- /dev/null +++ b/llvm/test/tools/llvm-readobj/Inputs/many-sections.elf-x86_64 diff --git a/llvm/test/tools/llvm-readobj/many-sections.s b/llvm/test/tools/llvm-readobj/many-sections.s new file mode 100644 index 00000000000..383df266139 --- /dev/null +++ b/llvm/test/tools/llvm-readobj/many-sections.s @@ -0,0 +1,36 @@ +## many-sections.elf-x86_64 is a file that was generated to simulate +## an object with more than ~65k sections. When an ELF object +## has SHN_LORESERVE (0xff00) or more sections, its e_shnum field +## should be zero and sh_size of the section header at index 0 is used +## to store the value. If the section name string table section index is +## greater than or equal to SHN_LORESERVE, then e_shstrndx field +## should have the value of SHN_XINDEX and sh_link of the section header +## at index 0 is used to store the value. +## +## many-sections.elf-x86_64 has few sections to save disk +## space, but its e_shnum, e_shstrndx, sh_size and sh_link fields are set +## according to the above description, so that we can test the dumper. + +# RUN: llvm-readobj -file-headers -elf-output-style GNU \ +# RUN: %p/Inputs/many-sections.elf-x86_64 | FileCheck %s --check-prefix=GNU1 +# GNU1: Number of section headers: 0 (5) +# GNU1: Section header string table index: 65535 (3) + +# RUN: llvm-readobj -file-headers -elf-output-style LLVM \ +# RUN: %p/Inputs/many-sections.elf-x86_64 | FileCheck %s --check-prefix=LLVM1 +# LLVM1: SectionHeaderCount: 0 (5) +# LLVM1: StringTableSectionIndex: 65535 (3) + +## many-sections-stripped.elf-x86_64 is many-sections.elf-x86_64 with +## e_shoff field set to zero, but not e_shstrndx, to show that +## this corrupt case is handled correctly. + +# RUN: llvm-readobj -file-headers -elf-output-style GNU \ +# RUN: %p/Inputs/many-sections-stripped.elf-x86_64 | FileCheck %s --check-prefix=GNU2 +# GNU2: Number of section headers: 0 +# GNU2: Section header string table index: 65535 (corrupt: out of range) + +# RUN: llvm-readobj -file-headers -elf-output-style LLVM \ +# RUN: %p/Inputs/many-sections-stripped.elf-x86_64 | FileCheck %s --check-prefix=LLVM2 +# LLVM2: SectionHeaderCount: 0 +# LLVM2: StringTableSectionIndex: 65535 (corrupt: out of range) |

