[PATCH] D77330: Consider increasing the default ARM32 page size to 64k.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 3 10:15:13 PDT 2020


MaskRay added a comment.

In D77330#1960004 <https://reviews.llvm.org/D77330#1960004>, @jyknight wrote:

> In D77330#1959071 <https://reviews.llvm.org/D77330#1959071>, @srhines wrote:
>
> > We (Android Google folks) have an internal thread going on about what implications this might have, but I can say that I am concerned about making this kind of change for ARM Android targets. Even though we manually set a 4KB max page size in our platform builds for 32-bit, we also have to consider the needs of NDK developers (i.e. those folks making native applications/games/etc.). Some of their build configurations might behave very differently with this change, so my current thinking is that 64KB should **not** be the default for ARM Android targets.
>
>
> Can you say more about your concern? I was actually thinking the exact opposite -- that the special-case in the Driver to use 4K pages on Android AArch64 could very likely be removed, now that using the default 64k max-page-size will no longer cause the binary size to increase.


I am slightly in favor of D77330 <https://reviews.llvm.org/D77330> because the change will improve consistency with GNU ld, considering that the binary size is not affected by max-page-size at all (since D66749 <https://reviews.llvm.org/D66749>), and I think the patch does not weaken ASLR.
By default there are 4 PT_LOAD segments: R, RX, RW(RELRO) and RW(non-RELRO).
This patch mostly changes p_vaddr/p_paddr of RX, RW(RELRO) and RW(non-RELRO) and thus the distances between two adjacent segments.

My question is now more about whether Android uses -z separate-code and whether Android expects NDK developers (from the context above they seem to be able to enable arbitrary linker scripts and options) to use -z separate-code with -z max-page-size=65536. -z separate-code + -z max-page-size=65536 can waste a lot of bytes (up to 2 * 65536) due to padding. There can be padding before the RX and the RW(RELRO).

Deleting `-z max-page-size` from the clang driver should have no downside if they don't use -z separate-code.

The only thing that may motivate -z separate-code is probably eXecute-Only Memory (see --execute-only (D49456 <https://reviews.llvm.org/D49456>)) and probably SHF_ARM_PURECODE (rL326207 <https://reviews.llvm.org/rL326207>) plus the intention to not share file bytes between R and RX.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77330





More information about the llvm-commits mailing list