diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-02 12:47:20 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-02 12:47:20 +0000 |
commit | d040441f934c022d291dd78321d95ff2bff27f05 (patch) | |
tree | 448ab0fbfc5895ee194074338621c92d0773d79e /ELF/SyntheticSections.cpp | |
parent | 43f6d9feefc874e8ad4e96f4b4c3c0713a29febe (diff) | |
download | src-d040441f934c022d291dd78321d95ff2bff27f05.tar.gz src-d040441f934c022d291dd78321d95ff2bff27f05.zip |
Vendor import of lld release_50 branch r319231:vendor/lld/lld-release_50-r319231
Notes
Notes:
svn path=/vendor/lld/dist/; revision=326467
svn path=/vendor/lld/lld-release_50-r319231/; revision=326468; tag=vendor/lld/lld-release_50-r319231
Diffstat (limited to 'ELF/SyntheticSections.cpp')
-rw-r--r-- | ELF/SyntheticSections.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ELF/SyntheticSections.cpp b/ELF/SyntheticSections.cpp index 4bbec4ab34bd..a67b039ddf21 100644 --- a/ELF/SyntheticSections.cpp +++ b/ELF/SyntheticSections.cpp @@ -427,10 +427,11 @@ CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Piece, &Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]); // Search for an existing CIE by CIE contents/relocation target pair. - CieRecord *Cie = &CieMap[{Piece.data(), Personality}]; + CieRecord *&Cie = CieMap[{Piece.data(), Personality}]; // If not found, create a new one. - if (Cie->Piece == nullptr) { + if (!Cie) { + Cie = make<CieRecord>(); Cie->Piece = &Piece; Cies.push_back(Cie); } @@ -522,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() { |