diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-14 15:39:25 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-14 15:39:25 +0000 |
commit | 1eafc0458f4bb4547fe78c62b78312ad4f719c38 (patch) | |
tree | db247ebc1d3d05750e31ef4b162cf9ab4af9ddef /ELF/Symbols.cpp | |
parent | b047fead11133644be3dbae34b85be39ce2819e9 (diff) |
Notes
Diffstat (limited to 'ELF/Symbols.cpp')
-rw-r--r-- | ELF/Symbols.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/ELF/Symbols.cpp b/ELF/Symbols.cpp index f3edafaf4b78..289bc18487a8 100644 --- a/ELF/Symbols.cpp +++ b/ELF/Symbols.cpp @@ -81,7 +81,7 @@ static typename ELFT::uint getSymVA(const SymbolBody &Body, return 0; if (SS.isFunc()) return Body.getPltVA<ELFT>(); - return Out<ELFT>::Bss->Addr + SS.OffsetInBss; + return SS.getBssSectionForCopy()->Addr + SS.CopyOffset; } case SymbolBody::UndefinedKind: return 0; @@ -97,7 +97,8 @@ SymbolBody::SymbolBody(Kind K, StringRefZ Name, bool IsLocal, uint8_t StOther, uint8_t Type) : SymbolKind(K), NeedsCopyOrPltAddr(false), IsLocal(IsLocal), IsInGlobalMipsGot(false), Is32BitMipsGot(false), IsInIplt(false), - IsInIgot(false), Type(Type), StOther(StOther), Name(Name) {} + IsInIgot(false), CopyIsInBssRelRo(false), Type(Type), StOther(StOther), + Name(Name) {} // 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. @@ -245,6 +246,12 @@ Undefined<ELFT>::Undefined(StringRefZ Name, bool IsLocal, uint8_t StOther, this->File = File; } +template <typename ELFT> +OutputSection<ELFT> *SharedSymbol<ELFT>::getBssSectionForCopy() const { + assert(needsCopy()); + return CopyIsInBssRelRo ? Out<ELFT>::BssRelRo : Out<ELFT>::Bss; +} + DefinedCommon::DefinedCommon(StringRef Name, uint64_t Size, uint64_t Alignment, uint8_t StOther, uint8_t Type, InputFile *File) : Defined(SymbolBody::DefinedCommonKind, Name, /*IsLocal=*/false, StOther, @@ -287,10 +294,22 @@ InputFile *LazyObject::fetch() { return createObjectFile(MBRef); } -bool Symbol::includeInDynsym() const { +uint8_t Symbol::computeBinding() const { + if (Config->Relocatable) + return Binding; if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED) + return STB_LOCAL; + if (VersionId == VER_NDX_LOCAL && !body()->isUndefined()) + return STB_LOCAL; + if (Config->NoGnuUnique && Binding == STB_GNU_UNIQUE) + return STB_GLOBAL; + return Binding; +} + +bool Symbol::includeInDynsym() const { + if (computeBinding() == STB_LOCAL) return false; - return (ExportDynamic && VersionId != VER_NDX_LOCAL) || body()->isShared() || + return ExportDynamic || body()->isShared() || (body()->isUndefined() && Config->Shared); } @@ -366,6 +385,11 @@ template class elf::Undefined<ELF32BE>; template class elf::Undefined<ELF64LE>; template class elf::Undefined<ELF64BE>; +template class elf::SharedSymbol<ELF32LE>; +template class elf::SharedSymbol<ELF32BE>; +template class elf::SharedSymbol<ELF64LE>; +template class elf::SharedSymbol<ELF64BE>; + template class elf::DefinedRegular<ELF32LE>; template class elf::DefinedRegular<ELF32BE>; template class elf::DefinedRegular<ELF64LE>; |