[lld] r266668 - Rename LocationNode -> SectionsCommand.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 18 14:00:45 PDT 2016


Author: ruiu
Date: Mon Apr 18 16:00:45 2016
New Revision: 266668

URL: http://llvm.org/viewvc/llvm-project?rev=266668&view=rev
Log:
Rename LocationNode -> SectionsCommand.

They are called sections-command in the doc, so it is nice to keep
it consistent with it.
https://sourceware.org/binutils/docs/ld/SECTIONS.html#SECTIONS

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=266668&r1=266667&r2=266668&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Apr 18 16:00:45 2016
@@ -113,7 +113,7 @@ void LinkerScript::assignAddresses(
     StringRef Name = Sec->getName();
     auto I = std::find(SectionOrder.begin(), SectionOrder.end(), Name);
     if (I == SectionOrder.end())
-      Locations.push_back({Command::Section, {}, Name});
+      Commands.push_back({SectionKind, {}, Name});
   }
 
   // Assign addresses as instructed by linker script SECTIONS sub-commands.
@@ -121,13 +121,13 @@ void LinkerScript::assignAddresses(
   uintX_t VA =
       Out<ELFT>::ElfHeader->getSize() + Out<ELFT>::ProgramHeaders->getSize();
 
-  for (LocationNode &Node : Locations) {
-    if (Node.Type == Command::Expr) {
-      VA = evaluate(Node.Expr, VA);
+  for (SectionsCommand &Cmd : Commands) {
+    if (Cmd.Kind == ExprKind) {
+      VA = evaluate(Cmd.Expr, VA);
       continue;
     }
 
-    OutputSectionBase<ELFT> *Sec = findSection(Sections, Node.SectionName);
+    OutputSectionBase<ELFT> *Sec = findSection(Sections, Cmd.SectionName);
     if (!Sec)
       continue;
 
@@ -400,22 +400,22 @@ void ScriptParser::readSectionPatterns(S
 void ScriptParser::readLocationCounterValue() {
   expect(".");
   expect("=");
-  Script->Locations.push_back({Command::Expr, {}, ""});
-  LocationNode &Node = Script->Locations.back();
+  Script->Commands.push_back({ExprKind, {}, ""});
+  SectionsCommand &Cmd = Script->Commands.back();
   while (!Error) {
     StringRef Tok = next();
     if (Tok == ";")
       break;
-    Node.Expr.push_back(Tok);
+    Cmd.Expr.push_back(Tok);
   }
-  if (Node.Expr.empty())
+  if (Cmd.Expr.empty())
     error("error in location counter expression");
 }
 
 void ScriptParser::readOutputSectionDescription() {
   StringRef OutSec = next();
   Script->SectionOrder.push_back(OutSec);
-  Script->Locations.push_back({Command::Section, {}, OutSec});
+  Script->Commands.push_back({SectionKind, {}, OutSec});
   expect(":");
   expect("{");
   while (!Error && !skip("}")) {

Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=266668&r1=266667&r2=266668&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Mon Apr 18 16:00:45 2016
@@ -44,10 +44,10 @@ private:
 // This enum represents what we can observe in SECTIONS tag of script:
 // Expr is a location counter change, like ". = . + 0x1000"
 // Section is a description of output section, like ".data :..."
-enum class Command { Expr, Section };
+enum SectionsCommandKind { ExprKind, SectionKind };
 
-struct LocationNode {
-  Command Type;
+struct SectionsCommand {
+  SectionsCommandKind Kind;
   std::vector<StringRef> Expr;
   StringRef SectionName;
 };
@@ -85,7 +85,7 @@ private:
   llvm::StringMap<std::vector<uint8_t>> Filler;
 
   // Used to assign addresses to sections.
-  std::vector<LocationNode> Locations;
+  std::vector<SectionsCommand> Commands;
 
   llvm::BumpPtrAllocator Alloc;
 };




More information about the llvm-commits mailing list