[llvm] r222852 - Object/COFF: Fix off-by-one error for object having lots of relocations
Rui Ueyama
ruiu at google.com
Wed Nov 26 14:17:25 PST 2014
Author: ruiu
Date: Wed Nov 26 16:17:25 2014
New Revision: 222852
URL: http://llvm.org/viewvc/llvm-project?rev=222852&view=rev
Log:
Object/COFF: Fix off-by-one error for object having lots of relocations
llvm-objdump printed out an error message for this off-by-one error,
but because it always exits with 0 whether or not it found an error,
the test (llvm-objdump/coff-many-relocs.test) succeeded.
I made llvm-objdump exit with EXIT_FAILURE when an error is found.
Modified:
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=222852&r1=222851&r2=222852&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Wed Nov 26 16:17:25 2014
@@ -414,7 +414,8 @@ static uint32_t getNumberOfRelocations(c
if (getObject(FirstReloc, M, reinterpret_cast<const coff_relocation*>(
base + Sec->PointerToRelocations)))
return 0;
- return FirstReloc->VirtualAddress;
+ // -1 to exclude this first relocation entry.
+ return FirstReloc->VirtualAddress - 1;
}
return Sec->NumberOfRelocations;
}
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=222852&r1=222851&r2=222852&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Wed Nov 26 16:17:25 2014
@@ -149,6 +149,7 @@ PrivateHeadersShort("p", cl::desc("Alias
cl::aliasopt(PrivateHeaders));
static StringRef ToolName;
+static int ReturnValue = EXIT_SUCCESS;
bool llvm::error(std::error_code EC) {
if (!EC)
@@ -156,6 +157,7 @@ bool llvm::error(std::error_code EC) {
outs() << ToolName << ": error reading file: " << EC.message() << ".\n";
outs().flush();
+ ReturnValue = EXIT_FAILURE;
return true;
}
@@ -895,5 +897,5 @@ int main(int argc, char **argv) {
std::for_each(InputFilenames.begin(), InputFilenames.end(),
DumpInput);
- return 0;
+ return ReturnValue;
}
More information about the llvm-commits
mailing list