[PATCH] ld: Default the maximum page size to the common page size for -z separate-code
Fri Jan 12 12:19:00 GMT 2018
On Fri, Jan 12, 2018 at 3:39 AM, H.J. Lu <firstname.lastname@example.org> wrote:
> On Thu, Jan 11, 2018 at 9:55 PM, Alan Modra <email@example.com> wrote:
>> On Thu, Jan 11, 2018 at 09:13:19PM -0800, H.J. Lu wrote:
>>> When -z separate-code is used, code segment is aligned and padded to
>>> the maximum page size on disk. This patch defaults the maximum page
>>> size to the common page size for -z separate-code to reduce file size.
>> I think this is a bad idea. Options should have as few magical
>> side-effects as possible. If you want -z separate-code to align to
>> common-page-size, then do that in the script (and document in
>> ld.texinfo that code separation is only effective for system page size
>> up to common-page-size, like -z relro).
> RELRO segment is optional. Ignoring it at run-time won't crash
> the program.
> How about adding ELF_MAXCODEPAGESIZE which defaults to
> ELF_COMMONPAGESIZE and -z max-code-page-size?
Never mind. This is the same approach with a different implementation.
The problem with aligning code segment to common-page-size while
keeping the maximum page size is we don't get code separation with
the maximum page size is used:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x00000000 0x00000000 0x00200 0x00200 R 0x200000
LOAD 0x001000 0x00001000 0x00001000 0x00036 0x00036 R E 0x200000
LOAD 0x002000 0x00202000 0x00202000 0x00064 0x00064 R 0x200000
LOAD 0x002f80 0x00402f80 0x00402f80 0x000a0 0x000a0 RW 0x200000
The program runs with 2MB page size. But the 2MB code page contains
RO and RW data.
More information about the Binutils