[lld] r189572 - [PECOFF] Fix bug that atom size was sometimes wrong.
Rui Ueyama
ruiu at google.com
Thu Aug 29 00:34:58 PDT 2013
Author: ruiu
Date: Thu Aug 29 02:34:58 2013
New Revision: 189572
URL: http://llvm.org/viewvc/llvm-project?rev=189572&view=rev
Log:
[PECOFF] Fix bug that atom size was sometimes wrong.
Because of a bug, the last atom of each section contained a garbage at the
end of its data. In most cases the garbage is harmless but it could have cause
SEGV.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
lld/trunk/test/pecoff/hello.test
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=189572&r1=189571&r2=189572&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Thu Aug 29 02:34:58 2013
@@ -438,7 +438,7 @@ private:
const uint8_t *start = secData.data() + (*si)->Value;
// if this is the last symbol, take up the remaining data.
const uint8_t *end = (si + 1 == se)
- ? start + secData.size()
+ ? secData.data() + secData.size()
: secData.data() + (*(si + 1))->Value;
ArrayRef<uint8_t> data(start, end);
auto *atom = new (_alloc) COFFDefinedAtom(
Modified: lld/trunk/test/pecoff/hello.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/hello.test?rev=189572&r1=189571&r2=189572&view=diff
==============================================================================
--- lld/trunk/test/pecoff/hello.test (original)
+++ lld/trunk/test/pecoff/hello.test Thu Aug 29 02:34:58 2013
@@ -36,7 +36,7 @@ SECTIONS: }
SECTIONS: Section {
SECTIONS: Number: 2
SECTIONS: Name: .data (2E 64 61 74 61 00 00 00)
-SECTIONS: VirtualSize: 0x18
+SECTIONS: VirtualSize: 0x12
SECTIONS: VirtualAddress: 0x2000
SECTIONS: RawDataSize: 512
SECTIONS: PointerToRawData: 0x400
More information about the llvm-commits
mailing list