[PATCH] D27276: [ELF] Allow defined symbols to be assigned from linker script

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 14:52:14 PST 2016


ruiu added inline comments.


================
Comment at: ELF/LinkerScript.cpp:92-96
+  } else {
+    const OutputSectionBase *Sec = Cmd->Expression.Section();
+    if (Sec)
+      cast<DefinedSynthetic<ELFT>>(Cmd->Sym)->Value = Value - Sec->Addr;
+  }
----------------
Use early return and assignment-in-if.

    return;
  }
  if (const OutputSectionBase *Sec = Cmd->Expression.Section())
    cast<....>... = ...;


================
Comment at: ELF/LinkerScript.cpp:111-118
+  if (!B || B->isUndefined()) {
+    if (Cmd->Expression.IsAbsolute())
+      Cmd->Sym = addRegular<ELFT>(Cmd);
+    else
+      Cmd->Sym = addSynthetic<ELFT>(Cmd);
+  } else {
+    Cmd->Sym = B;
----------------
I don't think you need to check if B exists. You can add a new symbol unconditionally.


https://reviews.llvm.org/D27276





More information about the llvm-commits mailing list