[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
Thu Oct 5 20:09:48 PDT 2017


ruiu 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
----------------
I wonder if you really have to call this function twice. Can you initialize `Dot` only once in LinkerScript's ctor?


================
Comment at: ELF/LinkerScript.cpp:355
+
+uint64_t LinkerScript::getImageBase() {
+  // Use -image-base if set. Fall back to the target default if not.
----------------
This function does not use any LinkerScript's private/protected members. It is a good practice to not make such function a member function of some class. They can just be a non-member function. By doing that, it is obvious that the function doesn't access any private members.

That said, you can move this function to `Target`, and by doing that, you can make Target::DefaultImageBase a protected member. Can you do that?


https://reviews.llvm.org/D38360





More information about the llvm-commits mailing list