[ELF] - linkerscript AT keyword (in output section description) implemented.

The linker will normally set the LMA equal to the VMA. 
You can change that by using the AT keyword.
The expression lma that follows the AT keyword specifies 
the load address of the section.

Patch implements this keyword.

Differential revision: https://reviews.llvm.org/D19272

llvm-svn: 278911
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index df400a4..1b6ff23 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -504,6 +504,14 @@
   return {};
 }
 
+template <class ELFT> typename Expr LinkerScript<ELFT>::getLma(StringRef Name) {
+  for (const std::unique_ptr<BaseCommand> &Base : Opt.Commands)
+    if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base.get()))
+      if (Cmd->LmaExpr && Cmd->Name == Name)
+        return Cmd->LmaExpr;
+  return {};
+}
+
 // Returns the index of the given section name in linker script
 // SECTIONS commands. Sections are laid out as the same order as they
 // were in the script. If a given name did not appear in the script,
@@ -613,6 +621,7 @@
   SortKind readSortKind();
   SymbolAssignment *readProvideHidden(bool Provide, bool Hidden);
   SymbolAssignment *readProvideOrAssignment(StringRef Tok);
+  void readAt(OutputSectionCommand *Cmd);
   Expr readAlign();
   void readSort();
   Expr readAssert();
@@ -918,6 +927,12 @@
   };
 }
 
+void ScriptParser::readAt(OutputSectionCommand *Cmd) {
+  expect("(");
+  Cmd->LmaExpr = readExpr();
+  expect(")");
+}
+
 OutputSectionCommand *
 ScriptParser::readOutputSectionDescription(StringRef OutSec) {
   OutputSectionCommand *Cmd = new OutputSectionCommand(OutSec);
@@ -929,6 +944,9 @@
 
   expect(":");
 
+  if (skip("AT"))
+    readAt(Cmd);
+
   if (skip("ALIGN"))
     Cmd->AlignExpr = readAlign();