[lld] r286327 - Split Header into individual fields.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 17:42:41 PST 2016


Author: rafael
Date: Tue Nov  8 19:42:41 2016
New Revision: 286327

URL: http://llvm.org/viewvc/llvm-project?rev=286327&view=rev
Log:
Split Header into individual fields.

This is similar to what was done for InputSection.

With this the various fields are stored in host order and only
converted to target order when writing.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/OutputSections.h
    lld/trunk/ELF/Relocations.cpp
    lld/trunk/ELF/Symbols.cpp
    lld/trunk/ELF/SyntheticSections.cpp
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Thunks.cpp
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=286327&r1=286326&r2=286327&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Nov  8 19:42:41 2016
@@ -113,7 +113,7 @@ typename ELFT::uint InputSectionBase<ELF
     if (Offset != 0)
       fatal(getName(this) + ": unsupported reference to the middle of '" +
             Name + "' section");
-    return this->OutSec->getVA();
+    return this->OutSec->Addr;
   }
   llvm_unreachable("invalid section kind");
 }
@@ -267,7 +267,7 @@ static typename ELFT::uint getSymVA(uint
   case R_TLSDESC_CALL:
     llvm_unreachable("cannot relocate hint relocs");
   case R_TLSLD:
-    return Out<ELFT>::Got->getTlsIndexOff() + A - Out<ELFT>::Got->getSize();
+    return Out<ELFT>::Got->getTlsIndexOff() + A - Out<ELFT>::Got->Size;
   case R_TLSLD_PC:
     return Out<ELFT>::Got->getTlsIndexVA() + A - P;
   case R_THUNK_ABS:
@@ -278,8 +278,7 @@ static typename ELFT::uint getSymVA(uint
   case R_PPC_TOC:
     return getPPC64TocBase() + A;
   case R_TLSGD:
-    return Out<ELFT>::Got->getGlobalDynOffset(Body) + A -
-           Out<ELFT>::Got->getSize();
+    return Out<ELFT>::Got->getGlobalDynOffset(Body) + A - Out<ELFT>::Got->Size;
   case R_TLSGD_PC:
     return Out<ELFT>::Got->getGlobalDynAddr(Body) + A - P;
   case R_TLSDESC:
@@ -295,13 +294,12 @@ static typename ELFT::uint getSymVA(uint
   case R_SIZE:
     return Body.getSize<ELFT>() + A;
   case R_GOTREL:
-    return Body.getVA<ELFT>(A) - Out<ELFT>::Got->getVA();
+    return Body.getVA<ELFT>(A) - Out<ELFT>::Got->Addr;
   case R_GOTREL_FROM_END:
-    return Body.getVA<ELFT>(A) - Out<ELFT>::Got->getVA() -
-           Out<ELFT>::Got->getSize();
+    return Body.getVA<ELFT>(A) - Out<ELFT>::Got->Addr - Out<ELFT>::Got->Size;
   case R_RELAX_TLS_GD_TO_IE_END:
   case R_GOT_FROM_END:
-    return Body.getGotOffset<ELFT>() + A - Out<ELFT>::Got->getSize();
+    return Body.getGotOffset<ELFT>() + A - Out<ELFT>::Got->Size;
   case R_RELAX_TLS_GD_TO_IE_ABS:
   case R_GOT:
     return Body.getGotVA<ELFT>() + A;
@@ -312,9 +310,9 @@ static typename ELFT::uint getSymVA(uint
   case R_GOT_PC:
     return Body.getGotVA<ELFT>() + A - P;
   case R_GOTONLY_PC:
-    return Out<ELFT>::Got->getVA() + A - P;
+    return Out<ELFT>::Got->Addr + A - P;
   case R_GOTONLY_PC_FROM_END:
-    return Out<ELFT>::Got->getVA() + A - P + Out<ELFT>::Got->getSize();
+    return Out<ELFT>::Got->Addr + A - P + Out<ELFT>::Got->Size;
   case R_RELAX_TLS_LD_TO_LE:
   case R_RELAX_TLS_IE_TO_LE:
   case R_RELAX_TLS_GD_TO_LE:
@@ -366,8 +364,8 @@ static typename ELFT::uint getSymVA(uint
     if (Out<ELF64BE>::Opd) {
       // If this is a local call, and we currently have the address of a
       // function-descriptor, get the underlying code address instead.
-      uint64_t OpdStart = Out<ELF64BE>::Opd->getVA();
-      uint64_t OpdEnd = OpdStart + Out<ELF64BE>::Opd->getSize();
+      uint64_t OpdStart = Out<ELF64BE>::Opd->Addr;
+      uint64_t OpdEnd = OpdStart + Out<ELF64BE>::Opd->Size;
       bool InOpd = OpdStart <= SymVA && SymVA < OpdEnd;
       if (InOpd)
         SymVA = read64be(&Out<ELF64BE>::OpdBuf[SymVA - OpdStart]);
@@ -408,7 +406,7 @@ void InputSection<ELFT>::relocateNonAllo
       return;
     }
 
-    uintX_t AddrLoc = this->OutSec->getVA() + Offset;
+    uintX_t AddrLoc = this->OutSec->Addr + Offset;
     uint64_t SymVA = 0;
     if (!Sym.isTls() || Out<ELFT>::TlsPhdr)
       SymVA = SignExtend64<sizeof(uintX_t) * 8>(
@@ -440,7 +438,7 @@ void InputSectionBase<ELFT>::relocate(ui
     uint32_t Type = Rel.Type;
     uintX_t A = Rel.Addend;
 
-    uintX_t AddrLoc = OutSec->getVA() + Offset;
+    uintX_t AddrLoc = OutSec->Addr + Offset;
     RelExpr Expr = Rel.Expr;
     uint64_t SymVA =
         SignExtend64<Bits>(getSymVA<ELFT>(Type, A, AddrLoc, *Rel.Sym, Expr));

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=286327&r1=286326&r2=286327&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Nov  8 19:42:41 2016
@@ -381,7 +381,7 @@ static void assignSectionSymbol(SymbolAs
 
   if (auto *Body = dyn_cast<DefinedSynthetic<ELFT>>(Cmd->Sym)) {
     Body->Section = Sec;
-    Body->Value = Cmd->Expression(Value) - Sec->getVA();
+    Body->Value = Cmd->Expression(Value) - Sec->Addr;
     return;
   }
   auto *Body = cast<DefinedRegular<ELFT>>(Cmd->Sym);
@@ -389,7 +389,7 @@ static void assignSectionSymbol(SymbolAs
 }
 
 template <class ELFT> static bool isTbss(OutputSectionBase<ELFT> *Sec) {
-  return (Sec->getFlags() & SHF_TLS) && Sec->getType() == SHT_NOBITS;
+  return (Sec->Flags & SHF_TLS) && Sec->Type == SHT_NOBITS;
 }
 
 template <class ELFT> void LinkerScript<ELFT>::output(InputSection<ELFT> *S) {
@@ -399,13 +399,13 @@ template <class ELFT> void LinkerScript<
 
   uintX_t Pos = IsTbss ? Dot + ThreadBssOffset : Dot;
   Pos = alignTo(Pos, S->Alignment);
-  S->OutSecOff = Pos - CurOutSec->getVA();
+  S->OutSecOff = Pos - CurOutSec->Addr;
   Pos += S->getSize();
 
   // Update output section size after adding each section. This is so that
   // SIZEOF works correctly in the case below:
   // .foo { *(.aaa) a = SIZEOF(.foo); *(.bbb) }
-  CurOutSec->setSize(Pos - CurOutSec->getVA());
+  CurOutSec->Size = Pos - CurOutSec->Addr;
 
   if (IsTbss)
     ThreadBssOffset = Pos - Dot;
@@ -420,7 +420,7 @@ template <class ELFT> void LinkerScript<
     for (InputSection<ELFT> *I : OutSec->Sections)
       output(I);
   } else {
-    Dot += CurOutSec->getSize();
+    Dot += CurOutSec->Size;
   }
 }
 
@@ -434,8 +434,8 @@ void LinkerScript<ELFT>::switchTo(Output
   flush();
   CurOutSec = Sec;
 
-  Dot = alignTo(Dot, CurOutSec->getAlignment());
-  CurOutSec->setVA(isTbss(CurOutSec) ? Dot + ThreadBssOffset : Dot);
+  Dot = alignTo(Dot, CurOutSec->Addralign);
+  CurOutSec->Addr = isTbss(CurOutSec) ? Dot + ThreadBssOffset : Dot;
 
   // If neither AT nor AT> is specified for an allocatable section, the linker
   // will set the LMA such that the difference between VMA and LMA for the
@@ -450,7 +450,7 @@ template <class ELFT> void LinkerScript<
     if (AssignCmd->Name == ".") {
       // Update to location counter means update to section size.
       Dot = AssignCmd->Expression(Dot);
-      CurOutSec->setSize(Dot - CurOutSec->getVA());
+      CurOutSec->Size = Dot - CurOutSec->Addr;
       return;
     }
     assignSectionSymbol<ELFT>(AssignCmd, CurOutSec, Dot);
@@ -459,9 +459,9 @@ template <class ELFT> void LinkerScript<
 
   // Handle BYTE(), SHORT(), LONG(), or QUAD().
   if (auto *DataCmd = dyn_cast<BytesDataCommand>(&Base)) {
-    DataCmd->Offset = Dot - CurOutSec->getVA();
+    DataCmd->Offset = Dot - CurOutSec->Addr;
     Dot += DataCmd->Size;
-    CurOutSec->setSize(Dot - CurOutSec->getVA());
+    CurOutSec->Size = Dot - CurOutSec->Addr;
     return;
   }
 
@@ -552,8 +552,8 @@ template <class ELFT> void LinkerScript<
     std::vector<OutputSectionBase<ELFT> *> Secs =
         findSections(Cmd->Name, *OutputSections);
     if (!Secs.empty()) {
-      Flags = Secs[0]->getFlags();
-      Type = Secs[0]->getType();
+      Flags = Secs[0]->Flags;
+      Type = Secs[0]->Type;
       continue;
     }
 
@@ -654,10 +654,10 @@ void LinkerScript<ELFT>::assignAddresses
 
   uintX_t MinVA = std::numeric_limits<uintX_t>::max();
   for (OutputSectionBase<ELFT> *Sec : *OutputSections) {
-    if (Sec->getFlags() & SHF_ALLOC)
-      MinVA = std::min(MinVA, Sec->getVA());
+    if (Sec->Flags & SHF_ALLOC)
+      MinVA = std::min(MinVA, Sec->Addr);
     else
-      Sec->setVA(0);
+      Sec->Addr = 0;
   }
 
   uintX_t HeaderSize = getHeaderSize();
@@ -678,8 +678,8 @@ void LinkerScript<ELFT>::assignAddresses
     // ELF and Program headers need to be right before the first section in
     // memory. Set their addresses accordingly.
     MinVA = alignDown(MinVA - HeaderSize, Target->PageSize);
-    Out<ELFT>::ElfHeader->setVA(MinVA);
-    Out<ELFT>::ProgramHeaders->setVA(Out<ELFT>::ElfHeader->getSize() + MinVA);
+    Out<ELFT>::ElfHeader->Addr = MinVA;
+    Out<ELFT>::ProgramHeaders->Addr = Out<ELFT>::ElfHeader->Size + MinVA;
     FirstPTLoad->First = Out<ELFT>::ElfHeader;
     if (!FirstPTLoad->Last)
       FirstPTLoad->Last = Out<ELFT>::ProgramHeaders;
@@ -692,8 +692,8 @@ void LinkerScript<ELFT>::assignAddresses
     // The code below removes empty PT_LOAD segment and updates
     // program headers size.
     Phdrs.erase(FirstPTLoad);
-    Out<ELFT>::ProgramHeaders->setSize(sizeof(typename ELFT::Phdr) *
-                                       Phdrs.size());
+    Out<ELFT>::ProgramHeaders->Size =
+        sizeof(typename ELFT::Phdr) * Phdrs.size();
   }
 }
 
@@ -731,7 +731,7 @@ std::vector<PhdrEntry<ELFT>> LinkerScrip
 
   // Add output sections to program headers.
   for (OutputSectionBase<ELFT> *Sec : *OutputSections) {
-    if (!(Sec->getFlags() & SHF_ALLOC))
+    if (!(Sec->Flags & SHF_ALLOC))
       break;
 
     std::vector<size_t> PhdrIds = getPhdrIndices(Sec->getName());
@@ -833,7 +833,7 @@ template <class ELFT>
 uint64_t LinkerScript<ELFT>::getOutputSectionAddress(StringRef Name) {
   for (OutputSectionBase<ELFT> *Sec : *OutputSections)
     if (Sec->getName() == Name)
-      return Sec->getVA();
+      return Sec->Addr;
   error("undefined section " + Name);
   return 0;
 }
@@ -851,7 +851,7 @@ template <class ELFT>
 uint64_t LinkerScript<ELFT>::getOutputSectionSize(StringRef Name) {
   for (OutputSectionBase<ELFT> *Sec : *OutputSections)
     if (Sec->getName() == Name)
-      return Sec->getSize();
+      return Sec->Size;
   error("undefined section " + Name);
   return 0;
 }
@@ -860,7 +860,7 @@ template <class ELFT>
 uint64_t LinkerScript<ELFT>::getOutputSectionAlign(StringRef Name) {
   for (OutputSectionBase<ELFT> *Sec : *OutputSections)
     if (Sec->getName() == Name)
-      return Sec->getAlignment();
+      return Sec->Addralign;
   error("undefined section " + Name);
   return 0;
 }

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=286327&r1=286326&r2=286327&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Nov  8 19:42:41 2016
@@ -36,14 +36,12 @@ template <class ELFT>
 OutputSectionBase<ELFT>::OutputSectionBase(StringRef Name, uint32_t Type,
                                            uintX_t Flags)
     : Name(Name) {
-  memset(&Header, 0, sizeof(Elf_Shdr));
-  Header.sh_type = Type;
-  Header.sh_flags = Flags;
-  Header.sh_addralign = 1;
+  this->Type = Type;
+  this->Flags = Flags;
+  this->Addralign = 1;
 }
 
 template <class ELFT> uint32_t OutputSectionBase<ELFT>::getPhdrFlags() const {
-  uintX_t Flags = getFlags();
   uint32_t Ret = PF_R;
   if (Flags & SHF_WRITE)
     Ret |= PF_W;
@@ -54,7 +52,16 @@ template <class ELFT> uint32_t OutputSec
 
 template <class ELFT>
 void OutputSectionBase<ELFT>::writeHeaderTo(Elf_Shdr *Shdr) {
-  *Shdr = Header;
+  Shdr->sh_entsize = Entsize;
+  Shdr->sh_addralign = Addralign;
+  Shdr->sh_type = Type;
+  Shdr->sh_offset = Offset;
+  Shdr->sh_flags = Flags;
+  Shdr->sh_info = Info;
+  Shdr->sh_link = Link;
+  Shdr->sh_addr = Addr;
+  Shdr->sh_size = Size;
+  Shdr->sh_name = ShName;
 }
 
 template <class ELFT>
@@ -81,7 +88,7 @@ template <class ELFT> void GdbIndexSecti
   // GdbIndex header consist from version fields
   // and 5 more fields with different kinds of offsets.
   CuTypesOffset = CuListOffset + CompilationUnits.size() * CompilationUnitSize;
-  this->Header.sh_size = CuTypesOffset;
+  this->Size = CuTypesOffset;
 }
 
 template <class ELFT> void GdbIndexSection<ELFT>::writeTo(uint8_t *Buf) {
@@ -104,7 +111,7 @@ template <class ELFT> void GdbIndexSecti
 template <class ELFT>
 GotPltSection<ELFT>::GotPltSection()
     : OutputSectionBase<ELFT>(".got.plt", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE) {
-  this->Header.sh_addralign = Target->GotPltEntrySize;
+  this->Addralign = Target->GotPltEntrySize;
 }
 
 template <class ELFT> void GotPltSection<ELFT>::addEntry(SymbolBody &Sym) {
@@ -117,8 +124,8 @@ template <class ELFT> bool GotPltSection
 }
 
 template <class ELFT> void GotPltSection<ELFT>::finalize() {
-  this->Header.sh_size = (Target->GotPltHeaderEntriesNum + Entries.size()) *
-                         Target->GotPltEntrySize;
+  this->Size = (Target->GotPltHeaderEntriesNum + Entries.size()) *
+               Target->GotPltEntrySize;
 }
 
 template <class ELFT> void GotPltSection<ELFT>::writeTo(uint8_t *Buf) {
@@ -134,8 +141,8 @@ template <class ELFT>
 GotSection<ELFT>::GotSection()
     : OutputSectionBase<ELFT>(".got", SHT_PROGBITS, SHF_ALLOC | SHF_WRITE) {
   if (Config->EMachine == EM_MIPS)
-    this->Header.sh_flags |= SHF_MIPS_GPREL;
-  this->Header.sh_addralign = Target->GotEntrySize;
+    this->Flags |= SHF_MIPS_GPREL;
+  this->Addralign = Target->GotEntrySize;
 }
 
 template <class ELFT> void GotSection<ELFT>::addEntry(SymbolBody &Sym) {
@@ -281,7 +288,7 @@ typename GotSection<ELFT>::uintX_t GotSe
 template <class ELFT>
 typename GotSection<ELFT>::uintX_t
 GotSection<ELFT>::getGlobalDynAddr(const SymbolBody &B) const {
-  return this->getVA() + B.GlobalDynIndex * sizeof(uintX_t);
+  return this->Addr + B.GlobalDynIndex * sizeof(uintX_t);
 }
 
 template <class ELFT>
@@ -312,11 +319,11 @@ template <class ELFT> void GotSection<EL
       // page of the output section has at least one GOT relocation against it.
       // Add 0x8000 to the section's size because the page address stored
       // in the GOT entry is calculated as (value + 0x8000) & ~0xffff.
-      MipsPageEntries += (OutSec->getSize() + 0x8000 + 0xfffe) / 0xffff;
+      MipsPageEntries += (OutSec->Size + 0x8000 + 0xfffe) / 0xffff;
     }
     EntriesNum += getMipsLocalEntriesNum() + MipsGlobal.size();
   }
-  this->Header.sh_size = EntriesNum * sizeof(uintX_t);
+  this->Size = EntriesNum * sizeof(uintX_t);
 }
 
 template <class ELFT>
@@ -402,7 +409,7 @@ template <class ELFT> void GotSection<EL
 template <class ELFT>
 PltSection<ELFT>::PltSection()
     : OutputSectionBase<ELFT>(".plt", SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR) {
-  this->Header.sh_addralign = 16;
+  this->Addralign = 16;
 }
 
 template <class ELFT> void PltSection<ELFT>::writeTo(uint8_t *Buf) {
@@ -415,7 +422,7 @@ template <class ELFT> void PltSection<EL
     const SymbolBody *B = I.first;
     unsigned RelOff = I.second;
     uint64_t Got = B->getGotPltVA<ELFT>();
-    uint64_t Plt = this->getVA() + Off;
+    uint64_t Plt = this->Addr + Off;
     Target->writePlt(Buf + Off, Got, Plt, B->PltIndex, RelOff);
     Off += Target->PltEntrySize;
   }
@@ -428,8 +435,7 @@ template <class ELFT> void PltSection<EL
 }
 
 template <class ELFT> void PltSection<ELFT>::finalize() {
-  this->Header.sh_size =
-      Target->PltHeaderSize + Entries.size() * Target->PltEntrySize;
+  this->Size = Target->PltHeaderSize + Entries.size() * Target->PltEntrySize;
 }
 
 template <class ELFT>
@@ -437,8 +443,8 @@ RelocationSection<ELFT>::RelocationSecti
     : OutputSectionBase<ELFT>(Name, Config->Rela ? SHT_RELA : SHT_REL,
                               SHF_ALLOC),
       Sort(Sort) {
-  this->Header.sh_entsize = Config->Rela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);
-  this->Header.sh_addralign = sizeof(uintX_t);
+  this->Entsize = Config->Rela ? sizeof(Elf_Rela) : sizeof(Elf_Rel);
+  this->Addralign = sizeof(uintX_t);
 }
 
 template <class ELFT>
@@ -487,25 +493,24 @@ template <class ELFT> void RelocationSec
 }
 
 template <class ELFT> unsigned RelocationSection<ELFT>::getRelocOffset() {
-  return this->Header.sh_entsize * Relocs.size();
+  return this->Entsize * Relocs.size();
 }
 
 template <class ELFT> void RelocationSection<ELFT>::finalize() {
-  this->Header.sh_link = Out<ELFT>::DynSymTab
-                             ? Out<ELFT>::DynSymTab->SectionIndex
-                             : Out<ELFT>::SymTab->SectionIndex;
-  this->Header.sh_size = Relocs.size() * this->Header.sh_entsize;
+  this->Link = Out<ELFT>::DynSymTab ? Out<ELFT>::DynSymTab->SectionIndex
+                                    : Out<ELFT>::SymTab->SectionIndex;
+  this->Size = Relocs.size() * this->Entsize;
 }
 
 template <class ELFT>
 HashTableSection<ELFT>::HashTableSection()
     : OutputSectionBase<ELFT>(".hash", SHT_HASH, SHF_ALLOC) {
-  this->Header.sh_entsize = sizeof(Elf_Word);
-  this->Header.sh_addralign = sizeof(Elf_Word);
+  this->Entsize = sizeof(Elf_Word);
+  this->Addralign = sizeof(Elf_Word);
 }
 
 template <class ELFT> void HashTableSection<ELFT>::finalize() {
-  this->Header.sh_link = Out<ELFT>::DynSymTab->SectionIndex;
+  this->Link = Out<ELFT>::DynSymTab->SectionIndex;
 
   unsigned NumEntries = 2;                             // nbucket and nchain.
   NumEntries += Out<ELFT>::DynSymTab->getNumSymbols(); // The chain entries.
@@ -514,7 +519,7 @@ template <class ELFT> void HashTableSect
   // FIXME: This is simplistic. We can try to optimize it, but implementing
   // support for SHT_GNU_HASH is probably even more profitable.
   NumEntries += Out<ELFT>::DynSymTab->getNumSymbols();
-  this->Header.sh_size = NumEntries * sizeof(Elf_Word);
+  this->Size = NumEntries * sizeof(Elf_Word);
 }
 
 template <class ELFT> void HashTableSection<ELFT>::writeTo(uint8_t *Buf) {
@@ -546,8 +551,8 @@ static uint32_t hashGnu(StringRef Name)
 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 = sizeof(uintX_t);
+  this->Entsize = ELFT::Is64Bits ? 0 : 4;
+  this->Addralign = sizeof(uintX_t);
 }
 
 template <class ELFT>
@@ -591,11 +596,11 @@ template <class ELFT> void GnuHashTableS
   // Second hash shift estimation: just predefined values.
   Shift2 = ELFT::Is64Bits ? 6 : 5;
 
-  this->Header.sh_link = Out<ELFT>::DynSymTab->SectionIndex;
-  this->Header.sh_size = sizeof(Elf_Word) * 4            // Header
-                         + sizeof(Elf_Off) * MaskWords   // Bloom Filter
-                         + sizeof(Elf_Word) * NBuckets   // Hash Buckets
-                         + sizeof(Elf_Word) * NumHashed; // Hash Values
+  this->Link = Out<ELFT>::DynSymTab->SectionIndex;
+  this->Size = sizeof(Elf_Word) * 4            // Header
+               + sizeof(Elf_Off) * MaskWords   // Bloom Filter
+               + sizeof(Elf_Word) * NBuckets   // Hash Buckets
+               + sizeof(Elf_Word) * NumHashed; // Hash Values
 }
 
 template <class ELFT> void GnuHashTableSection<ELFT>::writeTo(uint8_t *Buf) {
@@ -691,15 +696,14 @@ static unsigned getVerDefNum() { return
 template <class ELFT>
 DynamicSection<ELFT>::DynamicSection()
     : OutputSectionBase<ELFT>(".dynamic", SHT_DYNAMIC, SHF_ALLOC | SHF_WRITE) {
-  Elf_Shdr &Header = this->Header;
-  Header.sh_addralign = sizeof(uintX_t);
-  Header.sh_entsize = ELFT::Is64Bits ? 16 : 8;
+  this->Addralign = sizeof(uintX_t);
+  this->Entsize = ELFT::Is64Bits ? 16 : 8;
 
   // .dynamic section is not writable on MIPS.
   // See "Special Section" in Chapter 4 in the following document:
   // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
   if (Config->EMachine == EM_MIPS)
-    Header.sh_flags = SHF_ALLOC;
+    this->Flags = SHF_ALLOC;
 
   addEntries();
 }
@@ -747,15 +751,15 @@ template <class ELFT> void DynamicSectio
 
 // Add remaining entries to complete .dynamic contents.
 template <class ELFT> void DynamicSection<ELFT>::finalize() {
-  if (this->Header.sh_size)
+  if (this->Size)
     return; // Already finalized.
 
-  this->Header.sh_link = Out<ELFT>::DynStrTab->SectionIndex;
+  this->Link = Out<ELFT>::DynStrTab->SectionIndex;
 
   if (Out<ELFT>::RelaDyn->hasRelocs()) {
     bool IsRela = Config->Rela;
     Add({IsRela ? DT_RELA : DT_REL, Out<ELFT>::RelaDyn});
-    Add({IsRela ? DT_RELASZ : DT_RELSZ, Out<ELFT>::RelaDyn->getSize()});
+    Add({IsRela ? DT_RELASZ : DT_RELSZ, Out<ELFT>::RelaDyn->Size});
     Add({IsRela ? DT_RELAENT : DT_RELENT,
          uintX_t(IsRela ? sizeof(Elf_Rela) : sizeof(Elf_Rel))});
 
@@ -770,7 +774,7 @@ template <class ELFT> void DynamicSectio
   }
   if (Out<ELFT>::RelaPlt && Out<ELFT>::RelaPlt->hasRelocs()) {
     Add({DT_JMPREL, Out<ELFT>::RelaPlt});
-    Add({DT_PLTRELSZ, Out<ELFT>::RelaPlt->getSize()});
+    Add({DT_PLTRELSZ, Out<ELFT>::RelaPlt->Size});
     Add({Config->EMachine == EM_MIPS ? DT_MIPS_PLTGOT : DT_PLTGOT,
          Out<ELFT>::GotPlt});
     Add({DT_PLTREL, uint64_t(Config->Rela ? DT_RELA : DT_REL)});
@@ -779,7 +783,7 @@ template <class ELFT> void DynamicSectio
   Add({DT_SYMTAB, Out<ELFT>::DynSymTab});
   Add({DT_SYMENT, sizeof(Elf_Sym)});
   Add({DT_STRTAB, Out<ELFT>::DynStrTab});
-  Add({DT_STRSZ, Out<ELFT>::DynStrTab->getSize()});
+  Add({DT_STRSZ, Out<ELFT>::DynStrTab->Size});
   if (Out<ELFT>::GnuHashTab)
     Add({DT_GNU_HASH, Out<ELFT>::GnuHashTab});
   if (Out<ELFT>::HashTab)
@@ -831,7 +835,7 @@ template <class ELFT> void DynamicSectio
   }
 
   // +1 for DT_NULL
-  this->Header.sh_size = (Entries.size() + 1) * this->Header.sh_entsize;
+  this->Size = (Entries.size() + 1) * this->Entsize;
 }
 
 template <class ELFT> void DynamicSection<ELFT>::writeTo(uint8_t *Buf) {
@@ -841,10 +845,10 @@ template <class ELFT> void DynamicSectio
     P->d_tag = E.Tag;
     switch (E.Kind) {
     case Entry::SecAddr:
-      P->d_un.d_ptr = E.OutSec->getVA();
+      P->d_un.d_ptr = E.OutSec->Addr;
       break;
     case Entry::SecSize:
-      P->d_un.d_val = E.OutSec->getSize();
+      P->d_un.d_val = E.OutSec->Size;
       break;
     case Entry::SymAddr:
       P->d_un.d_ptr = E.Sym->template getVA<ELFT>();
@@ -880,11 +884,11 @@ template <class ELFT> void EhFrameHeader
   Buf[1] = DW_EH_PE_pcrel | DW_EH_PE_sdata4;
   Buf[2] = DW_EH_PE_udata4;
   Buf[3] = DW_EH_PE_datarel | DW_EH_PE_sdata4;
-  write32<E>(Buf + 4, Out<ELFT>::EhFrame->getVA() - this->getVA() - 4);
+  write32<E>(Buf + 4, Out<ELFT>::EhFrame->Addr - this->Addr - 4);
   write32<E>(Buf + 8, Fdes.size());
   Buf += 12;
 
-  uintX_t VA = this->getVA();
+  uintX_t VA = this->Addr;
   for (FdeData &Fde : Fdes) {
     write32<E>(Buf, Fde.Pc - VA);
     write32<E>(Buf + 4, Fde.FdeVA - VA);
@@ -894,7 +898,7 @@ template <class ELFT> void EhFrameHeader
 
 template <class ELFT> void EhFrameHeader<ELFT>::finalize() {
   // .eh_frame_hdr has a 12 bytes header followed by an array of FDEs.
-  this->Header.sh_size = 12 + Out<ELFT>::EhFrame->NumFdes * 8;
+  this->Size = 12 + Out<ELFT>::EhFrame->NumFdes * 8;
 }
 
 template <class ELFT>
@@ -906,17 +910,17 @@ template <class ELFT>
 OutputSection<ELFT>::OutputSection(StringRef Name, uint32_t Type, uintX_t Flags)
     : OutputSectionBase<ELFT>(Name, Type, Flags) {
   if (Type == SHT_RELA)
-    this->Header.sh_entsize = sizeof(Elf_Rela);
+    this->Entsize = sizeof(Elf_Rela);
   else if (Type == SHT_REL)
-    this->Header.sh_entsize = sizeof(Elf_Rel);
+    this->Entsize = sizeof(Elf_Rel);
 }
 
 template <class ELFT> void OutputSection<ELFT>::finalize() {
-  uint32_t Type = this->Header.sh_type;
-  if (this->Header.sh_flags & SHF_LINK_ORDER) {
+  uint32_t Type = this->Type;
+  if (this->Flags & SHF_LINK_ORDER) {
     if (!Config->Relocatable) {
       // SHF_LINK_ORDER only has meaning in relocatable objects
-      this->Header.sh_flags &= ~SHF_LINK_ORDER;
+      this->Flags &= ~SHF_LINK_ORDER;
     }
     else if (!this->Sections.empty()) {
       // When doing a relocatable link we must preserve the link order
@@ -925,16 +929,16 @@ template <class ELFT> void OutputSection
       // InputSection sh_link to the OutputSection sh_link, all InputSections
       // in the OutputSection have the same dependency.
       if (auto *D = this->Sections.front()->getLinkOrderDep())
-        this->Header.sh_link = D->OutSec->SectionIndex;
+        this->Link = D->OutSec->SectionIndex;
     }
   }
   if (Type != SHT_RELA && Type != SHT_REL)
     return;
-  this->Header.sh_link = Out<ELFT>::SymTab->SectionIndex;
+  this->Link = Out<ELFT>::SymTab->SectionIndex;
   // sh_info for SHT_REL[A] sections should contain the section header index of
   // the section to which the relocation applies.
   InputSectionBase<ELFT> *S = Sections[0]->getRelocatedSection();
-  this->Header.sh_info = S->OutSec->SectionIndex;
+  this->Info = S->OutSec->SectionIndex;
 }
 
 template <class ELFT>
@@ -947,19 +951,19 @@ void OutputSection<ELFT>::addSection(Inp
   // Keep sh_entsize value of the input section to be able to perform merging
   // later during a final linking using the generated relocatable object.
   if (Config->Relocatable && (S->Flags & SHF_MERGE))
-    this->Header.sh_entsize = S->Entsize;
+    this->Entsize = S->Entsize;
 }
 
 // This function is called after we sort input sections
 // and scan relocations to setup sections' offsets.
 template <class ELFT> void OutputSection<ELFT>::assignOffsets() {
-  uintX_t Off = this->Header.sh_size;
+  uintX_t Off = this->Size;
   for (InputSection<ELFT> *S : Sections) {
     Off = alignTo(Off, S->Alignment);
     S->OutSecOff = Off;
     Off += S->getSize();
   }
-  this->Header.sh_size = Off;
+  this->Size = Off;
 }
 
 // Sorts input sections by section name suffixes, so that .foo.N comes
@@ -1052,7 +1056,7 @@ static void fill(uint8_t *Buf, size_t Si
 template <class ELFT> void OutputSection<ELFT>::writeTo(uint8_t *Buf) {
   ArrayRef<uint8_t> Filler = Script<ELFT>::X->getFiller(this->Name);
   if (!Filler.empty())
-    fill(Buf, this->getSize(), Filler);
+    fill(Buf, this->Size, Filler);
   if (Config->Threads) {
     parallel_for_each(Sections.begin(), Sections.end(),
                       [=](InputSection<ELFT> *C) { C->writeTo(Buf); });
@@ -1186,7 +1190,7 @@ static void writeCieFde(uint8_t *Buf, Ar
 }
 
 template <class ELFT> void EhOutputSection<ELFT>::finalize() {
-  if (this->Header.sh_size)
+  if (this->Size)
     return; // Already finalized.
 
   size_t Off = 0;
@@ -1199,7 +1203,7 @@ template <class ELFT> void EhOutputSecti
       Off += alignTo(Fde->size(), sizeof(uintX_t));
     }
   }
-  this->Header.sh_size = Off;
+  this->Size = Off;
 }
 
 template <class ELFT> static uint64_t readFdeAddr(uint8_t *Buf, int Size) {
@@ -1231,7 +1235,7 @@ typename ELFT::uint EhOutputSection<ELFT
   if ((Enc & 0x70) == DW_EH_PE_absptr)
     return Addr;
   if ((Enc & 0x70) == DW_EH_PE_pcrel)
-    return Addr + this->getVA() + Off;
+    return Addr + this->Addr + Off;
   fatal("unknown FDE size relative encoding");
 }
 
@@ -1262,7 +1266,7 @@ template <class ELFT> void EhOutputSecti
       uint8_t Enc = getFdeEncoding<ELFT>(Cie->Piece->data());
       for (SectionPiece *Fde : Cie->FdePieces) {
         uintX_t Pc = getFdePc(Buf, Fde->OutputOff, Enc);
-        uintX_t FdeVA = this->getVA() + Fde->OutputOff;
+        uintX_t FdeVA = this->Addr + Fde->OutputOff;
         Out<ELFT>::EhFrameHdr->addFde(Pc, FdeVA);
       }
     }
@@ -1284,7 +1288,7 @@ void MergeOutputSection<ELFT>::addSectio
   auto *Sec = cast<MergeInputSection<ELFT>>(C);
   Sec->OutSec = this;
   this->updateAlignment(Sec->Alignment);
-  this->Header.sh_entsize = Sec->Entsize;
+  this->Entsize = Sec->Entsize;
   Sections.push_back(Sec);
 
   auto HashI = Sec->Hashes.begin();
@@ -1308,7 +1312,7 @@ unsigned MergeOutputSection<ELFT>::getOf
 }
 
 template <class ELFT> bool MergeOutputSection<ELFT>::shouldTailMerge() const {
-  return Config->Optimize >= 2 && this->Header.sh_flags & SHF_STRINGS;
+  return Config->Optimize >= 2 && this->Flags & SHF_STRINGS;
 }
 
 template <class ELFT> void MergeOutputSection<ELFT>::finalize() {
@@ -1316,7 +1320,7 @@ template <class ELFT> void MergeOutputSe
     Builder.finalize();
   else
     Builder.finalizeInOrder();
-  this->Header.sh_size = Builder.getSize();
+  this->Size = Builder.getSize();
 }
 
 template <class ELFT> void MergeOutputSection<ELFT>::finalizePieces() {
@@ -1330,7 +1334,7 @@ StringTableSection<ELFT>::StringTableSec
                               Dynamic ? (uintX_t)SHF_ALLOC : 0),
       Dynamic(Dynamic) {
   // ELF string tables start with a NUL byte, so 1.
-  this->setSize(1);
+  this->Size = 1;
 }
 
 // Adds a string to the string table. If HashIt is true we hash and check for
@@ -1340,12 +1344,12 @@ StringTableSection<ELFT>::StringTableSec
 template <class ELFT>
 unsigned StringTableSection<ELFT>::addString(StringRef S, bool HashIt) {
   if (HashIt) {
-    auto R = StringMap.insert(std::make_pair(S, this->getSize()));
+    auto R = StringMap.insert(std::make_pair(S, this->Size));
     if (!R.second)
       return R.first->second;
   }
-  unsigned Ret = this->getSize();
-  this->setSize(this->getSize() + S.size() + 1);
+  unsigned Ret = this->Size;
+  this->Size = this->Size + S.size() + 1;
   Strings.push_back(S);
   return Ret;
 }
@@ -1362,8 +1366,8 @@ template <class ELFT> void StringTableSe
 template <class ELFT>
 typename ELFT::uint DynamicReloc<ELFT>::getOffset() const {
   if (OutputSec)
-    return OutputSec->getVA() + OffsetInSec;
-  return InputSec->OutSec->getVA() + InputSec->getOffset(OffsetInSec);
+    return OutputSec->Addr + OffsetInSec;
+  return InputSec->OutSec->Addr + InputSec->getOffset(OffsetInSec);
 }
 
 template <class ELFT>
@@ -1386,8 +1390,8 @@ SymbolTableSection<ELFT>::SymbolTableSec
                               StrTabSec.isDynamic() ? SHT_DYNSYM : SHT_SYMTAB,
                               StrTabSec.isDynamic() ? (uintX_t)SHF_ALLOC : 0),
       StrTabSec(StrTabSec) {
-  this->Header.sh_entsize = sizeof(Elf_Sym);
-  this->Header.sh_addralign = sizeof(uintX_t);
+  this->Entsize = sizeof(Elf_Sym);
+  this->Addralign = sizeof(uintX_t);
 }
 
 // Orders symbols according to their positions in the GOT,
@@ -1418,12 +1422,12 @@ static uint8_t getSymbolBinding(SymbolBo
 }
 
 template <class ELFT> void SymbolTableSection<ELFT>::finalize() {
-  if (this->Header.sh_size)
+  if (this->Size)
     return; // Already finalized.
 
-  this->Header.sh_size = getNumSymbols() * sizeof(Elf_Sym);
-  this->Header.sh_link = StrTabSec.SectionIndex;
-  this->Header.sh_info = NumLocals + 1;
+  this->Size = getNumSymbols() * sizeof(Elf_Sym);
+  this->Link = StrTabSec.SectionIndex;
+  this->Info = NumLocals + 1;
 
   if (Config->Relocatable) {
     size_t I = NumLocals;
@@ -1485,7 +1489,7 @@ void SymbolTableSection<ELFT>::writeLoca
       } else {
         const OutputSectionBase<ELFT> *OutSec = Section->OutSec;
         ESym->st_shndx = OutSec->SectionIndex;
-        ESym->st_value = OutSec->getVA() + Section->getOffset(Body);
+        ESym->st_value = OutSec->Addr + Section->getOffset(Body);
       }
       ESym->st_name = P.second;
       ESym->st_size = Body.template getSize<ELFT>();
@@ -1564,7 +1568,7 @@ SymbolTableSection<ELFT>::getOutputSecti
 template <class ELFT>
 VersionDefinitionSection<ELFT>::VersionDefinitionSection()
     : OutputSectionBase<ELFT>(".gnu.version_d", SHT_GNU_verdef, SHF_ALLOC) {
-  this->Header.sh_addralign = sizeof(uint32_t);
+  this->Addralign = sizeof(uint32_t);
 }
 
 static StringRef getFileDefName() {
@@ -1578,14 +1582,13 @@ template <class ELFT> void VersionDefini
   for (VersionDefinition &V : Config->VersionDefinitions)
     V.NameOff = Out<ELFT>::DynStrTab->addString(V.Name);
 
-  this->Header.sh_size =
-      (sizeof(Elf_Verdef) + sizeof(Elf_Verdaux)) * getVerDefNum();
-  this->Header.sh_link = Out<ELFT>::DynStrTab->SectionIndex;
+  this->Size = (sizeof(Elf_Verdef) + sizeof(Elf_Verdaux)) * getVerDefNum();
+  this->Link = Out<ELFT>::DynStrTab->SectionIndex;
 
   // sh_info should be set to the number of definitions. This fact is missed in
   // documentation, but confirmed by binutils community:
   // https://sourceware.org/ml/binutils/2014-11/msg00355.html
-  this->Header.sh_info = getVerDefNum();
+  this->Info = getVerDefNum();
 }
 
 template <class ELFT>
@@ -1622,16 +1625,16 @@ void VersionDefinitionSection<ELFT>::wri
 template <class ELFT>
 VersionTableSection<ELFT>::VersionTableSection()
     : OutputSectionBase<ELFT>(".gnu.version", SHT_GNU_versym, SHF_ALLOC) {
-  this->Header.sh_addralign = sizeof(uint16_t);
+  this->Addralign = sizeof(uint16_t);
 }
 
 template <class ELFT> void VersionTableSection<ELFT>::finalize() {
-  this->Header.sh_size =
+  this->Size =
       sizeof(Elf_Versym) * (Out<ELFT>::DynSymTab->getSymbols().size() + 1);
-  this->Header.sh_entsize = sizeof(Elf_Versym);
+  this->Entsize = sizeof(Elf_Versym);
   // At the moment of june 2016 GNU docs does not mention that sh_link field
   // should be set, but Sun docs do. Also readelf relies on this field.
-  this->Header.sh_link = Out<ELFT>::DynSymTab->SectionIndex;
+  this->Link = Out<ELFT>::DynSymTab->SectionIndex;
 }
 
 template <class ELFT> void VersionTableSection<ELFT>::writeTo(uint8_t *Buf) {
@@ -1645,7 +1648,7 @@ template <class ELFT> void VersionTableS
 template <class ELFT>
 VersionNeedSection<ELFT>::VersionNeedSection()
     : OutputSectionBase<ELFT>(".gnu.version_r", SHT_GNU_verneed, SHF_ALLOC) {
-  this->Header.sh_addralign = sizeof(uint32_t);
+  this->Addralign = sizeof(uint32_t);
 
   // Identifiers in verneed section start at 2 because 0 and 1 are reserved
   // for VER_NDX_LOCAL and VER_NDX_GLOBAL.
@@ -1713,20 +1716,20 @@ template <class ELFT> void VersionNeedSe
 }
 
 template <class ELFT> void VersionNeedSection<ELFT>::finalize() {
-  this->Header.sh_link = Out<ELFT>::DynStrTab->SectionIndex;
-  this->Header.sh_info = Needed.size();
+  this->Link = Out<ELFT>::DynStrTab->SectionIndex;
+  this->Info = Needed.size();
   unsigned Size = Needed.size() * sizeof(Elf_Verneed);
   for (std::pair<SharedFile<ELFT> *, size_t> &P : Needed)
     Size += P.first->VerdefMap.size() * sizeof(Elf_Vernaux);
-  this->Header.sh_size = Size;
+  this->Size = Size;
 }
 
 template <class ELFT>
 MipsReginfoOutputSection<ELFT>::MipsReginfoOutputSection()
     : OutputSectionBase<ELFT>(".reginfo", SHT_MIPS_REGINFO, SHF_ALLOC) {
-  this->Header.sh_addralign = 4;
-  this->Header.sh_entsize = sizeof(Elf_Mips_RegInfo);
-  this->Header.sh_size = sizeof(Elf_Mips_RegInfo);
+  this->Addralign = 4;
+  this->Entsize = sizeof(Elf_Mips_RegInfo);
+  this->Size = sizeof(Elf_Mips_RegInfo);
 }
 
 template <class ELFT>
@@ -1735,7 +1738,7 @@ void MipsReginfoOutputSection<ELFT>::wri
   if (Config->Relocatable)
     R->ri_gp_value = 0;
   else
-    R->ri_gp_value = Out<ELFT>::Got->getVA() + MipsGPOffset;
+    R->ri_gp_value = Out<ELFT>::Got->Addr + MipsGPOffset;
   R->ri_gprmask = GprMask;
 }
 
@@ -1751,23 +1754,23 @@ template <class ELFT>
 MipsOptionsOutputSection<ELFT>::MipsOptionsOutputSection()
     : OutputSectionBase<ELFT>(".MIPS.options", SHT_MIPS_OPTIONS,
                               SHF_ALLOC | SHF_MIPS_NOSTRIP) {
-  this->Header.sh_addralign = 8;
-  this->Header.sh_entsize = 1;
-  this->Header.sh_size = sizeof(Elf_Mips_Options) + sizeof(Elf_Mips_RegInfo);
+  this->Addralign = 8;
+  this->Entsize = 1;
+  this->Size = sizeof(Elf_Mips_Options) + sizeof(Elf_Mips_RegInfo);
 }
 
 template <class ELFT>
 void MipsOptionsOutputSection<ELFT>::writeTo(uint8_t *Buf) {
   auto *Opt = reinterpret_cast<Elf_Mips_Options *>(Buf);
   Opt->kind = ODK_REGINFO;
-  Opt->size = this->Header.sh_size;
+  Opt->size = this->Size;
   Opt->section = 0;
   Opt->info = 0;
   auto *Reg = reinterpret_cast<Elf_Mips_RegInfo *>(Buf + sizeof(*Opt));
   if (Config->Relocatable)
     Reg->ri_gp_value = 0;
   else
-    Reg->ri_gp_value = Out<ELFT>::Got->getVA() + MipsGPOffset;
+    Reg->ri_gp_value = Out<ELFT>::Got->Addr + MipsGPOffset;
   Reg->ri_gprmask = GprMask;
 }
 
@@ -1782,9 +1785,9 @@ void MipsOptionsOutputSection<ELFT>::add
 template <class ELFT>
 MipsAbiFlagsOutputSection<ELFT>::MipsAbiFlagsOutputSection()
     : OutputSectionBase<ELFT>(".MIPS.abiflags", SHT_MIPS_ABIFLAGS, SHF_ALLOC) {
-  this->Header.sh_addralign = 8;
-  this->Header.sh_entsize = sizeof(Elf_Mips_ABIFlags);
-  this->Header.sh_size = sizeof(Elf_Mips_ABIFlags);
+  this->Addralign = 8;
+  this->Entsize = sizeof(Elf_Mips_ABIFlags);
+  this->Size = sizeof(Elf_Mips_ABIFlags);
   memset(&Flags, 0, sizeof(Flags));
 }
 
@@ -1859,7 +1862,7 @@ OutputSectionFactory<ELFT>::create(const
   uintX_t Flags = getOutFlags(C);
   OutputSectionBase<ELFT> *&Sec = Map[Key];
   if (Sec) {
-    Sec->updateFlags(Flags);
+    Sec->Flags |= Flags;
     return {Sec, false};
   }
 

Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=286327&r1=286326&r2=286327&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Tue Nov  8 19:42:41 2016
@@ -71,13 +71,8 @@ public:
   };
 
   OutputSectionBase(StringRef Name, uint32_t Type, uintX_t Flags);
-  void setVA(uintX_t VA) { Header.sh_addr = VA; }
-  uintX_t getVA() const { return Header.sh_addr; }
   void setLMAOffset(uintX_t LMAOff) { LMAOffset = LMAOff; }
-  uintX_t getLMA() const { return Header.sh_addr + LMAOffset; }
-  void setFileOffset(uintX_t Off) { Header.sh_offset = Off; }
-  uintX_t getFileOffset() { return Header.sh_offset; }
-  void setSHName(unsigned Val) { Header.sh_name = Val; }
+  uintX_t getLMA() const { return Addr + LMAOffset; }
   void writeHeaderTo(Elf_Shdr *SHdr);
   StringRef getName() const { return Name; }
 
@@ -89,19 +84,11 @@ public:
 
   unsigned SectionIndex;
 
-  // Returns the size of the section in the output file.
-  uintX_t getSize() const { return Header.sh_size; }
-  void setSize(uintX_t Val) { Header.sh_size = Val; }
-  uintX_t getFlags() const { return Header.sh_flags; }
-  void updateFlags(uintX_t Val) { Header.sh_flags |= Val; }
   uint32_t getPhdrFlags() const;
-  uintX_t getFileOff() const { return Header.sh_offset; }
-  uintX_t getAlignment() const { return Header.sh_addralign; }
-  uint32_t getType() const { return Header.sh_type; }
 
   void updateAlignment(uintX_t Alignment) {
-    if (Alignment > Header.sh_addralign)
-      Header.sh_addralign = Alignment;
+    if (Alignment > Addralign)
+      Addralign = Alignment;
   }
 
   // If true, this section will be page aligned on disk.
@@ -122,10 +109,20 @@ public:
   virtual void writeTo(uint8_t *Buf) {}
   virtual ~OutputSectionBase() = default;
 
-protected:
   StringRef Name;
-  Elf_Shdr Header;
+
+  // The following fields correspond to Elf_Shdr members.
+  uintX_t Size = 0;
+  uintX_t Entsize = 0;
+  uintX_t Addralign = 0;
+  uintX_t Offset = 0;
+  uintX_t Flags = 0;
   uintX_t LMAOffset = 0;
+  uintX_t Addr = 0;
+  uint32_t ShName = 0;
+  uint32_t Type = 0;
+  uint32_t Info = 0;
+  uint32_t Link = 0;
 };
 
 template <class ELFT>
@@ -187,7 +184,7 @@ public:
   // after 'local' and 'global' entries.
   uintX_t getMipsTlsOffset() const;
 
-  uintX_t getTlsIndexVA() { return Base::getVA() + TlsIndexOff; }
+  uintX_t getTlsIndexVA() { return this->Addr + TlsIndexOff; }
   uint32_t getTlsIndexOff() const { return TlsIndexOff; }
 
   // Flag to force GOT to be in output if we have relocations
@@ -794,7 +791,7 @@ private:
 template <class ELFT> uint64_t getHeaderSize() {
   if (Config->OFormatBinary)
     return 0;
-  return Out<ELFT>::ElfHeader->getSize() + Out<ELFT>::ProgramHeaders->getSize();
+  return Out<ELFT>::ElfHeader->Size + Out<ELFT>::ProgramHeaders->Size;
 }
 
 template <class ELFT> uint8_t Out<ELFT>::First;

Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=286327&r1=286326&r2=286327&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Tue Nov  8 19:42:41 2016
@@ -394,8 +394,8 @@ template <class ELFT> static void addCop
     fatal("cannot create a copy relocation for symbol " + SS->getName());
 
   uintX_t Alignment = getAlignment(SS);
-  uintX_t Off = alignTo(Out<ELFT>::Bss->getSize(), Alignment);
-  Out<ELFT>::Bss->setSize(Off + SymSize);
+  uintX_t Off = alignTo(Out<ELFT>::Bss->Size, Alignment);
+  Out<ELFT>::Bss->Size = Off + SymSize;
   Out<ELFT>::Bss->updateAlignment(Alignment);
   uintX_t Shndx = SS->Sym.st_shndx;
   uintX_t Value = SS->Sym.st_value;

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=286327&r1=286326&r2=286327&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Tue Nov  8 19:42:41 2016
@@ -37,8 +37,8 @@ static typename ELFT::uint getSymVA(cons
     if (!Sec)
       return D.Value;
     if (D.Value == DefinedSynthetic<ELFT>::SectionEnd)
-      return Sec->getVA() + Sec->getSize();
-    return Sec->getVA() + D.Value;
+      return Sec->Addr + Sec->Size;
+    return Sec->Addr + D.Value;
   }
   case SymbolBody::DefinedRegularKind: {
     auto &D = cast<DefinedRegular<ELFT>>(Body);
@@ -60,7 +60,7 @@ static typename ELFT::uint getSymVA(cons
       Offset += Addend;
       Addend = 0;
     }
-    uintX_t VA = (SC->OutSec ? SC->OutSec->getVA() : 0) + SC->getOffset(Offset);
+    uintX_t VA = (SC->OutSec ? SC->OutSec->Addr : 0) + SC->getOffset(Offset);
     if (D.isTls() && !Config->Relocatable) {
       if (!Out<ELFT>::TlsPhdr)
         fatal(getFilename(D.File) +
@@ -70,7 +70,7 @@ static typename ELFT::uint getSymVA(cons
     return VA;
   }
   case SymbolBody::DefinedCommonKind:
-    return In<ELFT>::Common->OutSec->getVA() + In<ELFT>::Common->OutSecOff +
+    return In<ELFT>::Common->OutSec->Addr + In<ELFT>::Common->OutSecOff +
            cast<DefinedCommon>(Body).Offset;
   case SymbolBody::SharedKind: {
     auto &SS = cast<SharedSymbol<ELFT>>(Body);
@@ -78,7 +78,7 @@ static typename ELFT::uint getSymVA(cons
       return 0;
     if (SS.isFunc())
       return Body.getPltVA<ELFT>();
-    return Out<ELFT>::Bss->getVA() + SS.OffsetInBss;
+    return Out<ELFT>::Bss->Addr + SS.OffsetInBss;
   }
   case SymbolBody::UndefinedKind:
     return 0;
@@ -151,7 +151,7 @@ typename ELFT::uint SymbolBody::getVA(ty
 }
 
 template <class ELFT> typename ELFT::uint SymbolBody::getGotVA() const {
-  return Out<ELFT>::Got->getVA() + getGotOffset<ELFT>();
+  return Out<ELFT>::Got->Addr + getGotOffset<ELFT>();
 }
 
 template <class ELFT> typename ELFT::uint SymbolBody::getGotOffset() const {
@@ -159,7 +159,7 @@ template <class ELFT> typename ELFT::uin
 }
 
 template <class ELFT> typename ELFT::uint SymbolBody::getGotPltVA() const {
-  return Out<ELFT>::GotPlt->getVA() + getGotPltOffset<ELFT>();
+  return Out<ELFT>::GotPlt->Addr + getGotPltOffset<ELFT>();
 }
 
 template <class ELFT> typename ELFT::uint SymbolBody::getGotPltOffset() const {
@@ -167,7 +167,7 @@ template <class ELFT> typename ELFT::uin
 }
 
 template <class ELFT> typename ELFT::uint SymbolBody::getPltVA() const {
-  return Out<ELFT>::Plt->getVA() + Target->PltHeaderSize +
+  return Out<ELFT>::Plt->Addr + Target->PltHeaderSize +
          PltIndex * Target->PltEntrySize;
 }
 

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=286327&r1=286326&r2=286327&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Nov  8 19:42:41 2016
@@ -107,7 +107,7 @@ BuildIdSection<ELFT>::BuildIdSection(siz
 
 template <class ELFT>
 uint8_t *BuildIdSection<ELFT>::getOutputLoc(uint8_t *Start) const {
-  return Start + this->OutSec->getFileOffset() + this->OutSecOff;
+  return Start + this->OutSec->Offset + this->OutSecOff;
 }
 
 static std::vector<ArrayRef<uint8_t>> split(ArrayRef<uint8_t> Arr,

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=286327&r1=286326&r2=286327&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Nov  8 19:42:41 2016
@@ -355,7 +355,7 @@ RelExpr X86TargetInfo::adjustRelaxExpr(u
 }
 
 void X86TargetInfo::writeGotPltHeader(uint8_t *Buf) const {
-  write32le(Buf, Out<ELF32LE>::Dynamic->getVA());
+  write32le(Buf, Out<ELF32LE>::Dynamic->Addr);
 }
 
 void X86TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &S) const {
@@ -403,7 +403,7 @@ void X86TargetInfo::writePltHeader(uint8
       0x90, 0x90, 0x90, 0x90              // nop; nop; nop; nop
   };
   memcpy(Buf, PltData, sizeof(PltData));
-  uint32_t Got = Out<ELF32LE>::GotPlt->getVA();
+  uint32_t Got = Out<ELF32LE>::GotPlt->Addr;
   write32le(Buf + 2, Got + 4);
   write32le(Buf + 8, Got + 8);
 }
@@ -420,7 +420,7 @@ void X86TargetInfo::writePlt(uint8_t *Bu
 
   // jmp *foo at GOT(%ebx) or jmp *foo_in_GOT
   Buf[1] = Config->Pic ? 0xa3 : 0x25;
-  uint32_t Got = Out<ELF32LE>::GotPlt->getVA();
+  uint32_t Got = Out<ELF32LE>::GotPlt->Addr;
   write32le(Buf + 2, Config->Shared ? GotEntryAddr - Got : GotEntryAddr);
   write32le(Buf + 7, RelOff);
   write32le(Buf + 12, -Index * PltEntrySize - PltHeaderSize - 16);
@@ -595,7 +595,7 @@ void X86_64TargetInfo<ELFT>::writeGotPlt
   // required, but it is documented in the psabi and the glibc dynamic linker
   // seems to use it (note that this is relevant for linking ld.so, not any
   // other program).
-  write64le(Buf, Out<ELFT>::Dynamic->getVA());
+  write64le(Buf, Out<ELFT>::Dynamic->Addr);
 }
 
 template <class ELFT>
@@ -613,8 +613,8 @@ void X86_64TargetInfo<ELFT>::writePltHea
       0x0f, 0x1f, 0x40, 0x00              // nopl 0x0(rax)
   };
   memcpy(Buf, PltData, sizeof(PltData));
-  uint64_t Got = Out<ELFT>::GotPlt->getVA();
-  uint64_t Plt = Out<ELFT>::Plt->getVA();
+  uint64_t Got = Out<ELFT>::GotPlt->Addr;
+  uint64_t Plt = Out<ELFT>::Plt->Addr;
   write32le(Buf + 2, Got - Plt + 2); // GOT+8
   write32le(Buf + 8, Got - Plt + 4); // GOT+16
 }
@@ -1019,7 +1019,7 @@ uint64_t getPPC64TocBase() {
   // TOC starts where the first of these sections starts. We always create a
   // .got when we see a relocation that uses it, so for us the start is always
   // the .got.
-  uint64_t TocVA = Out<ELF64BE>::Got->getVA();
+  uint64_t TocVA = Out<ELF64BE>::Got->Addr;
 
   // Per the ppc64-elf-linux ABI, The TOC base is TOC value plus 0x8000
   // thus permitting a full 64 Kbytes segment. Note that the glibc startup
@@ -1254,7 +1254,7 @@ uint32_t AArch64TargetInfo::getDynRel(ui
 }
 
 void AArch64TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
-  write64le(Buf, Out<ELF64LE>::Plt->getVA());
+  write64le(Buf, Out<ELF64LE>::Plt->Addr);
 }
 
 static uint64_t getAArch64Page(uint64_t Expr) {
@@ -1274,8 +1274,8 @@ void AArch64TargetInfo::writePltHeader(u
   };
   memcpy(Buf, PltData, sizeof(PltData));
 
-  uint64_t Got = Out<ELF64LE>::GotPlt->getVA();
-  uint64_t Plt = Out<ELF64LE>::Plt->getVA();
+  uint64_t Got = Out<ELF64LE>::GotPlt->Addr;
+  uint64_t Plt = Out<ELF64LE>::Plt->Addr;
   relocateOne(Buf + 4, R_AARCH64_ADR_PREL_PG_HI21,
               getAArch64Page(Got + 16) - getAArch64Page(Plt + 4));
   relocateOne(Buf + 8, R_AARCH64_LDST64_ABS_LO12_NC, Got + 16);
@@ -1616,7 +1616,7 @@ uint32_t ARMTargetInfo::getDynRel(uint32
 }
 
 void ARMTargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
-  write32le(Buf, Out<ELF32LE>::Plt->getVA());
+  write32le(Buf, Out<ELF32LE>::Plt->Addr);
 }
 
 void ARMTargetInfo::writePltHeader(uint8_t *Buf) const {
@@ -1628,8 +1628,8 @@ void ARMTargetInfo::writePltHeader(uint8
       0x00, 0x00, 0x00, 0x00, // L2: .word   &(.got.plt) - L1 - 8
   };
   memcpy(Buf, PltData, sizeof(PltData));
-  uint64_t GotPlt = Out<ELF32LE>::GotPlt->getVA();
-  uint64_t L1 = Out<ELF32LE>::Plt->getVA() + 8;
+  uint64_t GotPlt = Out<ELF32LE>::GotPlt->Addr;
+  uint64_t L1 = Out<ELF32LE>::Plt->Addr + 8;
   write32le(Buf + 16, GotPlt - L1 - 8);
 }
 
@@ -1996,7 +1996,7 @@ bool MipsTargetInfo<ELFT>::isTlsGlobalDy
 
 template <class ELFT>
 void MipsTargetInfo<ELFT>::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
-  write32<ELFT::TargetEndianness>(Buf, Out<ELFT>::Plt->getVA());
+  write32<ELFT::TargetEndianness>(Buf, Out<ELFT>::Plt->Addr);
 }
 
 template <endianness E, uint8_t BSIZE, uint8_t SHIFT>
@@ -2063,7 +2063,7 @@ void MipsTargetInfo<ELFT>::writePltHeade
   write32<E>(Buf + 20, 0x0018c082); // srl   $24, $24, 2
   write32<E>(Buf + 24, 0x0320f809); // jalr  $25
   write32<E>(Buf + 28, 0x2718fffe); // subu  $24, $24, 2
-  uint64_t Got = Out<ELFT>::GotPlt->getVA();
+  uint64_t Got = Out<ELFT>::GotPlt->Addr;
   writeMipsHi16<E>(Buf, Got);
   writeMipsLo16<E>(Buf + 4, Got);
   writeMipsLo16<E>(Buf + 8, Got);

Modified: lld/trunk/ELF/Thunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Thunks.cpp?rev=286327&r1=286326&r2=286327&view=diff
==============================================================================
--- lld/trunk/ELF/Thunks.cpp (original)
+++ lld/trunk/ELF/Thunks.cpp Tue Nov  8 19:42:41 2016
@@ -183,7 +183,7 @@ Thunk<ELFT>::Thunk(const SymbolBody &D,
     : Destination(D), Owner(O), Offset(O.getThunkOff() + O.getThunksSize()) {}
 
 template <class ELFT> typename ELFT::uint Thunk<ELFT>::getVA() const {
-  return Owner.OutSec->getVA() + Owner.OutSecOff + Offset;
+  return Owner.OutSec->Addr + Owner.OutSecOff + Offset;
 }
 
 template <class ELFT> Thunk<ELFT>::~Thunk() = default;

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=286327&r1=286326&r2=286327&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Nov  8 19:42:41 2016
@@ -222,7 +222,7 @@ template <class ELFT> void Writer<ELFT>:
   Out<ELFT>::VerNeed = make<VersionNeedSection<ELFT>>();
 
   Out<ELFT>::ElfHeader = make<OutputSectionBase<ELFT>>("", 0, SHF_ALLOC);
-  Out<ELFT>::ElfHeader->setSize(sizeof(Elf_Ehdr));
+  Out<ELFT>::ElfHeader->Size = sizeof(Elf_Ehdr);
   Out<ELFT>::ProgramHeaders = make<OutputSectionBase<ELFT>>("", 0, SHF_ALLOC);
   Out<ELFT>::ProgramHeaders->updateAlignment(sizeof(uintX_t));
 
@@ -263,7 +263,7 @@ template <class ELFT> void Writer<ELFT>:
     // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
     Out<ELFT>::MipsRldMap = make<OutputSection<ELFT>>(".rld_map", SHT_PROGBITS,
                                                       SHF_ALLOC | SHF_WRITE);
-    Out<ELFT>::MipsRldMap->setSize(sizeof(uintX_t));
+    Out<ELFT>::MipsRldMap->Size = sizeof(uintX_t);
     Out<ELFT>::MipsRldMap->updateAlignment(sizeof(uintX_t));
   }
   if (!Config->VersionDefinitions.empty())
@@ -394,12 +394,12 @@ template <class ELFT>
 bool elf::isRelroSection(const OutputSectionBase<ELFT> *Sec) {
   if (!Config->ZRelro)
     return false;
-  typename ELFT::uint Flags = Sec->getFlags();
+  typename ELFT::uint Flags = Sec->Flags;
   if (!(Flags & SHF_ALLOC) || !(Flags & SHF_WRITE))
     return false;
   if (Flags & SHF_TLS)
     return true;
-  uint32_t Type = Sec->getType();
+  uint32_t Type = Sec->Type;
   if (Type == SHT_INIT_ARRAY || Type == SHT_FINI_ARRAY ||
       Type == SHT_PREINIT_ARRAY)
     return true;
@@ -422,14 +422,10 @@ static bool compareSectionsNonScript(con
   if (AIsInterp != BIsInterp)
     return AIsInterp;
 
-  typedef typename ELFT::uint uintX_t;
-  uintX_t AFlags = A->getFlags();
-  uintX_t BFlags = B->getFlags();
-
   // Allocatable sections go first to reduce the total PT_LOAD size and
   // so debug info doesn't change addresses in actual code.
-  bool AIsAlloc = AFlags & SHF_ALLOC;
-  bool BIsAlloc = BFlags & SHF_ALLOC;
+  bool AIsAlloc = A->Flags & SHF_ALLOC;
+  bool BIsAlloc = B->Flags & SHF_ALLOC;
   if (AIsAlloc != BIsAlloc)
     return AIsAlloc;
 
@@ -440,8 +436,8 @@ static bool compareSectionsNonScript(con
 
   // We want the read only sections first so that they go in the PT_LOAD
   // covering the program headers at the start of the file.
-  bool AIsWritable = AFlags & SHF_WRITE;
-  bool BIsWritable = BFlags & SHF_WRITE;
+  bool AIsWritable = A->Flags & SHF_WRITE;
+  bool BIsWritable = B->Flags & SHF_WRITE;
   if (AIsWritable != BIsWritable)
     return BIsWritable;
 
@@ -451,8 +447,8 @@ static bool compareSectionsNonScript(con
     // We only do that if we are not using linker scripts, since with linker
     // scripts ro and rx sections are in the same PT_LOAD, so their relative
     // order is not important.
-    bool AIsExec = AFlags & SHF_EXECINSTR;
-    bool BIsExec = BFlags & SHF_EXECINSTR;
+    bool AIsExec = A->Flags & SHF_EXECINSTR;
+    bool BIsExec = B->Flags & SHF_EXECINSTR;
     if (AIsExec != BIsExec)
       return BIsExec;
   }
@@ -463,8 +459,8 @@ static bool compareSectionsNonScript(con
   // PT_LOAD, so stick TLS sections directly before R/W sections. The TLS NOBITS
   // sections are placed here as they don't take up virtual address space in the
   // PT_LOAD.
-  bool AIsTls = AFlags & SHF_TLS;
-  bool BIsTls = BFlags & SHF_TLS;
+  bool AIsTls = A->Flags & SHF_TLS;
+  bool BIsTls = B->Flags & SHF_TLS;
   if (AIsTls != BIsTls)
     return AIsTls;
 
@@ -473,8 +469,8 @@ static bool compareSectionsNonScript(con
   // them is a p_memsz that is larger than p_filesz. Seeing that it
   // zeros the end of the PT_LOAD, so that has to correspond to the
   // nobits sections.
-  bool AIsNoBits = A->getType() == SHT_NOBITS;
-  bool BIsNoBits = B->getType() == SHT_NOBITS;
+  bool AIsNoBits = A->Type == SHT_NOBITS;
+  bool BIsNoBits = B->Type == SHT_NOBITS;
   if (AIsNoBits != BIsNoBits)
     return BIsNoBits;
 
@@ -522,7 +518,7 @@ template <class ELFT> void PhdrEntry<ELF
   Last = Sec;
   if (!First)
     First = Sec;
-  H.p_align = std::max<typename ELFT::uint>(H.p_align, Sec->getAlignment());
+  H.p_align = std::max<typename ELFT::uint>(H.p_align, Sec->Addralign);
   if (H.p_type == PT_LOAD)
     Sec->FirstInPtLoad = First;
 }
@@ -699,17 +695,17 @@ template <class ELFT> void Writer<ELFT>:
 template <class ELFT>
 static bool canSharePtLoad(const OutputSectionBase<ELFT> &S1,
                            const OutputSectionBase<ELFT> &S2) {
-  if (!(S1.getFlags() & SHF_ALLOC) || !(S2.getFlags() & SHF_ALLOC))
+  if (!(S1.Flags & SHF_ALLOC) || !(S2.Flags & SHF_ALLOC))
     return false;
 
-  bool S1IsWrite = S1.getFlags() & SHF_WRITE;
-  bool S2IsWrite = S2.getFlags() & SHF_WRITE;
+  bool S1IsWrite = S1.Flags & SHF_WRITE;
+  bool S2IsWrite = S2.Flags & SHF_WRITE;
   if (S1IsWrite != S2IsWrite)
     return false;
 
   if (!S1IsWrite)
     return true; // RO and RX share a PT_LOAD with linker scripts.
-  return (S1.getFlags() & SHF_EXECINSTR) == (S2.getFlags() & SHF_EXECINSTR);
+  return (S1.Flags & SHF_EXECINSTR) == (S2.Flags & SHF_EXECINSTR);
 }
 
 template <class ELFT> void Writer<ELFT>::sortSections() {
@@ -850,7 +846,7 @@ template <class ELFT> void Writer<ELFT>:
   unsigned I = 1;
   for (OutputSectionBase<ELFT> *Sec : OutputSections) {
     Sec->SectionIndex = I++;
-    Sec->setSHName(Out<ELFT>::ShStrTab->addString(Sec->getName()));
+    Sec->ShName = Out<ELFT>::ShStrTab->addString(Sec->getName());
   }
 
   // Finalizers fix each section's size.
@@ -934,7 +930,7 @@ template <class ELFT> void Writer<ELFT>:
     Add(Out<ELFT>::Plt);
   if (!Out<ELFT>::EhFrame->empty())
     Add(Out<ELFT>::EhFrameHdr);
-  if (Out<ELFT>::Bss->getSize() > 0)
+  if (Out<ELFT>::Bss->Size > 0)
     Add(Out<ELFT>::Bss);
 }
 
@@ -981,13 +977,13 @@ OutputSectionBase<ELFT> *Writer<ELFT>::f
 }
 
 template <class ELFT> static bool needsPtLoad(OutputSectionBase<ELFT> *Sec) {
-  if (!(Sec->getFlags() & SHF_ALLOC))
+  if (!(Sec->Flags & SHF_ALLOC))
     return false;
 
   // Don't allocate VA space for TLS NOBITS sections. The PT_TLS PHDR is
   // responsible for allocating space for them, not the PT_LOAD that
   // contains the TLS initialization image.
-  if (Sec->getFlags() & SHF_TLS && Sec->getType() == SHT_NOBITS)
+  if (Sec->Flags & SHF_TLS && Sec->Type == SHT_NOBITS)
     return false;
   return true;
 }
@@ -1035,13 +1031,13 @@ template <class ELFT> std::vector<PhdrEn
   Phdr Note(PT_NOTE, PF_R);
   Phdr ARMExidx(PT_ARM_EXIDX, PF_R);
   for (OutputSectionBase<ELFT> *Sec : OutputSections) {
-    if (!(Sec->getFlags() & SHF_ALLOC))
+    if (!(Sec->Flags & SHF_ALLOC))
       break;
 
     // If we meet TLS section then we create TLS header
     // and put all TLS sections inside for further use when
     // assign addresses.
-    if (Sec->getFlags() & SHF_TLS)
+    if (Sec->Flags & SHF_TLS)
       TlsHdr.add(Sec);
 
     if (!needsPtLoad(Sec))
@@ -1062,9 +1058,9 @@ template <class ELFT> std::vector<PhdrEn
 
     if (isRelroSection(Sec))
       RelRo.add(Sec);
-    if (Sec->getType() == SHT_NOTE)
+    if (Sec->Type == SHT_NOTE)
       Note.add(Sec);
-    if (Config->EMachine == EM_ARM && Sec->getType() == SHT_ARM_EXIDX)
+    if (Config->EMachine == EM_ARM && Sec->Type == SHT_ARM_EXIDX)
       ARMExidx.add(Sec);
   }
 
@@ -1148,10 +1144,10 @@ template <class ELFT> void Writer<ELFT>:
 // list, but have them to simplify the code.
 template <class ELFT> void Writer<ELFT>::fixHeaders() {
   uintX_t BaseVA = ScriptConfig->HasSections ? 0 : Config->ImageBase;
-  Out<ELFT>::ElfHeader->setVA(BaseVA);
-  uintX_t Off = Out<ELFT>::ElfHeader->getSize();
-  Out<ELFT>::ProgramHeaders->setVA(Off + BaseVA);
-  Out<ELFT>::ProgramHeaders->setSize(sizeof(Elf_Phdr) * Phdrs.size());
+  Out<ELFT>::ElfHeader->Addr = BaseVA;
+  uintX_t Off = Out<ELFT>::ElfHeader->Size;
+  Out<ELFT>::ProgramHeaders->Addr = Off + BaseVA;
+  Out<ELFT>::ProgramHeaders->Size = sizeof(Elf_Phdr) * Phdrs.size();
 }
 
 // Assign VAs (addresses at run-time) to output sections.
@@ -1159,7 +1155,7 @@ template <class ELFT> void Writer<ELFT>:
   uintX_t VA = Config->ImageBase + getHeaderSize<ELFT>();
   uintX_t ThreadBssOffset = 0;
   for (OutputSectionBase<ELFT> *Sec : OutputSections) {
-    uintX_t Alignment = Sec->getAlignment();
+    uintX_t Alignment = Sec->Addralign;
     if (Sec->PageAlign)
       Alignment = std::max<uintX_t>(Alignment, Config->MaxPageSize);
 
@@ -1170,13 +1166,13 @@ template <class ELFT> void Writer<ELFT>:
     // We only assign VAs to allocated sections.
     if (needsPtLoad(Sec)) {
       VA = alignTo(VA, Alignment);
-      Sec->setVA(VA);
-      VA += Sec->getSize();
-    } else if (Sec->getFlags() & SHF_TLS && Sec->getType() == SHT_NOBITS) {
+      Sec->Addr = VA;
+      VA += Sec->Size;
+    } else if (Sec->Flags & SHF_TLS && Sec->Type == SHT_NOBITS) {
       uintX_t TVA = VA + ThreadBssOffset;
       TVA = alignTo(TVA, Alignment);
-      Sec->setVA(TVA);
-      ThreadBssOffset = TVA - VA + Sec->getSize();
+      Sec->Addr = TVA;
+      ThreadBssOffset = TVA - VA + Sec->Size;
     }
   }
 }
@@ -1187,7 +1183,7 @@ template <class ELFT> void Writer<ELFT>:
 // executables without any address adjustment.
 template <class ELFT, class uintX_t>
 static uintX_t getFileAlignment(uintX_t Off, OutputSectionBase<ELFT> *Sec) {
-  uintX_t Alignment = Sec->getAlignment();
+  uintX_t Alignment = Sec->Addralign;
   if (Sec->PageAlign)
     Alignment = std::max<uintX_t>(Alignment, Config->MaxPageSize);
   Off = alignTo(Off, Alignment);
@@ -1200,26 +1196,26 @@ static uintX_t getFileAlignment(uintX_t
   // If two sections share the same PT_LOAD the file offset is calculated using
   // this formula: Off2 = Off1 + (VA2 - VA1).
   if (Sec == First)
-    return alignTo(Off, Target->MaxPageSize, Sec->getVA());
-  return First->getFileOffset() + Sec->getVA() - First->getVA();
+    return alignTo(Off, Target->MaxPageSize, Sec->Addr);
+  return First->Offset + Sec->Addr - First->Addr;
 }
 
 template <class ELFT, class uintX_t>
 void setOffset(OutputSectionBase<ELFT> *Sec, uintX_t &Off) {
-  if (Sec->getType() == SHT_NOBITS) {
-    Sec->setFileOffset(Off);
+  if (Sec->Type == SHT_NOBITS) {
+    Sec->Offset = Off;
     return;
   }
 
   Off = getFileAlignment<ELFT>(Off, Sec);
-  Sec->setFileOffset(Off);
-  Off += Sec->getSize();
+  Sec->Offset = Off;
+  Off += Sec->Size;
 }
 
 template <class ELFT> void Writer<ELFT>::assignFileOffsetsBinary() {
   uintX_t Off = 0;
   for (OutputSectionBase<ELFT> *Sec : OutputSections)
-    if (Sec->getFlags() & SHF_ALLOC)
+    if (Sec->Flags & SHF_ALLOC)
       setOffset(Sec, Off);
   FileSize = alignTo(Off, sizeof(uintX_t));
 }
@@ -1245,12 +1241,12 @@ template <class ELFT> void Writer<ELFT>:
     OutputSectionBase<ELFT> *First = P.First;
     OutputSectionBase<ELFT> *Last = P.Last;
     if (First) {
-      H.p_filesz = Last->getFileOff() - First->getFileOff();
-      if (Last->getType() != SHT_NOBITS)
-        H.p_filesz += Last->getSize();
-      H.p_memsz = Last->getVA() + Last->getSize() - First->getVA();
-      H.p_offset = First->getFileOff();
-      H.p_vaddr = First->getVA();
+      H.p_filesz = Last->Offset - First->Offset;
+      if (Last->Type != SHT_NOBITS)
+        H.p_filesz += Last->Size;
+      H.p_memsz = Last->Addr + Last->Size - First->Addr;
+      H.p_offset = First->Offset;
+      H.p_vaddr = First->Addr;
       if (!P.HasLMA)
         H.p_paddr = First->getLMA();
     }
@@ -1298,7 +1294,7 @@ static uint16_t getELFType() {
 template <class ELFT> void Writer<ELFT>::fixAbsoluteSymbols() {
   // __ehdr_start is the location of program headers.
   if (ElfSym<ELFT>::EhdrStart)
-    ElfSym<ELFT>::EhdrStart->Value = Out<ELFT>::ProgramHeaders->getVA();
+    ElfSym<ELFT>::EhdrStart->Value = Out<ELFT>::ProgramHeaders->Addr;
 
   auto Set = [](DefinedRegular<ELFT> *S1, DefinedRegular<ELFT> *S2, uintX_t V) {
     if (S1)
@@ -1382,8 +1378,8 @@ template <class ELFT> void Writer<ELFT>:
 template <class ELFT> void Writer<ELFT>::writeSectionsBinary() {
   uint8_t *Buf = Buffer->getBufferStart();
   for (OutputSectionBase<ELFT> *Sec : OutputSections)
-    if (Sec->getFlags() & SHF_ALLOC)
-      Sec->writeTo(Buf + Sec->getFileOff());
+    if (Sec->Flags & SHF_ALLOC)
+      Sec->writeTo(Buf + Sec->Offset);
 }
 
 // Convert the .ARM.exidx table entries that use relative PREL31 offsets to
@@ -1449,23 +1445,23 @@ template <class ELFT> void Writer<ELFT>:
   // before processing relocations in code-containing sections.
   Out<ELFT>::Opd = findSection(".opd");
   if (Out<ELFT>::Opd) {
-    Out<ELFT>::OpdBuf = Buf + Out<ELFT>::Opd->getFileOff();
-    Out<ELFT>::Opd->writeTo(Buf + Out<ELFT>::Opd->getFileOff());
+    Out<ELFT>::OpdBuf = Buf + Out<ELFT>::Opd->Offset;
+    Out<ELFT>::Opd->writeTo(Buf + Out<ELFT>::Opd->Offset);
   }
 
   for (OutputSectionBase<ELFT> *Sec : OutputSections)
     if (Sec != Out<ELFT>::Opd && Sec != Out<ELFT>::EhFrameHdr)
-      Sec->writeTo(Buf + Sec->getFileOff());
+      Sec->writeTo(Buf + Sec->Offset);
 
   OutputSectionBase<ELFT> *ARMExidx = findSection(".ARM.exidx");
   if (!Config->Relocatable)
     if (auto *OS = dyn_cast_or_null<OutputSection<ELFT>>(ARMExidx))
-      sortARMExidx(Buf + OS->getFileOff(), OS->getVA(), OS->getSize());
+      sortARMExidx(Buf + OS->Offset, OS->Addr, OS->Size);
 
   // The .eh_frame_hdr depends on .eh_frame section contents, therefore
   // it should be written after .eh_frame is written.
   if (!Out<ELFT>::EhFrame->empty() && Out<ELFT>::EhFrameHdr)
-    Out<ELFT>::EhFrameHdr->writeTo(Buf + Out<ELFT>::EhFrameHdr->getFileOff());
+    Out<ELFT>::EhFrameHdr->writeTo(Buf + Out<ELFT>::EhFrameHdr->Offset);
 }
 
 template <class ELFT> void Writer<ELFT>::writeBuildId() {




More information about the llvm-commits mailing list