sparc: Fix linker script for PIE

Our bootloader really doesn't want the executable section to also be
writable (even if it needs to, for relocation purposes).

Force it to be read-only in program headers by explicitly setting the
flags.

Change-Id: I5b780f6fd9df5f073f0cbc6cc96bc21479004d2c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3584
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
PulkoMandy 2021-01-01 00:39:48 +01:00 committed by waddlesplash
parent 6fd0953545
commit d5d6ada3fd

View File

@ -6,7 +6,7 @@ ENTRY(_start)
PHDRS
{
headers PT_PHDR PHDRS ;
text PT_LOAD FILEHDR PHDRS ;
text PT_LOAD FILEHDR PHDRS FLAGS(5) ;
data PT_LOAD ;
dynamic PT_DYNAMIC ;
}
@ -42,8 +42,8 @@ SECTIONS
.altcodepatch : { *(.altcodepatch) }
altcodepatch_end = .;
/* writable data */
. = ALIGN (0x1000);
/* writable data - in a separate page for memory protection purposes */
. = ALIGN (0x2000);
__data_start = .;
.data : { *(.data .data.* .gnu.linkonce.d.*) } :data
@ -58,10 +58,12 @@ SECTIONS
.dynamic : { *(.dynamic) } :dynamic :data
/* uninitialized data (in same segment as writable data) */
. = ALIGN(0x8);
__bss_start = .;
.bss : { *(.bss .bss.* .gnu.linkonce.b.*) } :data
. = ALIGN(0x1000);
/* make sure to end on a page boundary */
. = ALIGN(0x2000);
_end = . ;
/* Strip unnecessary stuff */