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

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 03:17:05 PDT 2016


evgeny777 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};
----------------
ruiu wrote:
> 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.
> Theoretically, you need to propagate Section value not only for + or - but for all binary operators, no?

I think you don't have to do this for '*' and '/', because it's senseless (gold doesn't do this either). The 'AddExprSection' should work, but one has to propagate it to SymbolAssignment at any given point of call to Expression(). 

BTW, may be you take a look at https://reviews.llvm.org/D25560 ?
It works for me either and is much shorter at the same time.



Repository:
  rL LLVM

https://reviews.llvm.org/D25441





More information about the llvm-commits mailing list