[PATCH] D33183: [ELF] - Simplify readAddressArea() implementation.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 7 03:52:37 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL304895: [ELF] - Simplify readAddressArea() implementation. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D33183?vs=98964&id=101686#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33183

Files:
  lld/trunk/ELF/SyntheticSections.cpp


Index: lld/trunk/ELF/SyntheticSections.cpp
===================================================================
--- lld/trunk/ELF/SyntheticSections.cpp
+++ lld/trunk/ELF/SyntheticSections.cpp
@@ -1719,10 +1719,15 @@
     CU->collectAddressRanges(Ranges);
 
     ArrayRef<InputSectionBase *> 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<InputSection>(S), R.LowPC, R.HighPC, CurrentCU});
+    }
     ++CurrentCU;
   }
   return Ret;
@@ -1743,27 +1748,15 @@
   return Ret;
 }
 
-class ObjInfoTy : public llvm::LoadedObjectInfo {
-  uint64_t getSectionLoadAddress(const object::SectionRef &Sec) const override {
-    auto &S = static_cast<const object::ELFSectionRef &>(Sec);
-    if (S.getFlags() & ELF::SHF_ALLOC)
-      return S.getOffset();
-    return 0;
-  }
-
-  std::unique_ptr<llvm::LoadedObjectInfo> clone() const override { return {}; }
-};
-
 void GdbIndexSection::readDwarf(InputSection *Sec) {
   Expected<std::unique_ptr<object::ObjectFile>> Obj =
       object::ObjectFile::createObjectFile(Sec->File->MB);
   if (!Obj) {
     error(toString(Sec->File) + ": error creating DWARF context");
     return;
   }
 
-  ObjInfoTy ObjInfo;
-  DWARFContextInMemory Dwarf(*Obj.get(), &ObjInfo);
+  DWARFContextInMemory Dwarf(*Obj.get());
 
   size_t CuId = CompilationUnits.size();
   for (std::pair<uint64_t, uint64_t> &P : readCuList(Dwarf, Sec))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33183.101686.patch
Type: text/x-patch
Size: 1879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170607/85ebadd3/attachment.bin>


More information about the llvm-commits mailing list