[PATCH] D64903: [ELF] Pad the last page of last PF_X PT_LOAD with traps when -z separate-code is specified

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 24 04:30:52 PDT 2019


MaskRay added a comment.

> I'm happy with the change to introduce the option and its effects. I'm not sure we have consensus on what the default should be for the option though. Today I have a weak preference for no separate code for Arm and AArch64, but I'd be happy with a conservative approach of keeping the existing --separate-code until there becomes a relatively convenient to make platform/distro specific decisions as ultimately that is where the decision should be made. The separate code default would also lower the amount of tests that would need to be updated for D64906 <https://reviews.llvm.org/D64906> and D64930 <https://reviews.llvm.org/D64930> making them easier to review and less of a risky change.

As you see, this patch doesn't touch too many tests. The test fixing problem occurs when we do more layout changes (D64906 <https://reviews.llvm.org/D64906>) and enable the technique on more targets:

> bool enable = config->emachine == EM_AARCH64 || config->emachine == EM_PPC64; // all new targets here

I think we still have to fix 40%~60% tests (depending on the target) if we use -z separate-code by default:

>   config->zSeparateCode = getZFlag(args, "separate-code", "noseparate-code", true); // changed to false

With the default relro layout, the commonly used .dynamic and .got are in the first RW (RELRO RW), while the commonly used .got.plt, .data and .bss are in the second RW (non-RELRO RW). The alignment between the two RWs will also affect the addresses. **-z separate-code doesn't affect the transition from one RW to the other RW.**

ARM/AArch64/PPC/MIPS suffer from the defaultMaxPageSize=64k issue the most. AArch64 and PPC have been fixed by D64906 <https://reviews.llvm.org/D64906> and D64930 <https://reviews.llvm.org/D64930>. (It would not make it much easier if -z separate-code were used by default.) MIPS has 50+ tests (I may work on it as I want to learn a bit more about MIPS). The 300+ x86 tests that will be affected are a pain. Thankfully it is probably not worth fixing x86 because defaultMaxPageSize=4096 on x86.


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64903/new/

https://reviews.llvm.org/D64903





More information about the llvm-commits mailing list