summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-04-23 09:16:53 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-04-23 09:16:53 +0000
commitb9ed9cb5d7e36bcb07b437a8980df32cfe8268a2 (patch)
treecae481c684625b3a0100092411c8ee5b2d486f38 /llvm/lib/MC/ELFObjectWriter.cpp
parent7a784203535b2ec0712d85f898ab1a874530d084 (diff)
downloadbcm5719-llvm-b9ed9cb5d7e36bcb07b437a8980df32cfe8268a2.tar.gz
bcm5719-llvm-b9ed9cb5d7e36bcb07b437a8980df32cfe8268a2.zip
[llvm-mc] - Properly set the the address align field of the compressed sections.
About the compressed sections spec says: (https://docs.oracle.com/cd/E37838_01/html/E36783/section_compression.html) sh_addralign fields of the section header for a compressed section reflect the requirements of the compressed section. Currently, llvm-mc always puts uncompressed section alignment to sh_addralign. It is not correct. zlib styled section contains an Elfxx_Chdr header, so we should either use 4 or 8 values depending on the target (Uncompressed section alignment is stored in ch_addralign field of the compression header). GNU assembler version 2.31.1 also has this issue, but in 2.32.51 it was already fixed. This is how it was found during debugging of the https://bugs.llvm.org/show_bug.cgi?id=40482 actually. Differential revision: https://reviews.llvm.org/D60965 llvm-svn: 358960
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 1d4f3afe2ea..96bbc2ee630 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -886,12 +886,16 @@ void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
return;
}
- if (ZlibStyle)
+ if (ZlibStyle) {
// Set the compressed flag. That is zlib style.
Section.setFlags(Section.getFlags() | ELF::SHF_COMPRESSED);
- else
+ // Alignment field should reflect the requirements of
+ // the compressed section header.
+ Section.setAlignment(is64Bit() ? 8 : 4);
+ } else {
// Add "z" prefix to section name. This is zlib-gnu style.
MC.renameELFSection(&Section, (".z" + SectionName.drop_front(1)).str());
+ }
W.OS << CompressedContents;
}
OpenPOWER on IntegriCloud