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

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 15:42:14 PDT 2017

ruiu added inline comments.

Comment at: ELF/LinkerScript.cpp:1884
+      setError("malformed number: " + Tok);
+    Opt.Undefined.push_back(Tok);
+  }
phosek wrote:
> 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?
That sounds too much. I don't think linker scripts are input files but in my view they are rather extended command line options. I prefer this patch over the proposed solution.

By the way, instead of defining LinkerScript<ELFT>::addUndefined, you can do something like this in the driver.

  for (StringRef Sym : Script->Opt.UndefinedSymbols)



More information about the llvm-commits mailing list