[PATCH] D35004: [DWARF] - Add API to allow DWARFContextInMemory to delegate relocations handling to client.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 04:05:17 PDT 2017


grimar created this revision.

Previously DWARFContextInMemory handled relocations by itself.
(or used pre-relocated section content via another API)
This patch adds way to delegate relocations handling to client for each
relocation section.

I am using it in patch for LLD to speedup .gdb_index building, will
upload it and add dependency to this one really soon.

That allows to do some custom things, for example when building .gdb_index
looks we do not need to perform relocations computations for .debug_ranges,
all we need is to scan relocations to find the section indexes for futher use.


https://reviews.llvm.org/D35004

Files:
  include/llvm/DebugInfo/DIContext.h
  lib/DebugInfo/DWARF/DWARFContext.cpp


Index: lib/DebugInfo/DWARF/DWARFContext.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFContext.cpp
+++ lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -1041,6 +1041,9 @@
     if (Section.relocation_begin() == Section.relocation_end())
       continue;
 
+    if (L && L->relocate(Section, Map))
+      continue;
+
     // Symbol to [address, section index] cache mapping.
     std::map<SymbolRef, SymInfo> AddrCache;
     for (const RelocationRef &Reloc : Section.relocations()) {
Index: include/llvm/DebugInfo/DIContext.h
===================================================================
--- include/llvm/DebugInfo/DIContext.h
+++ include/llvm/DebugInfo/DIContext.h
@@ -16,6 +16,7 @@
 #define LLVM_DEBUGINFO_DICONTEXT_H
 
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
 #include "llvm/Object/ObjectFile.h"
 #include <cassert>
 #include <cstdint>
@@ -221,6 +222,18 @@
     return false;
   }
 
+  // Client may overload this method to perform relocations on its side.
+  //
+  // RelSec is a relocation section, client code is responsible for filling Map
+  // with relocated values. It that case method should return true, to say that
+  // client proccessed relocations and nothing else should be done on parser
+  // side. If method returns false (default), parser is responsible for
+  // performing relocations.
+  virtual bool relocate(const object::SectionRef &RelSec,
+                        RelocAddrMap *Map) const {
+    return false;
+  }
+
   /// Obtain a copy of this LoadedObjectInfo.
   ///
   /// The caller is responsible for deallocation once the copy is no longer required.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35004.105242.patch
Type: text/x-patch
Size: 1680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170705/33ede283/attachment-0001.bin>


More information about the llvm-commits mailing list