[PATCH] D38360: [ELF] Set Dot initially to --image-base value when using linker scripts

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 9 17:08:42 PDT 2017


ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: ELF/LinkerScript.cpp:349
 
+static uint64_t getInitialDot() {
+  // By default linker scripts use an initial value of 0 for '.', but prefer
----------------
jhenderson wrote:
> ruiu wrote:
> > I wonder if you really have to call this function twice. Can you initialize `Dot` only once in LinkerScript's ctor?
> No, because the value is not final until after command-line processing, whereas the LinkerScript instance is constructed during program initialisation. We also need to reset Dot every time we call assignAddresses, because it might be called multiple times. However, having looked closer it does not need setting in processCommands (it's never updated, and should never be referenced, although it currently could be in SUBALIGN expressions - this is a bug, these expressions should only accept constants, and the current behaviour results in an assertion failure if it is used). This allows me to move the function inline into assignAddresses.
Thank you for removing the assignment to Dot from this function!


================
Comment at: ELF/Target.cpp:173
+    return *Config->ImageBase;
+  return Config->Pic ? 0 : Target->DefaultImageBase;
+}
----------------
`this` is a TargetInfo, so remove `Target->`.


https://reviews.llvm.org/D38360





More information about the llvm-commits mailing list