Reduce sizeof(Symbol) from 104 bytes to 88 bytes.
authorRui Ueyama <ruiu@google.com>
Sat, 28 Oct 2017 22:18:17 +0000 (22:18 +0000)
committerRui Ueyama <ruiu@google.com>
Sat, 28 Oct 2017 22:18:17 +0000 (22:18 +0000)
Finding aliases for shared symbols doesn't need st_shndx because
we can just compare st_value.

llvm-svn: 316848

lld/ELF/Relocations.cpp
lld/ELF/SymbolTable.cpp
lld/ELF/Symbols.h

index a6af92a..92bd9bc 100644 (file)
@@ -469,7 +469,7 @@ static std::vector<SharedSymbol *> getSymbolsAt(SharedSymbol *SS) {
 
   std::vector<SharedSymbol *> Ret;
   for (const Elf_Sym &S : File->getGlobalELFSyms()) {
-    if (S.st_shndx != SS->Shndx || S.st_value != SS->Value)
+    if (S.st_shndx == 0 || S.st_value != SS->Value)
       continue;
     StringRef Name = check(S.getName(File->getStringTable()));
     SymbolBody *Sym = Symtab->find(Name);
index 34cd2f8..9f64746 100644 (file)
@@ -517,8 +517,7 @@ void SymbolTable::addShared(StringRef Name, SharedFile<ELFT> *File,
   if (WasInserted || ((Body->isUndefined() || Body->isLazy()) &&
                       Body->getVisibility() == STV_DEFAULT)) {
     replaceBody<SharedSymbol>(S, File, Name, Sym.st_other, Sym.getType(),
-                              Sym.st_value, Sym.st_size, Alignment,
-                              Sym.st_shndx, Verdef);
+                              Sym.st_value, Sym.st_size, Alignment, Verdef);
     if (!S->isWeak())
       File->IsUsed = true;
   }
index 7fb9852..0970354 100644 (file)
@@ -219,11 +219,9 @@ public:
   static bool classof(const SymbolBody *S) { return S->kind() == SharedKind; }
 
   SharedSymbol(StringRef Name, uint8_t StOther, uint8_t Type, uint64_t Value,
-               uint64_t Size, uint32_t Alignment, uint64_t Shndx,
-               const void *Verdef)
+               uint64_t Size, uint32_t Alignment, const void *Verdef)
       : Defined(SharedKind, Name, /*IsLocal=*/false, StOther, Type),
-        Verdef(Verdef), Value(Value), Size(Size), Shndx(Shndx),
-        Alignment(Alignment) {
+        Verdef(Verdef), Value(Value), Size(Size), Alignment(Alignment) {
     // GNU ifunc is a mechanism to allow user-supplied functions to
     // resolve PLT slot values at load-time. This is contrary to the
     // regualr symbol resolution scheme in which symbols are resolved just
@@ -257,8 +255,7 @@ public:
   InputSection *CopyRelSec = nullptr;
 
   uint64_t Value; // st_value
-  uint64_t Size;  // st_size
-  uint64_t Shndx; // st_shndx
+  uint32_t Size;  // st_size
   uint32_t Alignment;
 };