So in order to align the first text section, unless offset by SIZEOF_HEADERS, lld will insert an extra section. This is fine. Problematically it does not create two program headers for the original text section and the new one that only contains the headers, it tries to create a single segment that has a VADDR that begins BEFORE the text section. This is very problematic if your text segment is directly mapped, or the vaddr before your text segment is not valid for some other reason, it is not OK for the linker to try create mappings before the start address specified for the text section.
This can fixed by manually specifying program headers and specifying a segment for the headers (that may have an invalid VADDR but is NOT loaded), and a segment for the text that does have a correct starting address with PT_LOAD. LLD should do this by default.
So in order to align the first text section, unless offset by SIZEOF_HEADERS, lld will insert an extra section. This is fine. Problematically it does not create two program headers for the original text section and the new one that only contains the headers, it tries to create a single segment that has a VADDR that begins BEFORE the text section. This is very problematic if your text segment is directly mapped, or the vaddr before your text segment is not valid for some other reason, it is not OK for the linker to try create mappings before the start address specified for the text section.
This can fixed by manually specifying program headers and specifying a segment for the headers (that may have an invalid VADDR but is NOT loaded), and a segment for the text that does have a correct starting address with PT_LOAD. LLD should do this by default.