[PATCH] D31147: [ELF] Allow references to reserved symbols in linker scripts

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 15:33:08 PDT 2017

phosek added inline comments.

Comment at: ELF/LinkerScript.cpp:1884
+      setError("malformed number: " + Tok);
+    Opt.Undefined.push_back(Tok);
+  }
ruiu wrote:
> You want to add this to `Config->Undefined` instead of your own new array.
> Please add a comment saying that some special symbols (such as __ehdr_start) are defined only when there are undefined symbols for them, so we add undefined symbols to trigger that logic.
I tried as the initial solution, the problem is that the logic for processing `Config->Undefined` currently only handles `Lazy` files; it checks if the symbol is defined in any of the input `Lazy` files and if so it loads it in. However, the reserved symbols are not defined in any input file.

I think the best solution would be to introduce a new `InputFile` subclass for representing input linker scripts (which is what they really are). It'd require some changes, e.g. we'd have to stop using a single global `LinkerScript` instance for all linker scripts, instead each input script will have to have its own. I can try to implement that solution if that would be fine with you?



More information about the llvm-commits mailing list