[lld] r297722 - [ELF] - Move ThreadBssOffset and Dot to LinkerScriptBase. NFC.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 14 03:00:19 PDT 2017


Author: grimar
Date: Tue Mar 14 05:00:19 2017
New Revision: 297722

URL: http://llvm.org/viewvc/llvm-project?rev=297722&view=rev
Log:
[ELF] - Move ThreadBssOffset and Dot to LinkerScriptBase. NFC.

One more step to combine LinkerScript and LinkerScriptBase.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/LinkerScript.h

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=297722&r1=297721&r2=297722&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Mar 14 05:00:19 2017
@@ -81,7 +81,7 @@ static bool isUnderSysroot(StringRef Pat
 
 template <class ELFT>
 void LinkerScript<ELFT>::setDot(Expr E, const Twine &Loc, bool InSec) {
-  uintX_t Val = E();
+  uint64_t Val = E();
   if (Val < Dot) {
     if (InSec)
       error(Loc + ": unable to move location counter backward for: " +
@@ -398,7 +398,7 @@ template <class ELFT> void LinkerScript<
     return;
   bool IsTbss = isTbss<ELFT>(CurOutSec);
 
-  uintX_t Pos = IsTbss ? Dot + ThreadBssOffset : Dot;
+  uint64_t Pos = IsTbss ? Dot + ThreadBssOffset : Dot;
   Pos = alignTo(Pos, S->Alignment);
   S->OutSecOff = Pos - CurOutSec->Addr;
   Pos += S->getSize();
@@ -555,7 +555,7 @@ void LinkerScript<ELFT>::assignOffsets(O
     setDot(Cmd->AddrExpr, Cmd->Location);
 
   if (Cmd->LMAExpr) {
-    uintX_t D = Dot;
+    uint64_t D = Dot;
     LMAOffset = [=] { return Cmd->LMAExpr() - D; };
   }
 
@@ -612,7 +612,7 @@ template <class ELFT> void LinkerScript<
   // corresponding output section. The bfd linker seems to only create them if
   // '.' is assigned to, but creating these section should not have any bad
   // consequeces and gives us a section to put the symbol in.
-  uintX_t Flags = SHF_ALLOC;
+  uint64_t Flags = SHF_ALLOC;
   uint32_t Type = SHT_NOBITS;
   for (const std::unique_ptr<BaseCommand> &Base : Opt.Commands) {
     auto *Cmd = dyn_cast<OutputSectionCommand>(Base.get());
@@ -784,7 +784,7 @@ void LinkerScript<ELFT>::assignAddresses
     assignOffsets(Cmd);
   }
 
-  uintX_t MinVA = std::numeric_limits<uintX_t>::max();
+  uint64_t MinVA = std::numeric_limits<uint64_t>::max();
   for (OutputSection *Sec : *OutputSections) {
     if (Sec->Flags & SHF_ALLOC)
       MinVA = std::min<uint64_t>(MinVA, Sec->Addr);

Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=297722&r1=297721&r2=297722&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Tue Mar 14 05:00:19 2017
@@ -234,6 +234,9 @@ protected:
   // "ScriptConfig" is a bit too long, so define a short name for it.
   ScriptConfiguration &Opt = *ScriptConfig;
 
+  uint64_t Dot;
+  uint64_t ThreadBssOffset = 0;
+
 public:
   bool hasPhdrsCommands() { return !Opt.PhdrsCommands.empty(); }
 
@@ -248,8 +251,6 @@ public:
 
 // This is a runner of the linker script.
 template <class ELFT> class LinkerScript final : public LinkerScriptBase {
-  typedef typename ELFT::uint uintX_t;
-
 public:
   LinkerScript();
   ~LinkerScript();
@@ -297,11 +298,9 @@ private:
 
   MemoryRegion *findMemoryRegion(OutputSectionCommand *Cmd, OutputSection *Sec);
 
-  uintX_t Dot;
   std::function<uint64_t()> LMAOffset;
   OutputSection *CurOutSec = nullptr;
   MemoryRegion *CurMemRegion = nullptr;
-  uintX_t ThreadBssOffset = 0;
   void switchTo(OutputSection *Sec);
   void flush();
   void output(InputSection *Sec);




More information about the llvm-commits mailing list