[lld] r248868 - ELF2: Advance the buffer pointers right after we use them.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 17:54:29 PDT 2015


Author: ruiu
Date: Tue Sep 29 19:54:29 2015
New Revision: 248868

URL: http://llvm.org/viewvc/llvm-project?rev=248868&view=rev
Log:
ELF2: Advance the buffer pointers right after we use them.

So that it is clear that we are incrementing the pointers for sure. NFC.

Modified:
    lld/trunk/ELF/OutputSections.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=248868&r1=248867&r2=248868&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Sep 29 19:54:29 2015
@@ -410,10 +410,11 @@ void SymbolTableSection<ELFT>::writeLoca
     auto &File = cast<ObjectFile<ELFT>>(*FileB);
     Elf_Sym_Range Syms = File.getLocalSymbols();
     for (const Elf_Sym &Sym : Syms) {
-      auto *ESym = reinterpret_cast<Elf_Sym *>(Buf);
       ErrorOr<StringRef> SymName = Sym.getName(File.getStringTable());
       if (SymName && !shouldKeepInSymtab(*SymName))
         continue;
+      auto *ESym = reinterpret_cast<Elf_Sym *>(Buf);
+      Buf += sizeof(*ESym);
       ESym->st_name = (SymName) ? StrTabSec.getFileOff(*SymName) : 0;
       ESym->st_size = Sym.st_size;
       ESym->setBindingAndType(Sym.getBinding(), Sym.getType());
@@ -432,7 +433,6 @@ void SymbolTableSection<ELFT>::writeLoca
         VA += Out->getVA() + Section->getOutputSectionOff();
       }
       ESym->st_value = VA;
-      Buf += sizeof(Elf_Sym);
     }
   }
 }
@@ -453,6 +453,7 @@ void SymbolTableSection<ELFT>::writeGlob
     const auto &EBody = *cast<ELFSymbolBody<ELFT>>(Body);
     const Elf_Sym &InputSym = EBody.Sym;
     auto *ESym = reinterpret_cast<Elf_Sym *>(Buf);
+    Buf += sizeof(*ESym);
     ESym->st_name = StrTabSec.getFileOff(Name);
 
     const OutputSection<ELFT> *Out = nullptr;
@@ -491,8 +492,6 @@ void SymbolTableSection<ELFT>::writeGlob
 
     if (Out)
       ESym->st_shndx = Out->getSectionIndex();
-
-    Buf += sizeof(Elf_Sym);
   }
 }
 




More information about the llvm-commits mailing list