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.

llvm-svn: 286327
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index ddd2f9f..5204c5c 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -381,7 +381,7 @@
 
   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 @@
 }
 
 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 @@
 
   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 @@
     for (InputSection<ELFT> *I : OutSec->Sections)
       output(I);
   } else {
-    Dot += CurOutSec->getSize();
+    Dot += CurOutSec->Size;
   }
 }
 
@@ -434,8 +434,8 @@
   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 @@
     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 @@
 
   // 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 @@
     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 @@
 
   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 @@
     // 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 @@
     // 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 @@
 
   // 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 @@
 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 @@
 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 @@
 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;
 }