diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index d5ff181b4f9e..67432dd30b62 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -129,14 +129,6 @@ InputSectionBase::findMipsPairedReloc(uint8_t *Buf, uint32_t SymIndex, return nullptr; } -template -static typename llvm::object::ELFFile::uintX_t -getSymSize(SymbolBody &Body) { - if (auto *SS = dyn_cast>(&Body)) - return SS->Sym.st_size; - return 0; -} - template template void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd, @@ -243,7 +235,7 @@ void InputSectionBase::relocate(uint8_t *Buf, uint8_t *BufEnd, else if (Type == R_MIPS_LO16 && Body == Config->MipsGpDisp) SymVA = getMipsGpAddr() - AddrLoc + 4; } - uintX_t Size = getSymSize(*Body); + uintX_t Size = Body->getSize(); Target->relocateOne(BufLoc, BufEnd, Type, AddrLoc, SymVA + A, Size + A, findMipsPairedReloc(Buf, SymIndex, Type, NextRelocs)); } diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 30b086f68db8..dec844277c11 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -89,6 +89,13 @@ typename ELFFile::uintX_t SymbolBody::getPltVA() const { PltIndex * Target->PltEntrySize; } +template +typename ELFFile::uintX_t SymbolBody::getSize() const { + if (auto *B = dyn_cast>(this)) + return B->Sym.st_size; + return 0; +} + static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) { if (VA == STV_DEFAULT) return VB; @@ -252,6 +259,11 @@ template uint32_t SymbolBody::template getPltVA() const; template uint64_t SymbolBody::template getPltVA() const; template uint64_t SymbolBody::template getPltVA() const; +template uint32_t SymbolBody::template getSize() const; +template uint32_t SymbolBody::template getSize() const; +template uint64_t SymbolBody::template getSize() const; +template uint64_t SymbolBody::template getSize() const; + template int SymbolBody::compare(SymbolBody *Other); template int SymbolBody::compare(SymbolBody *Other); template int SymbolBody::compare(SymbolBody *Other); diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index af16124a7635..1d67d3b31c58 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -110,6 +110,8 @@ public: typename llvm::object::ELFFile::uintX_t getGotPltVA() const; template typename llvm::object::ELFFile::uintX_t getPltVA() const; + template + typename llvm::object::ELFFile::uintX_t getSize() const; // A SymbolBody has a backreference to a Symbol. Originally they are // doubly-linked. A backreference will never change. But the pointer