
Summary: getRelocatedValue may compute incorrect value for SHT_RELA-typed relocation entries. // DWARFDataExtractor.cpp uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint32_t *Off, ... // This formula is correct for REL, but may be incorrect for RELA if the value // stored in the location (getUnsigned(Off, Size)) is not zero. return getUnsigned(Off, Size) + Rel->Value; In this patch, we * refactor these visit* functions to include a new parameter `uint64_t A`. Since these visit* functions are no longer used as visitors, rename them to resolve*. + REL: A is used as the addend. A is the value stored in the location where the relocation applies: getUnsigned(Off, Size) + RELA: The addend encoded in RelocationRef is used, e.g. getELFAddend(R) * and add another set of supports* functions to check if a given relocation type is handled. DWARFObjInMemory uses them to fail early. Reviewers: echristo, dblaikie Reviewed By: echristo Subscribers: mgorny, aprantl, aheejin, fedor.sergeev, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57939 llvm-svn: 356729
88 lines
3.8 KiB
Plaintext
88 lines
3.8 KiB
Plaintext
RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-type.elf 2>&1 | FileCheck %s
|
|
RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-size.elf 2>&1 | FileCheck %s
|
|
RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-zero-size.elf 2>&1 | FileCheck %s
|
|
CHECK: Invalid data was encountered while parsing the file
|
|
|
|
RUN: not llvm-dwarfdump -debug-line %p/Inputs/invalid-bad-rel-type.elf 2>&1 | FileCheck --check-prefix=RELA %s
|
|
RELA: Section is not SHT_RELA
|
|
|
|
RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-non-null.elf 2>&1 | FileCheck --check-prefix=NON-NULL %s
|
|
NON-NULL: Invalid data was encountered while parsing the file
|
|
|
|
Test the sh_entsize are invalid
|
|
RUN: llvm-readobj -s %p/Inputs/invalid-sh_entsize.elf | FileCheck --check-prefix=SECTION %s
|
|
|
|
SECTION: Name: .dynsym
|
|
SECTION-NEXT: Type: SHT_DYNSYM
|
|
SECTION-NEXT: Flags [
|
|
SECTION-NEXT: SHF_ALLOC
|
|
SECTION-NEXT: ]
|
|
SECTION-NEXT: Address:
|
|
SECTION-NEXT: Offset:
|
|
SECTION-NEXT: Size:
|
|
SECTION-NEXT: Link:
|
|
SECTION-NEXT: Info:
|
|
SECTION-NEXT: AddressAlignment:
|
|
SECTION-NEXT: EntrySize: 32
|
|
|
|
SECTION: Name: .symtab
|
|
SECTION-NEXT: Type: SHT_SYMTAB
|
|
SECTION-NEXT: Flags [
|
|
SECTION-NEXT: ]
|
|
SECTION-NEXT: Address:
|
|
SECTION-NEXT: Offset:
|
|
SECTION-NEXT: Size:
|
|
SECTION-NEXT: Link:
|
|
SECTION-NEXT: Info:
|
|
SECTION-NEXT: AddressAlignment:
|
|
SECTION-NEXT: EntrySize: 32
|
|
|
|
RUN: not llvm-readobj -t %p/Inputs/invalid-sh_entsize.elf 2>&1 | FileCheck --check-prefix=INVALID-SYM-SIZE %s
|
|
INVALID-SYM-SIZE: invalid sh_entsize
|
|
|
|
RUN: not llvm-readobj --dyn-symbols %p/Inputs/invalid-sh_entsize.elf 2>&1 | FileCheck --check-prefix=INVALID-DYNSYM-SIZE %s
|
|
INVALID-DYNSYM-SIZE: Invalid entity size
|
|
|
|
RUN: not llvm-readobj -t %p/Inputs/invalid-section-index.elf 2>&1 | FileCheck --check-prefix=INVALID-SECTION-INDEX %s
|
|
INVALID-SECTION-INDEX: invalid section index
|
|
|
|
RUN: not llvm-readobj -s %p/Inputs/invalid-section-size.elf 2>&1 | FileCheck --check-prefix=INVALID-SECTION-SIZE %s
|
|
INVALID-SECTION-SIZE: invalid section header entry size (e_shentsize) in ELF header
|
|
|
|
|
|
RUN: not llvm-readobj -t %p/Inputs/invalid-symbol-table-size.elf 2>&1 | FileCheck --check-prefix=INVALID-SYMTAB-SIZE %s
|
|
INVALID-SYMTAB-SIZE: size is not a multiple of sh_entsize
|
|
|
|
|
|
RUN: not llvm-readobj -t %p/Inputs/invalid-xindex-size.elf 2>&1 | FileCheck --check-prefix=INVALID-XINDEX-SIZE %s
|
|
INVALID-XINDEX-SIZE: invalid section contents size
|
|
|
|
RUN: not llvm-readobj -t %p/Inputs/invalid-e_shnum.elf 2>&1 | FileCheck --check-prefix=INVALID-SH-NUM %s
|
|
INVALID-SH-NUM: invalid e_phentsize
|
|
|
|
RUN: not llvm-readobj -t %p/Inputs/invalid-ext-symtab-index.elf-x86-64 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-EXT-SYMTAB-INDEX %s
|
|
INVALID-EXT-SYMTAB-INDEX: index past the end of the symbol table
|
|
|
|
RUN: not llvm-readobj -r %p/Inputs/invalid-relocation-sec-sh_offset.elf-i386 2>&1 | \
|
|
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 section offset
|
|
|
|
RUN: not llvm-readobj -t %p/Inputs/invalid-section-size2.elf 2>&1 | \
|
|
RUN: FileCheck --check-prefix=INVALID-SECTION-SIZE2 %s
|
|
INVALID-SECTION-SIZE2: invalid section offset
|
|
|
|
RUN: not llvm-readobj -t %p/Inputs/invalid-sections-num.elf 2>&1 | FileCheck --check-prefix=INVALID-SECTION-NUM %s
|
|
INVALID-SECTION-NUM: section table goes past the end of file
|
|
|
|
RUN: not llvm-readobj -r %p/Inputs/invalid-rel-sym.elf 2>&1 | FileCheck --check-prefix=INVALID-REL-SYM %s
|
|
INVALID-REL-SYM: invalid section offset
|
|
|
|
RUN: not llvm-readobj -r %p/Inputs/invalid-buffer.elf 2>&1 | FileCheck --check-prefix=INVALID-BUFFER %s
|
|
INVALID-BUFFER: Invalid buffer
|
|
|
|
RUN: not llvm-readobj %p/Inputs/invalid-coff-header-too-small 2>&1 | FileCheck --check-prefix=COFF-HEADER %s
|
|
COFF-HEADER: The file was not recognized as a valid object file
|