[lld] r284699 - Rename variables so that they are more in line with rest of the code.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 19 23:34:04 PDT 2016


Author: ruiu
Date: Thu Oct 20 01:34:03 2016
New Revision: 284699

URL: http://llvm.org/viewvc/llvm-project?rev=284699&view=rev
Log:
Rename variables so that they are more in line with rest of the code.

Modified:
    lld/trunk/ELF/ELFCreator.cpp
    lld/trunk/ELF/ELFCreator.h
    lld/trunk/ELF/InputFiles.cpp

Modified: lld/trunk/ELF/ELFCreator.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ELFCreator.cpp?rev=284699&r1=284698&r2=284699&view=diff
==============================================================================
--- lld/trunk/ELF/ELFCreator.cpp (original)
+++ lld/trunk/ELF/ELFCreator.cpp Thu Oct 20 01:34:03 2016
@@ -29,15 +29,10 @@ ELFCreator<ELFT>::ELFCreator(std::uint16
                                 ? ELFDATA2LSB
                                 : ELFDATA2MSB;
   Header.e_ident[EI_VERSION] = EV_CURRENT;
-  Header.e_ident[EI_OSABI] = 0;
   Header.e_type = Type;
   Header.e_machine = Machine;
   Header.e_version = EV_CURRENT;
-  Header.e_entry = 0;
-  Header.e_phoff = 0;
-  Header.e_flags = 0;
   Header.e_ehsize = sizeof(Elf_Ehdr);
-  Header.e_phnum = 0;
   Header.e_shentsize = sizeof(Elf_Shdr);
   Header.e_shstrndx = 1;
 
@@ -61,7 +56,7 @@ template <class ELFT>
 typename ELFCreator<ELFT>::Section
 ELFCreator<ELFT>::addSection(StringRef Name) {
   auto Shdr = new (Alloc) Elf_Shdr{};
-  Shdr->sh_name = SecHdrStrTabBuilder.add(Name);
+  Shdr->sh_name = ShStrTabBuilder.add(Name);
   Sections.push_back(Shdr);
   return {Shdr, Sections.size()};
 }
@@ -70,18 +65,18 @@ template <class ELFT>
 typename ELFCreator<ELFT>::Symbol ELFCreator<ELFT>::addSymbol(StringRef Name) {
   auto Sym = new (Alloc) Elf_Sym{};
   Sym->st_name = StrTabBuilder.add(Name);
-  StaticSymbols.push_back(Sym);
-  return {Sym, StaticSymbols.size()};
+  Symbols.push_back(Sym);
+  return {Sym, Symbols.size()};
 }
 
 template <class ELFT> size_t ELFCreator<ELFT>::layout() {
-  SecHdrStrTabBuilder.finalizeInOrder();
-  ShStrTab->sh_size = SecHdrStrTabBuilder.getSize();
+  ShStrTabBuilder.finalizeInOrder();
+  ShStrTab->sh_size = ShStrTabBuilder.getSize();
 
   StrTabBuilder.finalizeInOrder();
   StrTab->sh_size = StrTabBuilder.getSize();
 
-  SymTab->sh_size = (StaticSymbols.size() + 1) * sizeof(Elf_Sym);
+  SymTab->sh_size = (Symbols.size() + 1) * sizeof(Elf_Sym);
 
   uintX_t Offset = sizeof(Elf_Ehdr);
   for (Elf_Shdr *Sec : Sections) {
@@ -98,15 +93,15 @@ template <class ELFT> size_t ELFCreator<
   return Offset;
 }
 
-template <class ELFT> void ELFCreator<ELFT>::write(uint8_t *Out) {
+template <class ELFT> void ELFCreator<ELFT>::writeTo(uint8_t *Out) {
   std::memcpy(Out, &Header, sizeof(Elf_Ehdr));
-  SecHdrStrTabBuilder.write(Out + ShStrTab->sh_offset);
+  ShStrTabBuilder.write(Out + ShStrTab->sh_offset);
   StrTabBuilder.write(Out + StrTab->sh_offset);
 
   Elf_Sym *Sym = reinterpret_cast<Elf_Sym *>(Out + SymTab->sh_offset);
   // Skip null.
   ++Sym;
-  for (Elf_Sym *S : StaticSymbols)
+  for (Elf_Sym *S : Symbols)
     *Sym++ = *S;
 
   Elf_Shdr *Shdr = reinterpret_cast<Elf_Shdr *>(Out + Header.e_shoff);

Modified: lld/trunk/ELF/ELFCreator.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ELFCreator.h?rev=284699&r1=284698&r2=284699&view=diff
==============================================================================
--- lld/trunk/ELF/ELFCreator.h (original)
+++ lld/trunk/ELF/ELFCreator.h Thu Oct 20 01:34:03 2016
@@ -39,13 +39,13 @@ public:
   Section addSection(StringRef Name);
   Symbol addSymbol(StringRef Name);
   size_t layout();
-  void write(uint8_t *Out);
+  void writeTo(uint8_t *Out);
 
 private:
-  Elf_Ehdr Header;
+  Elf_Ehdr Header = {};
   std::vector<Elf_Shdr *> Sections;
-  std::vector<Elf_Sym *> StaticSymbols;
-  llvm::StringTableBuilder SecHdrStrTabBuilder{llvm::StringTableBuilder::ELF};
+  std::vector<Elf_Sym *> Symbols;
+  llvm::StringTableBuilder ShStrTabBuilder{llvm::StringTableBuilder::ELF};
   llvm::StringTableBuilder StrTabBuilder{llvm::StringTableBuilder::ELF};
   llvm::BumpPtrAllocator Alloc;
   Elf_Shdr *ShStrTab;

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=284699&r1=284698&r2=284699&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Thu Oct 20 01:34:03 2016
@@ -782,8 +782,8 @@ static InputFile *createELFFile(MemoryBu
 // so that we can link it as a regular ELF file.
 template <class ELFT> InputFile *BinaryFile::createELF() {
   // Fill the ELF file header.
-  ELFCreator<ELFT> ELF(ET_REL, Config->EMachine);
-  auto DataSec = ELF.addSection(".data");
+  ELFCreator<ELFT> File(ET_REL, Config->EMachine);
+  auto DataSec = File.addSection(".data");
   DataSec.Header->sh_flags = SHF_ALLOC;
   DataSec.Header->sh_size = MB.getBufferSize();
   DataSec.Header->sh_type = SHT_PROGBITS;
@@ -796,26 +796,26 @@ template <class ELFT> InputFile *BinaryF
 
   // Add _start, _end and _size symbols.
   std::string StartSym = "_binary_" + Filepath + "_start";
-  auto SSym = ELF.addSymbol(StartSym);
+  auto SSym = File.addSymbol(StartSym);
   SSym.Sym->setBindingAndType(STB_GLOBAL, STT_OBJECT);
   SSym.Sym->st_shndx = DataSec.Index;
 
   std::string EndSym = "_binary_" + Filepath + "_end";
-  auto ESym = ELF.addSymbol(EndSym);
+  auto ESym = File.addSymbol(EndSym);
   ESym.Sym->setBindingAndType(STB_GLOBAL, STT_OBJECT);
   ESym.Sym->st_shndx = DataSec.Index;
   ESym.Sym->st_value = MB.getBufferSize();
 
   std::string SizeSym = "_binary_" + Filepath + "_size";
-  auto SZSym = ELF.addSymbol(SizeSym);
+  auto SZSym = File.addSymbol(SizeSym);
   SZSym.Sym->setBindingAndType(STB_GLOBAL, STT_OBJECT);
   SZSym.Sym->st_shndx = SHN_ABS;
   SZSym.Sym->st_value = MB.getBufferSize();
 
   // Fix the ELF file layout and write it down to ELFData uint8_t vector.
-  size_t Size = ELF.layout();
+  size_t Size = File.layout();
   ELFData.resize(Size);
-  ELF.write(ELFData.data());
+  File.writeTo(ELFData.data());
 
   // Fill .data section with actual data.
   std::copy(MB.getBufferStart(), MB.getBufferEnd(),




More information about the llvm-commits mailing list