mirror of
https://github.com/intel/llvm.git
synced 2026-01-19 17:45:07 +08:00
[ELF] Fix the semantic of PROVIDE in linker scripts.
PROVIDE request us to define a symbol only if it is referenced and is not defined by any object included in the link. We created the symbol in the symbol table no matter what. Differential Revision: https://reviews.llvm.org/D22739 llvm-svn: 276592
This commit is contained in:
@@ -350,7 +350,9 @@ template <class ELFT> void LinkerScript<ELFT>::addScriptedSymbols() {
|
||||
continue;
|
||||
|
||||
SymbolBody *B = Symtab<ELFT>::X->find(Cmd->Name);
|
||||
if (!B || B->isUndefined())
|
||||
// The semantic of PROVIDE is that of introducing a symbol only if
|
||||
// it's not defined and there's at least a reference to it.
|
||||
if ((!B && !Cmd->Provide) || (B && B->isUndefined()))
|
||||
Symtab<ELFT>::X->addAbsolute(Cmd->Name,
|
||||
Cmd->Hidden ? STV_HIDDEN : STV_DEFAULT);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user