[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
Mon Jul 17 09:26:43 PDT 2017
peter.smith updated this revision to Diff 106890.
peter.smith added a comment.
Thanks for the comments. I've updated the diff and renamed to LabeledThunk which I think makes sense as the Symbol labels the Thunk.
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.
@@ -91,6 +93,9 @@
// 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 *LabeledThunk = nullptr;
+
uint32_t DynsymIndex = 0;
uint32_t GotIndex = -1;
uint32_t GotPltIndex = -1;
Index: ELF/Relocations.h
===================================================================
--- ELF/Relocations.h
+++ ELF/Relocations.h
@@ -152,10 +152,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
@@ -1246,7 +1246,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->LabeledThunk) {
if (Target->inBranchRange(Rel.Type, Src, Rel.Sym->getVA()))
return true;
Rel.Sym = &ET->Destination;
@@ -1325,7 +1325,7 @@
else
TS = getISRThunkSec(Cmd->Sec, IS, ISR, Rel.Type, Src);
TS->addThunk(T);
- Thunks[T->ThunkSym] = T;
+ T->ThunkSym->LabeledThunk = 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.106890.patch
Type: text/x-patch
Size: 2220 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170717/cd85ff19/attachment.bin>
More information about the llvm-commits
mailing list