]> granicus.if.org Git - llvm/commitdiff
[llvm-objcopy] - Fix for "Bug 41775 - SymbolTableSection::addSymbol - shadow variable...
authorGeorge Rimar <grimar@accesssoftek.com>
Wed, 8 May 2019 07:31:05 +0000 (07:31 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Wed, 8 May 2019 07:31:05 +0000 (07:31 +0000)
This is a fix for https://bugs.llvm.org/show_bug.cgi?id=41775,

Problem is in the final line:
Size += this->EntrySize;

I checked that we do not actually need it in this place,
since we always call removeSectionReferences which
calls removeSymbols which updates the Size.

But it worth to keep it, that allows to relax the dependencies.

Differential revision: https://reviews.llvm.org/D61636

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360227 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-objcopy/ELF/Object.cpp
tools/llvm-objcopy/ELF/Object.h

index 60163b6eed38bf1e0bf21d2245edd34d07fec72c..d66948a0f46729b3f78b70029a044f7c8eac0837 100644 (file)
@@ -402,7 +402,7 @@ void SymbolTableSection::assignIndices() {
 void SymbolTableSection::addSymbol(Twine Name, uint8_t Bind, uint8_t Type,
                                    SectionBase *DefinedIn, uint64_t Value,
                                    uint8_t Visibility, uint16_t Shndx,
-                                   uint64_t Size) {
+                                   uint64_t SymbolSize) {
   Symbol Sym;
   Sym.Name = Name.str();
   Sym.Binding = Bind;
@@ -418,7 +418,7 @@ void SymbolTableSection::addSymbol(Twine Name, uint8_t Bind, uint8_t Type,
   }
   Sym.Value = Value;
   Sym.Visibility = Visibility;
-  Sym.Size = Size;
+  Sym.Size = SymbolSize;
   Sym.Index = Symbols.size();
   Symbols.emplace_back(llvm::make_unique<Symbol>(Sym));
   Size += this->EntrySize;
index 46687dd8b196f0bb2589bab7245a4d4ee4dcbd99..54e72d29aba866999ba6366221f9746a7ae10a55 100644 (file)
@@ -522,7 +522,7 @@ public:
 
   void addSymbol(Twine Name, uint8_t Bind, uint8_t Type, SectionBase *DefinedIn,
                  uint64_t Value, uint8_t Visibility, uint16_t Shndx,
-                 uint64_t Size);
+                 uint64_t SymbolSize);
   void prepareForLayout();
   // An 'empty' symbol table still contains a null symbol.
   bool empty() const { return Symbols.size() == 1; }