summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-09-14 19:00:35 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-09-14 19:00:35 +0000
commitbfcdfb32af5dcc25b3cf7cec26c8dd9c4e974aef (patch)
tree89630e6591dac9710c217ea692fe91b66ae5071b /lld/ELF/Writer.cpp
parentdc6be2453f28d77d9849c046d04707b4898b4c5e (diff)
downloadbcm5719-llvm-bfcdfb32af5dcc25b3cf7cec26c8dd9c4e974aef.tar.gz
bcm5719-llvm-bfcdfb32af5dcc25b3cf7cec26c8dd9c4e974aef.zip
Correctly align sections.
We have to align the start, not the end. This should fix crashes on systems where memcpy enforces the expected alignment. llvm-svn: 247599
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6d1c94ea8f4..f33257ea8ce 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -704,12 +704,14 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
uintX_t Align = Sec->getAlign();
uintX_t Size = Sec->getSize();
if (Sec->getFlags() & SHF_ALLOC) {
+ VA = RoundUpToAlignment(VA, Align);
Sec->setVA(VA);
- VA += RoundUpToAlignment(Size, Align);
+ VA += Size;
}
+ FileOff = RoundUpToAlignment(FileOff, Align);
Sec->setFileOffset(FileOff);
if (Sec->getType() != SHT_NOBITS)
- FileOff += RoundUpToAlignment(Size, Align);
+ FileOff += Size;
}
// Add a PHDR for the dynamic table.
OpenPOWER on IntegriCloud