Skip to content

Commit

Permalink
Reverted r283740 [Object/ELF] - Do not crash on invalid Header->e_sho…
Browse files Browse the repository at this point in the history
…ff value.

Bot does not like it: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/17075

/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/Object/invalid.test:70:32: error: expected string not found in input
INVALID-SEC-ADDRESS-ALIGNMENT: Invalid address alignment of section headers
                               ^
<stdin>:1:1: note: scanning from here
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Object/ELF.h:412:7: runtime error: upcast of misaligned address 0x000002d8b899 for type 'llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::support::endianness::little, true> >', which requires 2 byte alignment
^
<stdin>:1:125: note: possible intended match here
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Object/ELF.h:412:7: runtime error: upcast of misaligned address 0x000002d8b899 for type 'llvm::object::Elf_Shdr_Impl<llvm::object::ELFType<llvm::support::endianness::little, true> >', which requires 2 byte alignment
          

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283858 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
George Rimar committed Oct 11, 2016
1 parent ebc8a28 commit 54bf85d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 6 deletions.
2 changes: 0 additions & 2 deletions include/llvm/Object/ELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,6 @@ const typename ELFFile<ELFT>::Elf_Shdr *ELFFile<ELFT>::section_begin() const {
if (Header->e_shentsize != sizeof(Elf_Shdr))
report_fatal_error(
"Invalid section header entry size (e_shentsize) in ELF header");
if (Header->e_shoff & (AlignOf<Elf_Shdr>::Alignment - 1))
report_fatal_error("Invalid address alignment of section headers");
return reinterpret_cast<const Elf_Shdr *>(base() + Header->e_shoff);
}

Expand Down
Binary file not shown.
4 changes: 0 additions & 4 deletions test/Object/invalid.test
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,3 @@ RUN: FileCheck --check-prefix=INVALID-RELOC-SH-OFFSET %s
RUN: not llvm-readobj -r %p/Inputs/invalid-relocation-sec-sh_offset.elf-x86-64 2>&1 | \
RUN: FileCheck --check-prefix=INVALID-RELOC-SH-OFFSET %s
INVALID-RELOC-SH-OFFSET: Invalid data was encountered while parsing the file

RUN: not llvm-readobj -t %p/Inputs/invalid-sections-address-alignment.x86-64 2>&1 | \
RUN: FileCheck --check-prefix=INVALID-SEC-ADDRESS-ALIGNMENT %s
INVALID-SEC-ADDRESS-ALIGNMENT: Invalid address alignment of section headers

0 comments on commit 54bf85d

Please sign in to comment.