1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Report errors an invalid virtual addresses.

llvm-svn: 242676
This commit is contained in:
Rafael Espindola 2015-07-20 14:45:03 +00:00
parent 84ebc62561
commit 3323a6b994
3 changed files with 12 additions and 2 deletions

View File

@ -738,9 +738,13 @@ template <class ELFT> void ELFFile<ELFT>::scanDynamicTable() {
const Elf_Phdr **I = std::upper_bound(
LoadSegments.begin(), LoadSegments.end(), VAddr, compareAddr<ELFT>);
if (I == LoadSegments.begin())
return nullptr;
report_fatal_error("Virtual address is not in any segment");
--I;
return this->base() + (*I)->p_offset + (VAddr - (*I)->p_vaddr);
const Elf_Phdr &Phdr = **I;
uint64_t Delta = VAddr - Phdr.p_vaddr;
if (Delta >= Phdr.p_filesz)
report_fatal_error("Virtual address is not in any segment");
return this->base() + Phdr.p_offset + Delta;
};
for (Elf_Dyn_Iter DynI = dynamic_table_begin(), DynE = dynamic_table_end();

Binary file not shown.

View File

@ -37,3 +37,9 @@ RUN: %p/Inputs/corrupt-invalid-phentsize.elf.x86-64 2>&1 | \
RUN: FileCheck --check-prefix=PHENTSIZE %s
PHENTSIZE: Invalid program header size
RUN: not llvm-readobj -dynamic-table \
RUN: %p/Inputs/corrupt-invalid-virtual-addr.elf.x86-64 2>&1 | \
RUN: FileCheck --check-prefix=VIRTADDR %s
VIRTADDR: Virtual address is not in any segment