[lld] a130be6 - [LLD][NFC] Remove getOffsetInFile() workaround.

Alexey Lapshin via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 5 04:52:57 PST 2020


Author: Alexey Lapshin
Date: 2020-03-05T15:52:46+03:00
New Revision: a130be6ac51656407fd97208d13b763aaf37a7f3

URL: https://github.com/llvm/llvm-project/commit/a130be6ac51656407fd97208d13b763aaf37a7f3
DIFF: https://github.com/llvm/llvm-project/commit/a130be6ac51656407fd97208d13b763aaf37a7f3.diff

LOG: [LLD][NFC] Remove getOffsetInFile() workaround.

Summary:
LLD has workaround for the times when SectionIndex was not passed properly:

LT->getFileLineInfoForAddress(
      S->getOffsetInFile() + Offset, nullptr,
      DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, Info));

S->getOffsetInFile() was added to differentiate offsets between
various sections. Now SectionIndex is properly specified.
Thus it is not necessary to use getOffsetInFile() workaround.
See https://reviews.llvm.org/D58194, https://reviews.llvm.org/D58357.

This patch removes getOffsetInFile() workaround.

Reviewers: ruiu, grimar, MaskRay, espindola

Reviewed By: grimar, MaskRay

Subscribers: emaste, arichardson, llvm-commits

Tags: #llvm, #lld

Differential Revision: https://reviews.llvm.org/D75636

Added: 
    

Modified: 
    lld/ELF/DWARF.cpp
    lld/ELF/InputFiles.cpp
    lld/ELF/SyntheticSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp
index a00189a0e3a2..bf4fff76c31f 100644
--- a/lld/ELF/DWARF.cpp
+++ b/lld/ELF/DWARF.cpp
@@ -99,15 +99,9 @@ LLDDwarfObj<ELFT>::findAux(const InputSectionBase &sec, uint64_t pos,
   // 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<Defined>(&s)) {
+  if (auto *dr = dyn_cast<Defined>(&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<InputSection>(dr->section)->getOffsetInFile();
-  }
-
   DataRefImpl d;
   d.p = getAddend<ELFT>(rel);
   return RelocAddrEntry{secIndex, RelocationRef(d, nullptr),

diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index bd33fca23eec..4ec9abdcc090 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -296,9 +296,7 @@ Optional<DILineInfo> ObjFile<ELFT>::getDILineInfo(InputSectionBase *s,
     }
   }
 
-  // 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
index d15226949e96..3fd8cd7b745e 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2686,15 +2686,11 @@ readAddressAreas(DWARFContext &dwarf, InputSection *sec) {
     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<InputSection>(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<InputSection>(s), r.LowPC, r.HighPC, cuIdx});
     }
     ++cuIdx;
   }


        


More information about the llvm-commits mailing list