[lld] r267826 - Remove Size from Undefined symbol.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 17:26:55 PDT 2016


Author: ruiu
Date: Wed Apr 27 19:26:54 2016
New Revision: 267826

URL: http://llvm.org/viewvc/llvm-project?rev=267826&view=rev
Log:
Remove Size from Undefined symbol.

There seems to be no reason to keep st_size of undefined symbols.
This patch removes the member for it. This patch will change outputs
in cases that undefined symbols are copied to output, but I think
this is unimportant.

Differential Revision: http://reviews.llvm.org/D19574

Modified:
    lld/trunk/ELF/InputFiles.cpp
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/Symbols.cpp
    lld/trunk/ELF/Symbols.h
    lld/trunk/test/ELF/resolution.s

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=267826&r1=267825&r2=267826&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Wed Apr 27 19:26:54 2016
@@ -316,8 +316,7 @@ SymbolBody *elf::ObjectFile<ELFT>::creat
   InputSectionBase<ELFT> *Sec = getSection(*Sym);
   if (Binding == STB_LOCAL) {
     if (Sym->st_shndx == SHN_UNDEF)
-      return new (Alloc)
-          Undefined(Sym->st_name, Sym->st_other, Sym->getType(), Sym->st_size);
+      return new (Alloc) Undefined(Sym->st_name, Sym->st_other, Sym->getType());
     return new (Alloc) DefinedRegular<ELFT>(*Sym, Sec);
   }
 
@@ -325,9 +324,8 @@ SymbolBody *elf::ObjectFile<ELFT>::creat
 
   switch (Sym->st_shndx) {
   case SHN_UNDEF:
-    return new (Alloc)
-        Undefined(Name, Binding, Sym->st_other, Sym->getType(), Sym->st_size,
-                  /*IsBitcode*/ false);
+    return new (Alloc) Undefined(Name, Binding, Sym->st_other, Sym->getType(),
+                                 /*IsBitcode*/ false);
   case SHN_COMMON:
     return new (Alloc) DefinedCommon(Name, Sym->st_size, Sym->st_value, Binding,
                                      Sym->st_other, Sym->getType());
@@ -340,9 +338,8 @@ SymbolBody *elf::ObjectFile<ELFT>::creat
   case STB_WEAK:
   case STB_GNU_UNIQUE:
     if (Sec == &InputSection<ELFT>::Discarded)
-      return new (Alloc)
-          Undefined(Name, Binding, Sym->st_other, Sym->getType(), Sym->st_size,
-                    /*IsBitcode*/ false);
+      return new (Alloc) Undefined(Name, Binding, Sym->st_other, Sym->getType(),
+                                   /*IsBitcode*/ false);
     return new (Alloc) DefinedRegular<ELFT>(Name, *Sym, Sec);
   }
 }
@@ -548,14 +545,14 @@ BitcodeFile::createBody(const DenseSet<c
     if (const Comdat *C = GV->getComdat())
       if (!KeptComdats.count(C)) {
         Body = new (Alloc) Undefined(NameRef, Binding, Visibility, /*Type*/ 0,
-                                     /*Size*/ 0, /*IsBitcode*/ true);
+                                     /*IsBitcode*/ true);
         return Body;
       }
 
   const Module &M = Obj.getModule();
   if (Flags & BasicSymbolRef::SF_Undefined)
     return new (Alloc) Undefined(NameRef, Binding, Visibility, /*Type*/ 0,
-                                 /*Size*/ 0, /*IsBitcode*/ true);
+                                 /*IsBitcode*/ true);
   if (Flags & BasicSymbolRef::SF_Common) {
     // FIXME: Set SF_Common flag correctly for module asm symbols, and expose
     // size and alignment.

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=267826&r1=267825&r2=267826&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Apr 27 19:26:54 2016
@@ -150,9 +150,8 @@ template <class ELFT> void SymbolTable<E
 // Add an undefined symbol.
 template <class ELFT>
 SymbolBody *SymbolTable<ELFT>::addUndefined(StringRef Name) {
-  auto *Sym = new (Alloc)
-      Undefined(Name, STB_GLOBAL, STV_DEFAULT, /*Type*/ 0, /*Size*/ 0,
-                /*IsBitcode*/ false);
+  auto *Sym = new (Alloc) Undefined(Name, STB_GLOBAL, STV_DEFAULT, /*Type*/ 0,
+                                    /*IsBitcode*/ false);
   resolve(Sym);
   return Sym;
 }

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=267826&r1=267825&r2=267826&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Wed Apr 27 19:26:54 2016
@@ -174,8 +174,6 @@ template <class ELFT> typename ELFT::uin
     return DR->Size;
   if (const auto *S = dyn_cast<SharedSymbol<ELFT>>(this))
     return S->Sym.st_size;
-  if (const auto *U = dyn_cast<Undefined>(this))
-    return U->Size;
   return 0;
 }
 
@@ -232,16 +230,13 @@ bool DefinedBitcode::classof(const Symbo
 }
 
 Undefined::Undefined(StringRef Name, uint8_t Binding, uint8_t StOther,
-                     uint8_t Type, uint64_t Size, bool IsBitcode)
-    : SymbolBody(SymbolBody::UndefinedKind, Name, Binding, StOther, Type),
-      Size(Size) {
+                     uint8_t Type, bool IsBitcode)
+    : SymbolBody(SymbolBody::UndefinedKind, Name, Binding, StOther, Type) {
   this->IsUndefinedBitcode = IsBitcode;
 }
 
-Undefined::Undefined(uint32_t NameOffset, uint8_t StOther, uint8_t Type,
-                     uint64_t Size)
-    : SymbolBody(SymbolBody::UndefinedKind, NameOffset, StOther, Type),
-      Size(Size) {
+Undefined::Undefined(uint32_t NameOffset, uint8_t StOther, uint8_t Type)
+    : SymbolBody(SymbolBody::UndefinedKind, NameOffset, StOther, Type) {
   this->IsUndefinedBitcode = false;
 }
 

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=267826&r1=267825&r2=267826&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Wed Apr 27 19:26:54 2016
@@ -312,10 +312,8 @@ public:
 class Undefined : public SymbolBody {
 public:
   Undefined(StringRef Name, uint8_t Binding, uint8_t StOther, uint8_t Type,
-            uint64_t Size, bool IsBitcode);
-  Undefined(uint32_t NameOffset, uint8_t StOther, uint8_t Type, uint64_t Size);
-
-  uint64_t Size;
+            bool IsBitcode);
+  Undefined(uint32_t NameOffset, uint8_t StOther, uint8_t Type);
 
   static bool classof(const SymbolBody *S) {
     return S->kind() == UndefinedKind;

Modified: lld/trunk/test/ELF/resolution.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/resolution.s?rev=267826&r1=267825&r2=267826&view=diff
==============================================================================
--- lld/trunk/test/ELF/resolution.s (original)
+++ lld/trunk/test/ELF/resolution.s Wed Apr 27 19:26:54 2016
@@ -309,7 +309,7 @@
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: UndefWeak_with_UndefWeak
 // CHECK-NEXT:     Value: 0x0
-// CHECK-NEXT:     Size: 15
+// CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Weak
 // CHECK-NEXT:     Type: None
 // CHECK-NEXT:     Other: 0




More information about the llvm-commits mailing list