diff options
-rw-r--r-- | lld/ELF/SyntheticSections.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index ad1ec14dc00..80a80c40fce 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -435,8 +435,15 @@ bool EhFrameSection<ELFT>::isFdeLive(EhSectionPiece &Piece, ArrayRef<RelTy> Rels) { auto *Sec = cast<EhInputSection>(Piece.ID); unsigned FirstRelI = Piece.FirstRelocation; + + // An FDE should point to some function because FDEs are to describe + // functions. That's however not always the case due to an issue of + // ld.gold with -r. ld.gold may discard only functions and leave their + // corresponding FDEs, which results in creating bad .eh_frame sections. + // To deal with that, we ignore such FDEs. if (FirstRelI == (unsigned)-1) return false; + const RelTy &Rel = Rels[FirstRelI]; SymbolBody &B = Sec->template getFile<ELFT>()->getRelocTargetSym(Rel); auto *D = dyn_cast<DefinedRegular>(&B); |