summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Symbols.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/Symbols.cpp')
-rw-r--r--lld/ELF/Symbols.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 0a4805c7be4..6d7e7978c71 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -63,8 +63,10 @@ static typename ELFT::uint getSymVA(const SymbolBody &Body,
return VA - Out<ELFT>::TlsPhdr->p_vaddr;
return VA;
}
- case SymbolBody::DefinedCommonKind:
- return Out<ELFT>::Bss->getVA() + cast<DefinedCommon>(Body).OffsetInBss;
+ case SymbolBody::DefinedCommonKind: {
+ auto &D = cast<DefinedCommon<ELFT>>(Body);
+ return D.Section->OutSec->getVA() + D.Section->OutSecOff + D.Offset;
+ }
case SymbolBody::SharedKind: {
auto &SS = cast<SharedSymbol<ELFT>>(Body);
if (!SS.NeedsCopyOrPltAddr)
@@ -175,7 +177,7 @@ template <class ELFT> typename ELFT::uint SymbolBody::getThunkVA() const {
}
template <class ELFT> typename ELFT::uint SymbolBody::getSize() const {
- if (const auto *C = dyn_cast<DefinedCommon>(this))
+ if (const auto *C = dyn_cast<DefinedCommon<ELFT>>(this))
return C->Size;
if (const auto *DR = dyn_cast<DefinedRegular<ELFT>>(this))
return DR->Size;
@@ -218,8 +220,10 @@ DefinedSynthetic<ELFT>::DefinedSynthetic(StringRef N, uintX_t Value,
: Defined(SymbolBody::DefinedSyntheticKind, N, STV_HIDDEN, 0 /* Type */),
Value(Value), Section(Section) {}
-DefinedCommon::DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment,
- uint8_t StOther, uint8_t Type, InputFile *File)
+template <class ELFT>
+DefinedCommon<ELFT>::DefinedCommon(StringRef N, uint64_t Size,
+ uint64_t Alignment, uint8_t StOther,
+ uint8_t Type, InputFile *File)
: Defined(SymbolBody::DefinedCommonKind, N, StOther, Type),
Alignment(Alignment), Size(Size) {
this->File = File;
@@ -329,3 +333,8 @@ template class elf::DefinedSynthetic<ELF32LE>;
template class elf::DefinedSynthetic<ELF32BE>;
template class elf::DefinedSynthetic<ELF64LE>;
template class elf::DefinedSynthetic<ELF64BE>;
+
+template class elf::DefinedCommon<ELF32LE>;
+template class elf::DefinedCommon<ELF32BE>;
+template class elf::DefinedCommon<ELF64LE>;
+template class elf::DefinedCommon<ELF64BE>;
OpenPOWER on IntegriCloud