[llvm] r306171 - [llvm-readobj] Fix COFF RVA table dumping bug
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 23 15:12:12 PDT 2017
Author: rnk
Date: Fri Jun 23 17:12:11 2017
New Revision: 306171
URL: http://llvm.org/viewvc/llvm-project?rev=306171&view=rev
Log:
[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.
Added:
llvm/trunk/test/tools/llvm-readobj/Inputs/coff-load-config-data-end.exe (with props)
Modified:
llvm/trunk/test/tools/llvm-readobj/coff-load-config.test
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
Added: llvm/trunk/test/tools/llvm-readobj/Inputs/coff-load-config-data-end.exe
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/Inputs/coff-load-config-data-end.exe?rev=306171&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/tools/llvm-readobj/Inputs/coff-load-config-data-end.exe
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: llvm/trunk/test/tools/llvm-readobj/coff-load-config.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/coff-load-config.test?rev=306171&r1=306170&r2=306171&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/coff-load-config.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/coff-load-config.test Fri Jun 23 17:12:11 2017
@@ -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: ]
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=306171&r1=306170&r2=306171&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Fri Jun 23 17:12:11 2017
@@ -763,7 +763,8 @@ void COFFDumper::printRVATable(uint64_t
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;
More information about the llvm-commits
mailing list