[lld] r216122 - Add notifier hooks to symbol table.
Nick Kledzik
kledzik at apple.com
Wed Aug 20 13:46:29 PDT 2014
Author: kledzik
Date: Wed Aug 20 15:46:28 2014
New Revision: 216122
URL: http://llvm.org/viewvc/llvm-project?rev=216122&view=rev
Log:
Add notifier hooks to symbol table.
This is the one interesting aspect from:
http://reviews.llvm.org/D4965
These hooks are useful for flavor specific processing, such as recording that
a DefinedAtom replaced a weak SharedLibraryAtom.
Modified:
lld/trunk/include/lld/Core/LinkingContext.h
lld/trunk/lib/Core/SymbolTable.cpp
Modified: lld/trunk/include/lld/Core/LinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=216122&r1=216121&r2=216122&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LinkingContext.h (original)
+++ lld/trunk/include/lld/Core/LinkingContext.h Wed Aug 20 15:46:28 2014
@@ -224,6 +224,20 @@ public:
}
InputGraph &getInputGraph() const { return *_inputGraph; }
+ /// Notify the LinkingContext when an atom is added to the symbol table.
+ /// This is an opportunity for flavor specific work to be done.
+ virtual void notifySymbolTableAdd(const Atom *atom) const {
+ }
+
+ /// Notify the LinkingContext when the symbol table found a name collision.
+ /// The useNew parameter specifies which the symbol table plans to keep,
+ /// but that can be changed by the LinkingContext. This is also an
+ /// opportunity for flavor specific processing.
+ virtual void notifySymbolTableCoalesce(const Atom *existingAtom,
+ const Atom *newAtom,
+ bool &useNew) const {
+ }
+
/// This method adds undefined symbols specified by the -u option to the to
/// the list of undefined symbols known to the linker. This option essentially
/// forces an undefined symbol to be created. You may also need to call
Modified: lld/trunk/lib/Core/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/SymbolTable.cpp?rev=216122&r1=216121&r2=216122&view=diff
==============================================================================
--- lld/trunk/lib/Core/SymbolTable.cpp (original)
+++ lld/trunk/lib/Core/SymbolTable.cpp Wed Aug 20 15:46:28 2014
@@ -171,6 +171,7 @@ bool SymbolTable::addByName(const Atom &
const Atom *existing = findByName(name);
if (existing == nullptr) {
// Name is not in symbol table yet, add it associate with this atom.
+ _context.notifySymbolTableAdd(&newAtom);
_nameTable[name] = &newAtom;
return true;
}
@@ -299,6 +300,9 @@ bool SymbolTable::addByName(const Atom &
break;
}
+ // Give context a chance to change which is kept.
+ _context.notifySymbolTableCoalesce(existing, &newAtom, useNew);
+
if (useNew) {
// Update name table to use new atom.
_nameTable[name] = &newAtom;
More information about the llvm-commits
mailing list