[llvm-readobj] Fix COFF RVA table dumping bug

We would return an error in getVaPtr if the RVA table being dumped was
the last data in the .rdata section. Avoid the issue by subtracting one
from the offset and adding it back to get an open interval again.

llvm-svn: 306171
This commit is contained in:
Reid Kleckner 2017-06-23 22:12:11 +00:00
parent 66526dcfd5
commit 06075685d3
3 changed files with 11 additions and 1 deletions

View File

@ -1,6 +1,8 @@
RUN: llvm-readobj -coff-load-config %S/Inputs/coff-load-config-x86.dll | FileCheck %s --check-prefix=X86
RUN: llvm-readobj -coff-load-config %S/Inputs/coff-load-config-x64.dll | FileCheck %s --check-prefix=X64
RUN: llvm-readobj -coff-load-config %S/Inputs/coff-load-config-data-end.exe | FileCheck %s --check-prefix=DATAEND
X86: LoadConfig [
X86: Size: 0x5C
X86: TimeDateStamp: 1970-01-01 00:00:00 (0x0)
@ -85,3 +87,7 @@ X64: 0x180001970
X64: 0x180001B50
X64: 0x180001D90
X64: ]
DATAEND: SEHTable [
DATAEND-NEXT: 0x402006
DATAEND-NEXT: ]

View File

@ -763,7 +763,8 @@ void COFFDumper::printRVATable(uint64_t TableVA, uint64_t Count,
uint64_t EntrySize, PrintExtraCB PrintExtra) {
uintptr_t TableStart, TableEnd;
error(Obj->getVaPtr(TableVA, TableStart));
error(Obj->getVaPtr(TableVA + Count * EntrySize, TableEnd));
error(Obj->getVaPtr(TableVA + Count * EntrySize - 1, TableEnd));
TableEnd++;
for (uintptr_t I = TableStart; I < TableEnd; I += EntrySize) {
uint32_t RVA = *reinterpret_cast<const ulittle32_t *>(I);
raw_ostream &OS = W.startLine();
@ -804,6 +805,9 @@ void COFFDumper::printCOFFLoadConfig() {
template <typename T>
void COFFDumper::printCOFFLoadConfig(const T *Conf, LoadConfigTables &Tables) {
if (!Conf)
return;
ListScope LS(W, "LoadConfig");
char FormattedTime[20] = {};
time_t TDS = Conf->TimeDateStamp;