[PATCH] D25441: [ELF] Make symbols containing ADDR() function synthetic.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 15:51:24 PDT 2016


ruiu added inline comments.


================
Comment at: ELF/LinkerScript.cpp:1480-1484
   if (Op == "+")
-    return [=](uint64_t Dot) { return L(Dot) + R(Dot); };
+    return {[=](uint64_t Dot) { return L(Dot) + R(Dot); },
+            L.Section.empty() ? R.Section : L.Section};
   if (Op == "-")
+    return {[=](uint64_t Dot) { return L(Dot) - R(Dot); }, L.Section};
----------------
Theoretically, you need to propagate `Section` value not only for + or - but for all binary operators, no? I wonder if we should just add a member variable `StringRef AddExprSection` to ScriptParser and set it when we read "ADDR" expression. Then we can check the value in `readAssignment`. It's a bit dirty but is probably practical.


================
Comment at: ELF/LinkerScript.h:43
+  uint64_t operator()(uint64_t V) const { return Fn(V); }
+  operator bool() const { return Fn != nullptr; }
+
----------------
A std::function is not a pointer. It has operator bool, so it should be

  operator bool() const { return Fn; }


Repository:
  rL LLVM

https://reviews.llvm.org/D25441





More information about the llvm-commits mailing list