Index: lld/trunk/ELF/SyntheticSections.cpp =================================================================== --- lld/trunk/ELF/SyntheticSections.cpp +++ lld/trunk/ELF/SyntheticSections.cpp @@ -1719,10 +1719,15 @@ CU->collectAddressRanges(Ranges); ArrayRef Sections = Sec->File->getSections(); - for (DWARFAddressRange &R : Ranges) - if (InputSection *S = findSection(Sections, R.LowPC)) - Ret.push_back({S, R.LowPC - S->getOffsetInFile(), - R.HighPC - S->getOffsetInFile(), CurrentCU}); + for (DWARFAddressRange &R : Ranges) { + InputSectionBase *S = Sections[R.SectionIndex]; + if (!S || S == &InputSection::Discarded || !S->Live) + continue; + // Range list with zero size has no effect. + if (R.LowPC == R.HighPC) + continue; + Ret.push_back({cast(S), R.LowPC, R.HighPC, CurrentCU}); + } ++CurrentCU; } return Ret; @@ -1743,17 +1748,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); @@ -1762,8 +1756,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))