[lld] r259613 - Define SymbolBody::getSize instead of getSymSize(SymbolBody&). NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 2 16:12:24 PST 2016


Author: ruiu
Date: Tue Feb  2 18:12:24 2016
New Revision: 259613

URL: http://llvm.org/viewvc/llvm-project?rev=259613&view=rev
Log:
Define SymbolBody::getSize instead of getSymSize(SymbolBody&). NFC.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/Symbols.cpp
    lld/trunk/ELF/Symbols.h

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=259613&r1=259612&r2=259613&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Feb  2 18:12:24 2016
@@ -130,14 +130,6 @@ InputSectionBase<ELFT>::findMipsPairedRe
 }
 
 template <class ELFT>
-static typename llvm::object::ELFFile<ELFT>::uintX_t
-getSymSize(SymbolBody &Body) {
-  if (auto *SS = dyn_cast<DefinedElf<ELFT>>(&Body))
-    return SS->Sym.st_size;
-  return 0;
-}
-
-template <class ELFT>
 template <bool isRela>
 void InputSectionBase<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd,
                                       RelIteratorRange<isRela> Rels) {
@@ -243,7 +235,7 @@ void InputSectionBase<ELFT>::relocate(ui
       else if (Type == R_MIPS_LO16 && Body == Config->MipsGpDisp)
         SymVA = getMipsGpAddr<ELFT>() - AddrLoc + 4;
     }
-    uintX_t Size = getSymSize<ELFT>(*Body);
+    uintX_t Size = Body->getSize<ELFT>();
     Target->relocateOne(BufLoc, BufEnd, Type, AddrLoc, SymVA + A, Size + A,
                         findMipsPairedReloc(Buf, SymIndex, Type, NextRelocs));
   }

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=259613&r1=259612&r2=259613&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Tue Feb  2 18:12:24 2016
@@ -89,6 +89,13 @@ typename ELFFile<ELFT>::uintX_t SymbolBo
          PltIndex * Target->PltEntrySize;
 }
 
+template <class ELFT>
+typename ELFFile<ELFT>::uintX_t SymbolBody::getSize() const {
+  if (auto *B = dyn_cast<DefinedElf<ELFT>>(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 g
 template uint64_t SymbolBody::template getPltVA<ELF64LE>() const;
 template uint64_t SymbolBody::template getPltVA<ELF64BE>() const;
 
+template uint32_t SymbolBody::template getSize<ELF32LE>() const;
+template uint32_t SymbolBody::template getSize<ELF32BE>() const;
+template uint64_t SymbolBody::template getSize<ELF64LE>() const;
+template uint64_t SymbolBody::template getSize<ELF64BE>() const;
+
 template int SymbolBody::compare<ELF32LE>(SymbolBody *Other);
 template int SymbolBody::compare<ELF32BE>(SymbolBody *Other);
 template int SymbolBody::compare<ELF64LE>(SymbolBody *Other);

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=259613&r1=259612&r2=259613&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Tue Feb  2 18:12:24 2016
@@ -110,6 +110,8 @@ public:
   typename llvm::object::ELFFile<ELFT>::uintX_t getGotPltVA() const;
   template <class ELFT>
   typename llvm::object::ELFFile<ELFT>::uintX_t getPltVA() const;
+  template <class ELFT>
+  typename llvm::object::ELFFile<ELFT>::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




More information about the llvm-commits mailing list