Index: ELF/SyntheticSections.cpp =================================================================== --- ELF/SyntheticSections.cpp +++ ELF/SyntheticSections.cpp @@ -1701,16 +1701,6 @@ return Ret; } -static InputSectionBase *findSection(ArrayRef Arr, - uint64_t Offset) { - for (InputSectionBase *S : Arr) - if (S && S != &InputSection::Discarded) - if (Offset >= S->getOffsetInFile() && - Offset < S->getOffsetInFile() + S->getSize()) - return S; - return nullptr; -} - static std::vector readAddressArea(DWARFContext &Dwarf, InputSection *Sec, size_t CurrentCU) { std::vector Ret; @@ -1720,10 +1710,12 @@ CU->collectAddressRanges(Ranges); ArrayRef Sections = Sec->File->getSections(); - for (std::pair &R : Ranges) - if (InputSectionBase *S = findSection(Sections, R.first)) - Ret.push_back({S, R.first - S->getOffsetInFile(), - R.second - S->getOffsetInFile(), CurrentCU}); + for (DWARFAddress &R : Ranges) { + InputSectionBase *S = Sections[R.SecNdx]; + if (!S || S == &InputSection::Discarded) + continue; + Ret.push_back({S, R.LowPC, R.HighPC, CurrentCU}); + } ++CurrentCU; } return Ret; @@ -1744,17 +1736,6 @@ return Ret; } -class ObjInfoTy : public llvm::LoadedObjectInfo { - uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const override { - auto &S = static_cast(Sec); - if (S.getFlags() & ELF::SHF_ALLOC) - return S.getOffset(); - return 0; - } - - std::unique_ptr clone() const override { return {}; } -}; - void GdbIndexSection::readDwarf(InputSection *Sec) { Expected> Obj = object::ObjectFile::createObjectFile(Sec->File->MB); @@ -1763,8 +1744,7 @@ return; } - ObjInfoTy ObjInfo; - DWARFContextInMemory Dwarf(*Obj.get(), &ObjInfo); + DWARFContextInMemory Dwarf(*Obj.get()); size_t CuId = CompilationUnits.size(); for (std::pair &P : readCuList(Dwarf, Sec))