[lld] r314861 - Merging r312706:
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 3 16:44:23 PDT 2017
Author: ruiu
Date: Tue Oct 3 16:44:23 2017
New Revision: 314861
URL: http://llvm.org/viewvc/llvm-project?rev=314861&view=rev
Log:
Merging r312706:
------------------------------------------------------------------------
r312706 | anng | 2017-09-07 01:43:56 -0700 (Thu, 07 Sep 2017) | 14 lines
[LLD] Fix padding of .eh_frame when in executable segment
The default padding for an executable segment is the target trap
instruction which for x86_64 is 0xCC. However, the .eh_frame section
requires the padding to be zero. The code that writes the .eh_frame
section assumes that its segment is zero initialized and does not
explicitly write the zero padding. This does not work when the .eh_frame
section is in the executable segment (for example when using
-no-rosegment).
This patch changes the .eh_frame writing code to explicitly write the
zero padding.
Differential Revision: https://reviews.llvm.org/D37462
------------------------------------------------------------------------
Added:
lld/branches/release_50/test/ELF/eh-frame-padding-no-rosegment.s
- copied unchanged from r312706, lld/trunk/test/ELF/eh-frame-padding-no-rosegment.s
Modified:
lld/branches/release_50/ (props changed)
lld/branches/release_50/ELF/SyntheticSections.cpp
Propchange: lld/branches/release_50/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Oct 3 16:44:23 2017
@@ -1 +1 @@
-/lld/trunk:308492,308728,308935,308998,309002,310526,310989,310992,313741
+/lld/trunk:308492,308728,308935,308998,309002,310526,310989,310992,312706,313741
Modified: lld/branches/release_50/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_50/ELF/SyntheticSections.cpp?rev=314861&r1=314860&r2=314861&view=diff
==============================================================================
--- lld/branches/release_50/ELF/SyntheticSections.cpp (original)
+++ lld/branches/release_50/ELF/SyntheticSections.cpp Tue Oct 3 16:44:23 2017
@@ -523,9 +523,14 @@ template <class ELFT>
static void writeCieFde(uint8_t *Buf, ArrayRef<uint8_t> D) {
memcpy(Buf, D.data(), D.size());
+ size_t Aligned = alignTo(D.size(), sizeof(typename ELFT::uint));
+
+ // Zero-clear trailing padding if it exists.
+ memset(Buf + D.size(), 0, Aligned - D.size());
+
// Fix the size field. -4 since size does not include the size field itself.
const endianness E = ELFT::TargetEndianness;
- write32<E>(Buf, alignTo(D.size(), sizeof(typename ELFT::uint)) - 4);
+ write32<E>(Buf, Aligned - 4);
}
template <class ELFT> void EhFrameSection<ELFT>::finalizeContents() {
More information about the llvm-commits
mailing list