[PATCH] D28045: [ELF] - Return file offset as address only for allocatable sections when building .gdb_index

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 22 00:06:13 PST 2016


grimar created this revision.
grimar added a reviewer: dblaikie.
grimar added subscribers: ruiu, rafael, llvm-commits, grimar.
Herald added a subscriber: aprantl.

It is my suggestion for fixing issue we discussing in
"[llvm] r289961 - Revert "dwarfdump: Support/process relocations on a CU's abbrev_off"" thread.

Since callback named getSectionLoadAddress() it looks reasonable to make it return address only
for allocatable sections. That works for LLD needs and solves problem.


https://reviews.llvm.org/D28045

Files:
  ELF/GdbIndex.cpp


Index: ELF/GdbIndex.cpp
===================================================================
--- ELF/GdbIndex.cpp
+++ ELF/GdbIndex.cpp
@@ -179,10 +179,15 @@
   return Ret;
 }
 
+// We return file offset as load address for allocatable sections. That is
+// currently used for collecting address ranges in readAddressArea(). We are
+// able then to find section index that range belongs to.
 template <class ELFT>
 uint64_t GdbIndexBuilder<ELFT>::getSectionLoadAddress(
     const object::SectionRef &Sec) const {
-  return static_cast<const ELFSectionRef &>(Sec).getOffset();
+  if (static_cast<const ELFSectionRef &>(Sec).getFlags() & ELF::SHF_ALLOC)
+    return static_cast<const ELFSectionRef &>(Sec).getOffset();
+  return 0;
 }
 
 template <class ELFT>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28045.82310.patch
Type: text/x-patch
Size: 757 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161222/9398c39e/attachment.bin>


More information about the llvm-commits mailing list