[PATCH] D23165: [ELF] - Linkerscript: implement SIZEOF_HEADERS.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 15:05:41 PDT 2016


ruiu added inline comments.

================
Comment at: ELF/LinkerScript.cpp:241
@@ -240,3 +240,3 @@
   // Assign addresses as instructed by linker script SECTIONS sub-commands.
-  Dot = Out<ELFT>::ElfHeader->getSize() + Out<ELFT>::ProgramHeaders->getSize();
+  Dot = Opt.ManualHeadersSize ? 0 : getSizeOfHeaders();
   uintX_t MinVA = std::numeric_limits<uintX_t>::max();
----------------
grimar wrote:
> ruiu wrote:
> > I do see why you are doing this, but this is pretty obscure. Do we really have to do this?
> When SIZE_OF_HEADERS is not used it is convenient behavior to have location counted be shifted automatically. Otherwise users will have to leave space for headers manually which probably not the best experience we can offer.
> 
> Or do you mean we should always shift dot here on size of headers ? That means that if script contains SIZE_OF_HEADES there will be some waste of VA space. That does not allow script to control everything also, what I guess can be expected for those who want to set up everything manually.
I think we don't have to do this. If the first linker script line is

  . = SIZEOF_HEADERS;

and if `.` is the same as `SIZEOF_HEADERS` (it is), the first line is a nop. So it should just work.


https://reviews.llvm.org/D23165





More information about the llvm-commits mailing list