diff --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp --- a/lld/ELF/DWARF.cpp +++ b/lld/ELF/DWARF.cpp @@ -99,15 +99,9 @@ // its zero value will terminate the decoding of .debug_ranges prematurely. Symbol &s = file->getRelocTargetSym(rel); uint64_t val = 0; - if (auto *dr = dyn_cast(&s)) { + if (auto *dr = dyn_cast(&s)) val = dr->value; - // FIXME: We should be consistent about always adding the file - // offset or not. - if (dr->section->flags & ELF::SHF_ALLOC) - val += cast(dr->section)->getOffsetInFile(); - } - DataRefImpl d; d.p = getAddend(rel); return RelocAddrEntry{secIndex, RelocationRef(d, nullptr), diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -296,9 +296,7 @@ } } - // Use fake address calculated by adding section file offset and offset in - // section. See comments for ObjectInfo class. - return dwarf->getDILineInfo(s->getOffsetInFile() + offset, sectionIndex); + return dwarf->getDILineInfo(offset, sectionIndex); } ELFFileBase::ELFFileBase(Kind k, MemoryBufferRef mb) : InputFile(k, mb) { diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -2686,15 +2686,11 @@ for (DWARFAddressRange &r : *ranges) { if (r.SectionIndex == -1ULL) continue; - InputSectionBase *s = sections[r.SectionIndex]; - if (!s || s == &InputSection::discarded || !s->isLive()) - continue; // Range list with zero size has no effect. - if (r.LowPC == r.HighPC) - continue; - auto *isec = cast(s); - uint64_t offset = isec->getOffsetInFile(); - ret.push_back({isec, r.LowPC - offset, r.HighPC - offset, cuIdx}); + InputSectionBase *s = sections[r.SectionIndex]; + if (s && s != &InputSection::discarded && s->isLive()) + if (r.LowPC != r.HighPC) + ret.push_back({cast(s), r.LowPC, r.HighPC, cuIdx}); } ++cuIdx; }