[PATCH] D23505: [ELF] - Linkrscript: change the way of creating PT_LOADs segments when LS is used.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 16 00:47:10 PDT 2016


grimar added a comment.

In https://reviews.llvm.org/D23505#515896, @ruiu wrote:

> How did you know that FreeBSD's linker scripts depend on this behavior?


ld output of FreeBSD kernel is 2 PT_LOADS:

  LOAD           0x0000000000000000 0xffffffff80200000 0xffffffff80200000
                   0x0000000000fe2de8 0x0000000000fe2de8  R E    200000
  LOAD           0x0000000000fe3000 0xffffffff813e3000 0xffffffff813e3000
                   0x0000000000129430 0x00000000003313c0  RW     200000

lld output currently is:

  LOAD           0x0000000000000000 0xffffffff80001000 0xffffffff80001000
                  0x00000000000e410e 0x00000000000e410e  R      1000
  LOAD           0x00000000000e4110 0xffffffff800e5110 0xffffffff800e5110
                  0x0000000000ba2b0c 0x0000000000ba2b0c  R E    1000
  LOAD           0x0000000000c86c20 0xffffffff80c87c20 0xffffffff80c87c20
                  0x000000000038ab28 0x000000000038ab28  R      1000
  LOAD           0x0000000001012000 0xffffffff81013000 0xffffffff81013000
                  0x000000000012ae30 0x0000000000331e30  RW     1000

2 and 3 lld loads are not aligned to memory page. Script does not so that, assuming that
alignment for first section and for last (writable) is enough because 2 loads will be created.

So fix for that can be:

1. Changing script (not always acceptable).
2. Forced alignment of sections when flags are changed (should work, but not so obvious as 3 + will create more loads and waste more VA space).
3. This patch's solution (create 2 PT_LOADS just like ld do).

> If you think the new behavior you are implementing in this patch simpler than the current one, why don't you just replace it with the new one, instead of keeping two different functions?


This patch changes the way we create PT_LOADS when use linkerscript. I was unsure if I should change the non-linkerscript case as well. 
Though I think it will work fine either. This will require fix for many testcases I guess, but this is in the nature of the case.


https://reviews.llvm.org/D23505





More information about the llvm-commits mailing list