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

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 9 03:45:34 PDT 2017


jhenderson added inline comments.


================
Comment at: ELF/LinkerScript.cpp:349
 
+static uint64_t getInitialDot() {
+  // By default linker scripts use an initial value of 0 for '.', but prefer
----------------
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.


https://reviews.llvm.org/D38360





More information about the llvm-commits mailing list