Pass Binding instead of IsWeak to addBitcode.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 30 Aug 2016 20:53:26 +0000 (20:53 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 30 Aug 2016 20:53:26 +0000 (20:53 +0000)
We were computing the binding on both the caller and callee.

llvm-svn: 280156

lld/ELF/InputFiles.cpp
lld/ELF/SymbolTable.cpp
lld/ELF/SymbolTable.h

index 0127464..e0fd5f4 100644 (file)
@@ -635,8 +635,7 @@ Symbol *BitcodeFile::createSymbol(const DenseSet<const Comdat *> &KeptComdats,
   StringRef NameRef = Saver.save(StringRef(Name));
 
   uint32_t Flags = Sym.getFlags();
-  bool IsWeak = Flags & BasicSymbolRef::SF_Weak;
-  uint32_t Binding = IsWeak ? STB_WEAK : STB_GLOBAL;
+  uint32_t Binding = (Flags & BasicSymbolRef::SF_Weak) ? STB_WEAK : STB_GLOBAL;
 
   uint8_t Type = STT_NOTYPE;
   bool CanOmitFromDynSym = false;
@@ -681,7 +680,7 @@ Symbol *BitcodeFile::createSymbol(const DenseSet<const Comdat *> &KeptComdats,
                                       Binding, Visibility, STT_OBJECT,
                                       HasUnnamedAddr, this);
   }
-  return Symtab<ELFT>::X->addBitcode(NameRef, IsWeak, Visibility, Type,
+  return Symtab<ELFT>::X->addBitcode(NameRef, Binding, Visibility, Type,
                                      CanOmitFromDynSym, HasUnnamedAddr, this);
 }
 
index 49c31ad..e701d92 100644 (file)
@@ -460,7 +460,7 @@ void SymbolTable<ELFT>::addShared(SharedFile<ELFT> *F, StringRef Name,
 }
 
 template <class ELFT>
-Symbol *SymbolTable<ELFT>::addBitcode(StringRef Name, bool IsWeak,
+Symbol *SymbolTable<ELFT>::addBitcode(StringRef Name, uint8_t Binding,
                                       uint8_t StOther, uint8_t Type,
                                       bool CanOmitFromDynSym,
                                       bool HasUnnamedAddr, BitcodeFile *F) {
@@ -469,8 +469,7 @@ Symbol *SymbolTable<ELFT>::addBitcode(StringRef Name, bool IsWeak,
   std::tie(S, WasInserted) =
       insert(Name, Type, StOther & 3, CanOmitFromDynSym, HasUnnamedAddr,
              /*IsUsedInRegularObj*/ false, F);
-  int Cmp = compareDefinedNonCommon<ELFT>(S, WasInserted,
-                                          IsWeak ? STB_WEAK : STB_GLOBAL);
+  int Cmp = compareDefinedNonCommon<ELFT>(S, WasInserted, Binding);
   if (Cmp > 0)
     replaceBody<DefinedBitcode>(S, Name, StOther, Type, F);
   else if (Cmp == 0)
index 0af04a7..e4911b3 100644 (file)
@@ -72,8 +72,8 @@ public:
 
   void addLazyArchive(ArchiveFile *F, const llvm::object::Archive::Symbol S);
   void addLazyObject(StringRef Name, LazyObjectFile &Obj);
-  Symbol *addBitcode(StringRef Name, bool IsWeak, uint8_t StOther, uint8_t Type,
-                     bool CanOmitFromDynSym, bool HasUnnamedAddr,
+  Symbol *addBitcode(StringRef Name, uint8_t Binding, uint8_t StOther,
+                     uint8_t Type, bool CanOmitFromDynSym, bool HasUnnamedAddr,
                      BitcodeFile *File);
 
   Symbol *addCommon(StringRef N, uint64_t Size, uint64_t Alignment,