[PATCH] D75636: [LLD][NFC] Remove getOffsetInFile() workaround.

Alexey Lapshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 12:57:15 PST 2020


avl created this revision.
avl added reviewers: ruiu, grimar, MaskRay.
avl added projects: LLVM, lld.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75636

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


Index: lld/ELF/SyntheticSections.cpp
===================================================================
--- lld/ELF/SyntheticSections.cpp
+++ lld/ELF/SyntheticSections.cpp
@@ -2693,8 +2693,7 @@
       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});
+      ret.push_back({isec, r.LowPC, r.HighPC, cuIdx});
     }
     ++cuIdx;
   }
Index: lld/ELF/InputFiles.cpp
===================================================================
--- lld/ELF/InputFiles.cpp
+++ 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) {
Index: lld/ELF/DWARF.cpp
===================================================================
--- lld/ELF/DWARF.cpp
+++ 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<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),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75636.248286.patch
Type: text/x-patch
Size: 1750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200304/57d66a21/attachment.bin>


More information about the llvm-commits mailing list