summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/XCOFFObjectWriter.cpp
diff options
context:
space:
mode:
authordiggerlin <digger.llvm@gmail.com>2019-12-10 11:14:49 -0500
committerdiggerlin <digger.llvm@gmail.com>2019-12-10 11:14:49 -0500
commit98f5f022f0cb5ac6605385966ced38e1e2851f6b (patch)
tree7c8047c20651e7ed258bce9b7f1aecdfc9fa8361 /llvm/lib/MC/XCOFFObjectWriter.cpp
parentd77ae1552fc21a9f3877f3ed7e13d631f517c825 (diff)
downloadbcm5719-llvm-98f5f022f0cb5ac6605385966ced38e1e2851f6b.tar.gz
bcm5719-llvm-98f5f022f0cb5ac6605385966ced38e1e2851f6b.zip
[BUG-FIX][XCOFF] fixed a bug of XCOFFObjectFile.cpp when there is padding at the last csect of a sections
SUMMARY: Fixed a bug of XCOFFObjectFile.cpp when there is padding at the last csect of a sections. when there is a tail padding of a section, but the value of CurrentAddressLocation do not be increased by the padding size. it will hit assert assert(CurrentAddressLocation == Section->Address && "We should have no padding between sections."); Reviewers: daltenty,hubert.reinterpretcast, Differential Revision: https://reviews.llvm.org/D70859
Diffstat (limited to 'llvm/lib/MC/XCOFFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/XCOFFObjectWriter.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index 3bbf1a9b755..c7cba91c861 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -363,7 +363,7 @@ void XCOFFObjectWriter::writeSections(const MCAssembler &Asm,
continue;
assert(CurrentAddressLocation == Section->Address &&
- "We should have no padding between sections.");
+ "Sections should be written consecutively.");
for (const auto *Group : Section->Groups) {
for (const auto &Csect : *Group) {
if (uint32_t PaddingSize = Csect.Address - CurrentAddressLocation)
@@ -378,8 +378,10 @@ void XCOFFObjectWriter::writeSections(const MCAssembler &Asm,
// the current section minus the the end virtual address of the last csect
// in that section.
if (uint32_t PaddingSize =
- Section->Address + Section->Size - CurrentAddressLocation)
+ Section->Address + Section->Size - CurrentAddressLocation) {
W.OS.write_zeros(PaddingSize);
+ CurrentAddressLocation += PaddingSize;
+ }
}
}
OpenPOWER on IntegriCloud