Bug 23704

Summary: Too many PT_LOAD segments with -z separate-code
Product: binutils Reporter: Jakub Jelinek <jakub>
Component: ldAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: amodra, sam
Priority: P2    
Version: 2.31   
Target Milestone: ---   
See Also: https://bugzilla.redhat.com/show_bug.cgi?id=1623218
Host: Target:
Build: Last reconfirmed:

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.