summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core
diff options
context:
space:
mode:
Diffstat (limited to 'lld/lib/Core')
-rw-r--r--lld/lib/Core/Resolver.cpp7
-rw-r--r--lld/lib/Core/SymbolTable.cpp14
2 files changed, 13 insertions, 8 deletions
diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp
index 8b426fae87f..7e0d2e2895b 100644
--- a/lld/lib/Core/Resolver.cpp
+++ b/lld/lib/Core/Resolver.cpp
@@ -110,11 +110,8 @@ void Resolver::doDefinedAtom(const DefinedAtom &atom) {
// add to list of known atoms
_atoms.push_back(&atom);
- // non-static atoms need extra handling
- if (atom.scope() != DefinedAtom::scopeTranslationUnit) {
- // tell symbol table about non-static atoms
- _symbolTable.add(atom);
- }
+ // tell symbol table
+ _symbolTable.add(atom);
if (_options.deadCodeStripping()) {
// add to set of dead-strip-roots, all symbols that
diff --git a/lld/lib/Core/SymbolTable.cpp b/lld/lib/Core/SymbolTable.cpp
index b3fe8e8a50e..1c7ea99ff05 100644
--- a/lld/lib/Core/SymbolTable.cpp
+++ b/lld/lib/Core/SymbolTable.cpp
@@ -46,11 +46,16 @@ void SymbolTable::add(const AbsoluteAtom &atom) {
}
void SymbolTable::add(const DefinedAtom &atom) {
- assert(atom.scope() != DefinedAtom::scopeTranslationUnit);
- if ( !atom.name().empty() ) {
+ if (!atom.name().empty() &&
+ (atom.scope() != DefinedAtom::scopeTranslationUnit)) {
+ // Named atoms cannot be merged by content.
+ assert(atom.merge() != DefinedAtom::mergeByContent);
+ // Track named atoms that are not scoped to file (static).
this->addByName(atom);
}
- else {
+ else if ( atom.merge() == DefinedAtom::mergeByContent ) {
+ // Named atoms cannot be merged by content.
+ assert(atom.name().empty());
this->addByContent(atom);
}
}
@@ -123,6 +128,7 @@ static MergeResolution mergeSelect(DefinedAtom::Merge first,
void SymbolTable::addByName(const Atom & newAtom) {
StringRef name = newAtom.name();
+ assert(!name.empty());
const Atom *existing = this->findByName(name);
if (existing == nullptr) {
// Name is not in symbol table yet, add it associate with this atom.
@@ -283,6 +289,8 @@ bool SymbolTable::AtomMappingInfo::isEqual(const DefinedAtom * const l,
}
void SymbolTable::addByContent(const DefinedAtom & newAtom) {
+ // Currently only read-only constants can be merged.
+ assert(newAtom.permissions() == DefinedAtom::permR__);
AtomContentSet::iterator pos = _contentTable.find(&newAtom);
if ( pos == _contentTable.end() ) {
_contentTable.insert(&newAtom);
OpenPOWER on IntegriCloud