[PATCH] D31888: [LLD][ELF] Always use Script::assignAddresses()

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 10 17:22:50 PDT 2017


ruiu added inline comments.


================
Comment at: ELF/LinkerScript.cpp:411
 
+void LinkerScript::fabricateDefaultCommands(std::vector<PhdrEntry> &Phdrs,
+                                            unsigned MaxPageSize,
----------------
You are not using Phdrs?


================
Comment at: ELF/LinkerScript.cpp:412
+void LinkerScript::fabricateDefaultCommands(std::vector<PhdrEntry> &Phdrs,
+                                            unsigned MaxPageSize,
+                                            bool AllocateHeader) {
----------------
MaxPageSize can always be obtained by Config->MaxPageSize, so no need to pass it as an argument.


================
Comment at: ELF/LinkerScript.cpp:420
+    StartAddr += elf::getHeaderSize();
+  // The Sections with -T<section> are sorted in order of ascending address
+  // we must use this if it is lower than StartAddr as calls to setDot() must
----------------
Add a blank line before comment.


================
Comment at: ELF/LinkerScript.cpp:427-429
+  Expr E = [=]() { return StartAddr; };
+  auto *StartCmd = make<SymbolAssignment>(".", E, "");
+  Commands.push_back(StartCmd);
----------------
This can be

  Commands.push_back(make<SymbolAssignment>(".", [=] { return StartAddr; }, ""));


================
Comment at: ELF/LinkerScript.cpp:437-442
+    auto I = Config->SectionStartMap.find(Sec->Name);
+    if (I != Config->SectionStartMap.end()) {
+      Expr E = [=]() { return I->second; };
+      auto *DotCmd = make<SymbolAssignment>(".", E, "");
+      Commands.push_back(DotCmd);
+    }
----------------
This can be something like

  if (uint64_t Addr = Config->SectionStartMap.lookup(Sec->Name))
    Commands.push_back(make<SymbolAssignment>(".", [=] { return Addr; }, ""));



https://reviews.llvm.org/D31888





More information about the llvm-commits mailing list