diff options
Diffstat (limited to 'lld/ELF/OutputSections.cpp')
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 8bdc2b0e5c4..6d2605ab5cc 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -947,7 +947,8 @@ void EHOutputSection<ELFT>::addSectionAux( auto RelI = Rels.begin(); auto RelE = Rels.end(); - DenseMap<unsigned, unsigned> OffsetToIndex; + // Maps offset to Index/Length pair. + DenseMap<unsigned, std::pair<unsigned, uint32_t>> OffsetToData; while (!D.empty()) { unsigned Index = S->Offsets.size(); S->Offsets.push_back(std::make_pair(Offset, -1)); @@ -974,21 +975,24 @@ void EHOutputSection<ELFT>::addSectionAux( std::pair<StringRef, StringRef> CieInfo(Entry, Personality); auto P = CieMap.insert(std::make_pair(CieInfo, Cies.size())); - if (P.second) { + if (P.second) Cies.push_back(C); - this->Header.sh_size += RoundUpToAlignment(Length, sizeof(uintX_t)); - } - OffsetToIndex[Offset] = P.first->second; + OffsetToData[Offset] = std::make_pair(P.first->second, Length); } else { if (!HasReloc) error("FDE doesn't reference another section"); InputSectionBase<ELFT> *Target = S->getRelocTarget(*RelI); if (Target != &InputSection<ELFT>::Discarded && Target->isLive()) { uint32_t CieOffset = Offset + 4 - ID; - auto I = OffsetToIndex.find(CieOffset); - if (I == OffsetToIndex.end()) + auto I = OffsetToData.find(CieOffset); + if (I == OffsetToData.end()) error("Invalid CIE reference"); - Cies[I->second].Fdes.push_back(EHRegion<ELFT>(S, Index)); + std::pair<unsigned, uint32_t> &IndLen = I->second; + Cie<ELFT> &Cie = Cies[IndLen.first]; + if (Cie.Fdes.empty()) + this->Header.sh_size += + RoundUpToAlignment(IndLen.second, sizeof(uintX_t)); + Cie.Fdes.push_back(EHRegion<ELFT>(S, Index)); this->Header.sh_size += RoundUpToAlignment(Length, sizeof(uintX_t)); } } |

