Bug 23704 - Too many PT_LOAD segments with -z separate-code
Summary: Too many PT_LOAD segments with -z separate-code
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2018-09-24 13:29 UTC by Jakub Jelinek
Modified: 2018-10-02 03:55 UTC (History)
1 user (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2018-09-24 13:29:41 UTC
As I've already mentioned in https://bugzilla.redhat.com/show_bug.cgi?id=1623218#c13
I think it is complete waste to generate 4 PT_LOAD segments for -z separate-code,
IMNSHO 3 PT_LOADs should be enough, which should be achievable by moving for -z separate-code in the linker script all sections that need read-only non-executable before all read-only/executable sections.  That way we'd have one PF_R PT_LOAD, then one PF_R|PF_X and one PF_R|PF_W, the last one as before would start with relro sections if -z relro, rather than the current PF_R PT_LOAD, followed by PF_R|PF_X, followed by another PF_R one and finally PF_R|PF_W.
Comment 1 Alan Modra 2018-10-02 03:55:18 UTC
I agree that moving read-only (and relro) sections is a good idea, but it may not work for targets that have limited addressing and use offsets from a register to access .got, .got.plt, .plt and .sdata.  Any target that uses the same register to access sections on both sides of DATA_SEGMENT_RELRO_END will likely not be able to tolerate moving read-only sections.