diff options
Diffstat (limited to 'lld/ELF/Symbols.cpp')
-rw-r--r-- | lld/ELF/Symbols.cpp | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 3d99ef3baaa..5f1e69b2601 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -127,7 +127,8 @@ SymbolBody::SymbolBody(Kind K, StringRefZ Name, bool IsLocal, uint8_t StOther, uint8_t Type) : SymbolKind(K), NeedsPltAddr(false), IsLocal(IsLocal), IsInGlobalMipsGot(false), Is32BitMipsGot(false), IsInIplt(false), - IsInIgot(false), Type(Type), StOther(StOther), Name(Name) {} + IsInIgot(false), IsPreemptible(false), Type(Type), StOther(StOther), + Name(Name) {} InputFile *SymbolBody::getFile() const { if (isLocal()) @@ -135,41 +136,6 @@ InputFile *SymbolBody::getFile() const { return symbol()->File; } -// Returns true if a symbol can be replaced at load-time by a symbol -// with the same name defined in other ELF executable or DSO. -bool SymbolBody::isPreemptible() const { - if (isLocal()) - return false; - - // Shared symbols resolve to the definition in the DSO. The exceptions are - // symbols with copy relocations (which resolve to .bss) or preempt plt - // entries (which resolve to that plt entry). - if (auto *SS = dyn_cast<SharedSymbol>(this)) - return !SS->CopyRelSec && !NeedsPltAddr; - - // Only symbols that appear in dynsym can be preempted. - if (!symbol()->includeInDynsym()) - return false; - - // Only default visibility symbols can be preempted. - if (symbol()->Visibility != STV_DEFAULT) - return false; - - // Undefined symbols in non-DSOs are usually just an error, so it - // doesn't matter whether we return true or false here. However, if - // -unresolved-symbols=ignore-all is specified, undefined symbols in - // executables are automatically exported so that the runtime linker - // can try to resolve them. In that case, they is preemptible. So, we - // return true for an undefined symbol in case the option is specified. - if (!Config->Shared) - return isUndefined(); - - // -Bsymbolic means that definitions are not preempted. - if (Config->Bsymbolic || (Config->BsymbolicFunctions && isFunc())) - return !isDefined(); - return true; -} - // Overwrites all attributes with Other's so that this symbol becomes // an alias to Other. This is useful for handling some options such as // --wrap. |