forked from OSchip/llvm-project
Revert "[ELF] Fix linking when a regular object defines a symbol that is used in a DSO"
This commit reverts r218259 because it needed to be checked in with a few binary files for the test. llvm-svn: 218262
This commit is contained in:
parent
f2a721a875
commit
869c0019b1
|
@ -262,8 +262,8 @@ public:
|
||||||
|
|
||||||
void setCreateSeparateROSegment() { _mergeRODataToTextSegment = false; }
|
void setCreateSeparateROSegment() { _mergeRODataToTextSegment = false; }
|
||||||
|
|
||||||
bool hasCoalescedSharedLibPair(StringRef name) const {
|
bool hasCoalescedWeakPair(StringRef name) const {
|
||||||
return _sharedLibCoalescedSymbols.count(name) != 0;
|
return _weakCoalescedSymbols.count(name) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -300,7 +300,7 @@ protected:
|
||||||
StringRefVector _rpathList;
|
StringRefVector _rpathList;
|
||||||
StringRefVector _rpathLinkList;
|
StringRefVector _rpathLinkList;
|
||||||
std::map<std::string, uint64_t> _absoluteSymbols;
|
std::map<std::string, uint64_t> _absoluteSymbols;
|
||||||
llvm::StringSet<> _sharedLibCoalescedSymbols;
|
llvm::StringSet<> _weakCoalescedSymbols;
|
||||||
};
|
};
|
||||||
} // end namespace lld
|
} // end namespace lld
|
||||||
|
|
||||||
|
|
|
@ -241,6 +241,11 @@ std::unique_ptr<File> ELFLinkingContext::createUndefinedSymbolFile() const {
|
||||||
return std::move(undefinedSymFile);
|
return std::move(undefinedSymFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isSharedWeakAtom(const UndefinedAtom *ua) {
|
||||||
|
return ua->canBeNull() != UndefinedAtom::canBeNullNever &&
|
||||||
|
isa<SharedLibraryFile>(ua->file());
|
||||||
|
}
|
||||||
|
|
||||||
void ELFLinkingContext::notifySymbolTableCoalesce(const Atom *existingAtom,
|
void ELFLinkingContext::notifySymbolTableCoalesce(const Atom *existingAtom,
|
||||||
const Atom *newAtom,
|
const Atom *newAtom,
|
||||||
bool &useNew) {
|
bool &useNew) {
|
||||||
|
@ -254,12 +259,11 @@ void ELFLinkingContext::notifySymbolTableCoalesce(const Atom *existingAtom,
|
||||||
ua = dyn_cast<UndefinedAtom>(existingAtom);
|
ua = dyn_cast<UndefinedAtom>(existingAtom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (da && ua && da->scope() == Atom::scopeGlobal &&
|
if (da && ua && da->scope() == Atom::scopeGlobal && isSharedWeakAtom(ua))
|
||||||
isa<SharedLibraryFile>(ua->file()))
|
// If strong defined atom coalesces away weak atom declared
|
||||||
// If strong defined atom coalesces away an atom declared
|
// in the shared object the strong atom needs to be dynamicaly exported.
|
||||||
// in the shared object the strong atom needs to be dynamically exported.
|
|
||||||
// Save its name.
|
// Save its name.
|
||||||
_sharedLibCoalescedSymbols.insert(ua->name());
|
_weakCoalescedSymbols.insert(ua->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace lld
|
} // end namespace lld
|
||||||
|
|
|
@ -183,7 +183,7 @@ void OutputELFWriter<ELFT>::buildDynamicSymbolTable(const File &file) {
|
||||||
for (const auto &atom : section->atoms()) {
|
for (const auto &atom : section->atoms()) {
|
||||||
const DefinedAtom *da = dyn_cast<const DefinedAtom>(atom->_atom);
|
const DefinedAtom *da = dyn_cast<const DefinedAtom>(atom->_atom);
|
||||||
if (da && (da->dynamicExport() == DefinedAtom::dynamicExportAlways ||
|
if (da && (da->dynamicExport() == DefinedAtom::dynamicExportAlways ||
|
||||||
_context.hasCoalescedSharedLibPair(da->name())))
|
_context.hasCoalescedWeakPair(da->name())))
|
||||||
_dynamicSymbolTable->addSymbol(atom->_atom, section->ordinal(),
|
_dynamicSymbolTable->addSymbol(atom->_atom, section->ordinal(),
|
||||||
atom->_virtualAddr, atom);
|
atom->_virtualAddr, atom);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
# Tests that a reference from a DSO to a regular object
|
|
||||||
# forces the final executable to export the symbol.
|
|
||||||
|
|
||||||
RUN: lld -flavor gnu -target x86_64 %p/Inputs/defobj.o -L%p/Inputs -lundef2 -o %t1
|
|
||||||
RUN: llvm-readobj -dyn-symbols %t1 | FileCheck -check-prefix CHECKSYMS %s
|
|
||||||
|
|
||||||
CHECKSYMS: myexportedsymbol
|
|
Loading…
Reference in New Issue