Linker shouldn't include program headers in PT_LOAD in the following case:
- PHDRS directive exists
- PT_LOAD segment doesn't contain PHDRS and/or FILEHDR attribute
Below is an example of such script:
PHDRS { hdr PT_PHDR FILEHDR PHDRS; all PT_LOAD; } SECTIONS { . = 0x10000; .text : { *(.text) } : all /* other sections go here */ }
Current revision will detect that there is a place to put ELF and program headers and will do this even though 'all' segment doesn't
have PHDRS and FILEHDR attributes.
To make this patch as simple as possible, both FILEHDR and PHDRS attributes are required to put ELF and program headers to PT_LOAD.
GNU gold has the same requirement.