[lld] r277410 - Remove DefinedCommon::Section.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 1 18:35:13 PDT 2016


Author: ruiu
Date: Mon Aug  1 20:35:13 2016
New Revision: 277410

URL: http://llvm.org/viewvc/llvm-project?rev=277410&view=rev
Log:
Remove DefinedCommon::Section.

Since CommonInputSection is a singleton class, we don't need
to store pointers to all DefinedCommon symbols.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/OutputSections.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=277410&r1=277409&r2=277410&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Mon Aug  1 20:35:13 2016
@@ -687,7 +687,6 @@ CommonInputSection<ELFT>::CommonInputSec
 
     // Compute symbol offset relative to beginning of input section.
     Sym->Offset = Hdr.sh_size;
-    Sym->Section = this;
     Hdr.sh_size += Sym->Size;
   }
 }

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=277410&r1=277409&r2=277410&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon Aug  1 20:35:13 2016
@@ -1448,7 +1448,7 @@ SymbolTableSection<ELFT>::getOutputSecti
     break;
   }
   case SymbolBody::DefinedCommonKind:
-    return cast<DefinedCommon<ELFT>>(Sym)->Section->OutSec;
+    return CommonInputSection<ELFT>::X->OutSec;
   case SymbolBody::SharedKind:
     if (cast<SharedSymbol<ELFT>>(Sym)->needsCopy())
       return Out<ELFT>::Bss;

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=277410&r1=277409&r2=277410&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Mon Aug  1 20:35:13 2016
@@ -63,10 +63,10 @@ static typename ELFT::uint getSymVA(cons
       return VA - Out<ELFT>::TlsPhdr->p_vaddr;
     return VA;
   }
-  case SymbolBody::DefinedCommonKind: {
-    auto &D = cast<DefinedCommon<ELFT>>(Body);
-    return D.Section->OutSec->getVA() + D.Section->OutSecOff + D.Offset;
-  }
+  case SymbolBody::DefinedCommonKind:
+    return CommonInputSection<ELFT>::X->OutSec->getVA() +
+           CommonInputSection<ELFT>::X->OutSecOff +
+           cast<DefinedCommon<ELFT>>(Body).Offset;
   case SymbolBody::SharedKind: {
     auto &SS = cast<SharedSymbol<ELFT>>(Body);
     if (!SS.NeedsCopyOrPltAddr)

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=277410&r1=277409&r2=277410&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Mon Aug  1 20:35:13 2016
@@ -184,9 +184,6 @@ public:
   uint64_t Alignment;
 
   uint64_t Size;
-
-  // Virtual input section for common symbols.
-  CommonInputSection<ELFT> *Section;
 };
 
 // Regular defined symbols read from object file symbol tables.




More information about the llvm-commits mailing list