[PATCH] D36140: [ELF] - Do not segfault if linkerscript tries to access Target too early.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 07:25:48 PDT 2017


ruiu added inline comments.


================
Comment at: ELF/ScriptParser.cpp:796
 
-uint64_t static getConstant(StringRef S) {
-  if (S == "COMMONPAGESIZE")
+static uint64_t getPageSize(StringRef Location) {
+  if (Target)
----------------
Make this a member function.


================
Comment at: ELF/ScriptParser.cpp:800-801
+  error(Location + ": unable to calculate page size");
+  // Result value may be used in align(), and alignment can't be 0.
+  return 1;
+}
----------------
This is better.

  return 4096;  // return a dummy value


================
Comment at: ELF/ScriptParser.cpp:804
+
+uint64_t static getConstant(StringRef S, StringRef Location) {
+  if (S == "COMMONPAGESIZE")
----------------
Make this a member function of LinkerScript so that you don't need to pass `Location`.


https://reviews.llvm.org/D36140





More information about the llvm-commits mailing list