[PATCH] D35413: [LLD][ELF] Add DefinedInThunk to SymbolBody to remove need for hash lookup
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 14 06:06:35 PDT 2017
peter.smith created this revision.
Herald added a subscriber: emaste.
When doing thunk creation, if a relocation target is defined in a thunk we need to find a way of getting to the Thunk object. This change removes the
DenseMap in ThunkCreator that stored the mapping in preference for storing a pointer to the Thunk in SymbolBody. This saves a hash lookup at the expense of adding a pointer to SymbolBody.
This was suggested in https://reviews.llvm.org/D34692
https://reviews.llvm.org/D35413
Files:
ELF/Relocations.cpp
ELF/Relocations.h
ELF/Symbols.h
Index: ELF/Symbols.h
===================================================================
--- ELF/Symbols.h
+++ ELF/Symbols.h
@@ -33,6 +33,8 @@
class OutputSection;
template <class ELFT> class SharedFile;
+class Thunk;
+
struct Symbol;
// The base class for real symbol classes.
@@ -90,7 +92,8 @@
// The file from which this symbol was created.
InputFile *File = nullptr;
-
+ // The Thunk that this symbol is defined in, nullptr if not defined in Thunk
+ Thunk *DefinedInThunk = nullptr;
uint32_t DynsymIndex = 0;
uint32_t GotIndex = -1;
uint32_t GotPltIndex = -1;
Index: ELF/Relocations.h
===================================================================
--- ELF/Relocations.h
+++ ELF/Relocations.h
@@ -151,10 +151,6 @@
// Record all the available Thunks for a Symbol
llvm::DenseMap<SymbolBody *, std::vector<Thunk *>> ThunkedSymbols;
- // Find a Thunk from the Thunks symbol definition, we can use this to find
- // the Thunk from a relocation to the Thunks symbol definition.
- llvm::DenseMap<SymbolBody *, Thunk *> Thunks;
-
// Track InputSections that have an inline ThunkSection placed in front
// an inline ThunkSection may have control fall through to the section below
// so we need to make sure that there is only one of them.
Index: ELF/Relocations.cpp
===================================================================
--- ELF/Relocations.cpp
+++ ELF/Relocations.cpp
@@ -1235,7 +1235,7 @@
// was originally to a Thunk, but is no longer in range we revert the
// relocation back to its original non-Thunk target.
bool ThunkCreator::normalizeExistingThunk(Relocation &Rel, uint64_t Src) {
- if (Thunk *ET = Thunks.lookup(Rel.Sym)) {
+ if (Thunk *ET = Rel.Sym->DefinedInThunk) {
if (Target->inBranchRange(Rel.Type, Src, Rel.Sym->getVA()))
return true;
Rel.Sym = &ET->Destination;
@@ -1313,7 +1313,7 @@
else
TS = getISRThunkSec(OS, IS, ISR, Rel.Type, Src);
TS->addThunk(T);
- Thunks[T->ThunkSym] = T;
+ T->ThunkSym->DefinedInThunk = T;
}
// Redirect relocation to Thunk, we never go via the PLT to a Thunk
Rel.Sym = T->ThunkSym;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35413.106635.patch
Type: text/x-patch
Size: 2220 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170714/3ff7278d/attachment.bin>
More information about the llvm-commits
mailing list