[PATCH] D35004: [DWARF] - Add API to allow DWARFContextInMemory to delegate relocations handling to client.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 5 10:46:30 PDT 2017
I wonder if it would not be better to split DWARFContextInMemory in two.
DWARFContextInMemory would have no idea how to get section contents and
relocations. It would deffer that to a helper object. The
DWARFContextInMemory constructor would do nothing.
In llvm we would have a helper implementation that looks just like the
current DWARFContextInMemory constructor:
* Walk all sections.
* Decompress if compressed.
* Parse relocations into maps.
In lld we could have a very different implementation
* Don't walk the sections. We already did that.
* Don't decompress, we already did that.
* Don't parse relocations early.
The last point is because lld does a very simple in order walk over the
data. I would be surprised if it is not more efficient to walk the
relocations is lockstep instead of having a full map.
Cheers,
Rafael
George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
> 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.
>
>
> 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.
More information about the llvm-commits
mailing list