Remove DefinedCommon::Section.
authorRui Ueyama <ruiu@google.com>
Tue, 2 Aug 2016 01:35:13 +0000 (01:35 +0000)
committerRui Ueyama <ruiu@google.com>
Tue, 2 Aug 2016 01:35:13 +0000 (01:35 +0000)
Since CommonInputSection is a singleton class, we don't need
to store pointers to all DefinedCommon symbols.

llvm-svn: 277410

lld/ELF/InputSection.cpp
lld/ELF/OutputSections.cpp
lld/ELF/Symbols.cpp
lld/ELF/Symbols.h

index 28caacb..baa2e91 100644 (file)
@@ -687,7 +687,6 @@ CommonInputSection<ELFT>::CommonInputSection(
 
     // Compute symbol offset relative to beginning of input section.
     Sym->Offset = Hdr.sh_size;
-    Sym->Section = this;
     Hdr.sh_size += Sym->Size;
   }
 }
index 2b409ff..bf065d3 100644 (file)
@@ -1448,7 +1448,7 @@ SymbolTableSection<ELFT>::getOutputSection(SymbolBody *Sym) {
     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;
index 6d7e797..b1056f8 100644 (file)
@@ -63,10 +63,10 @@ static typename ELFT::uint getSymVA(const SymbolBody &Body,
       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)
index f8b5f46..a1170f4 100644 (file)
@@ -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.