aboutsummaryrefslogtreecommitdiffstats
path: root/ELF
diff options
context:
space:
mode:
Diffstat (limited to 'ELF')
-rw-r--r--ELF/SyntheticSections.cpp12
-rw-r--r--ELF/SyntheticSections.h3
2 files changed, 11 insertions, 4 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() {
diff --git a/ELF/SyntheticSections.h b/ELF/SyntheticSections.h
index ddd8ca99a61b..ccf021ec9597 100644
--- a/ELF/SyntheticSections.h
+++ b/ELF/SyntheticSections.h
@@ -103,7 +103,8 @@ private:
std::vector<CieRecord *> Cies;
// CIE records are uniquified by their contents and personality functions.
- llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap;
+ llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord *>
+ CieMap;
};
class GotSection : public SyntheticSection {