Commit a4fcc49a authored by Rui Ueyama's avatar Rui Ueyama
Browse files

Merging r313741:

------------------------------------------------------------------------
r313741 | grimar | 2017-09-20 02:27:41 -0700 (Wed, 20 Sep 2017) | 9 lines

[ELF] - Fix segfault when processing .eh_frame.

Its a PR34648 which was a segfault that happened because
we stored pointers to elements in DenseMap. 
When DenseMap grows such pointers are invalidated.
Solution implemented is to keep elements by pointer
and not by value.

Differential revision: https://reviews.llvm.org/D38034
------------------------------------------------------------------------

llvm-svn: 314860
parent 08d41dde
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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);
  }
+2 −1
Original line number Diff line number Diff line
@@ -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 {