[lld] r259250 - Consistenly use sizeof(uintX_t) instead of ELFT::Is64Bits ? 8 : 4.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 29 14:18:57 PST 2016


Author: ruiu
Date: Fri Jan 29 16:18:57 2016
New Revision: 259250

URL: http://llvm.org/viewvc/llvm-project?rev=259250&view=rev
Log:
Consistenly use sizeof(uintX_t) instead of ELFT::Is64Bits ? 8 : 4.

Modified:
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=259250&r1=259249&r2=259250&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Fri Jan 29 16:18:57 2016
@@ -230,7 +230,7 @@ RelocationSection<ELFT>::RelocationSecti
     : OutputSectionBase<ELFT>(Name, IsRela ? SHT_RELA : SHT_REL, SHF_ALLOC),
       IsRela(IsRela) {
   this->Header.sh_entsize = IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);
-  this->Header.sh_addralign = ELFT::Is64Bits ? 8 : 4;
+  this->Header.sh_addralign = sizeof(uintX_t);
 }
 
 // Applies corresponding symbol and type for dynamic tls relocation.
@@ -444,7 +444,7 @@ template <class ELFT>
 GnuHashTableSection<ELFT>::GnuHashTableSection()
     : OutputSectionBase<ELFT>(".gnu.hash", SHT_GNU_HASH, SHF_ALLOC) {
   this->Header.sh_entsize = ELFT::Is64Bits ? 0 : 4;
-  this->Header.sh_addralign = ELFT::Is64Bits ? 8 : 4;
+  this->Header.sh_addralign = sizeof(uintX_t);
 }
 
 template <class ELFT>
@@ -588,7 +588,7 @@ DynamicSection<ELFT>::DynamicSection(Sym
     : OutputSectionBase<ELFT>(".dynamic", SHT_DYNAMIC, SHF_ALLOC | SHF_WRITE),
       SymTab(SymTab) {
   Elf_Shdr &Header = this->Header;
-  Header.sh_addralign = ELFT::Is64Bits ? 8 : 4;
+  Header.sh_addralign = sizeof(uintX_t);
   Header.sh_entsize = ELFT::Is64Bits ? 16 : 8;
 
   // .dynamic section is not writable on MIPS.
@@ -1371,7 +1371,7 @@ SymbolTableSection<ELFT>::SymbolTableSec
                               StrTabSec.isDynamic() ? (uintX_t)SHF_ALLOC : 0),
       StrTabSec(StrTabSec), Table(Table) {
   this->Header.sh_entsize = sizeof(Elf_Sym);
-  this->Header.sh_addralign = ELFT::Is64Bits ? 8 : 4;
+  this->Header.sh_addralign = sizeof(uintX_t);
 }
 
 // Orders symbols according to their positions in the GOT,

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=259250&r1=259249&r2=259250&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Jan 29 16:18:57 2016
@@ -951,8 +951,8 @@ template <class ELFT> void Writer<ELFT>:
     if (Config->EMachine == EM_MIPS && !Config->Shared) {
       Out<ELFT>::MipsRldMap = new OutputSection<ELFT>(".rld_map", SHT_PROGBITS,
                                                       SHF_ALLOC | SHF_WRITE);
-      Out<ELFT>::MipsRldMap->setSize(ELFT::Is64Bits ? 8 : 4);
-      Out<ELFT>::MipsRldMap->updateAlign(ELFT::Is64Bits ? 8 : 4);
+      Out<ELFT>::MipsRldMap->setSize(sizeof(uintX_t));
+      Out<ELFT>::MipsRldMap->updateAlign(sizeof(uintX_t));
       OwningSections.emplace_back(Out<ELFT>::MipsRldMap);
       Add(Out<ELFT>::MipsRldMap);
     }
@@ -1204,7 +1204,7 @@ template <class ELFT> void Writer<ELFT>:
   }
 
   // Add space for section headers.
-  SectionHeaderOff = alignTo(FileOff, ELFT::Is64Bits ? 8 : 4);
+  SectionHeaderOff = alignTo(FileOff, sizeof(uintX_t));
   FileSize = SectionHeaderOff + getNumSections() * sizeof(Elf_Shdr);
 
   // Update "_end" and "end" symbols so that they




More information about the llvm-commits mailing list