[PATCH] D64854: [ELF] Delete redundant pageAlign of the first section after PT_GNU_RELRO after D58892
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 01:13:44 PDT 2019
MaskRay added subscribers: sfertile, atanasyan.
MaskRay added a comment.
Currently we align p_vaddr to the next multiple of max-page-size, instead of `ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1))` as ld.bfd does in its `-z noseparate-code` mode and some cases in its `-z separate-code` mode. See the comment below for a ld.lld -z max-page-size=0x200000 case:
[11] .rodata PROGBITS 0000000000000558 000558 000004 04 AM 0 0 4
[12] .eh_frame_hdr PROGBITS 000000000000055c 00055c 00002c 00 A 0 0 4
[13] .eh_frame PROGBITS 0000000000000588 000588 0000cc 00 A 0 0 8
////// gap due to separated R-- and R-X
///// This gap can be saved in --no-rosegment mode.
[14] .text PROGBITS 0000000000200000 200000 000161 00 AX 0 0 16
[15] .init PROGBITS 0000000000200164 200164 000017 00 AX 0 0 4
[16] .fini PROGBITS 000000000020017c 20017c 000009 00 AX 0 0 4
[17] .plt PROGBITS 0000000000200190 200190 000020 00 AX 0 0 16
[18] .fini_array FINI_ARRAY 0000000000400000 400000 000008 08 WA 0 0 8
[19] .init_array INIT_ARRAY 0000000000400008 400008 000008 08 WA 0 0 8
[20] .dynamic DYNAMIC 0000000000400010 400010 0001a0 10 WA 8 0 8
[21] .got PROGBITS 00000000004001b0 4001b0 000028 00 WA 0 0 8
[22] .bss.rel.ro NOBITS 00000000004001d8 4001d8 000000 00 WA 0 0 1
/// Gap due to PT_GNU_RELRO. It wasts almost 0x200000 bytes.
/// If we change p_vaddr of the RW PT_LOAD from 0x600000 to 0x6001d8, its p_offset doesn't need to be aligned, and we can save nearly 0x200000 bytes in the file.
[23] .data PROGBITS 0000000000600000 600000 000010 00 WA 0 0 8
[24] .tm_clone_table PROGBITS 0000000000600010 600010 000000 00 WA 0 0 8
[25] .got.plt PROGBITS 0000000000600010 600010 000020 00 WA 0 0 8
[26] .bss NOBITS 0000000000600030 600030 000001 00 WA 0 0 1
We perform several max-page-size alignments for this file and each costs nearly 0x200000 bytes. If we do the optimization as described in the comment, we can save a lot of disk space. This is particularly relevant to targets with a large `defaultMaxPageSize` (AArch64, MIPS (@atanasyan), and PPC (@sfertile): 65536).
What do you think of this trick?
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64854/new/
https://reviews.llvm.org/D64854
More information about the llvm-commits
mailing list