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 <[email protected]>
This commit is contained in:
PulkoMandy
2021-01-01 00:45:13 +00:00
committed by waddlesplash
parent 6fd0953545
commit d5d6ada3fd
+6 -4
View File
@@ -6,7 +6,7 @@ ENTRY(_start)
PHDRS PHDRS
{ {
headers PT_PHDR PHDRS ; headers PT_PHDR PHDRS ;
text PT_LOAD FILEHDR PHDRS ; text PT_LOAD FILEHDR PHDRS FLAGS(5) ;
data PT_LOAD ; data PT_LOAD ;
dynamic PT_DYNAMIC ; dynamic PT_DYNAMIC ;
} }
@@ -42,8 +42,8 @@ SECTIONS
.altcodepatch : { *(.altcodepatch) } .altcodepatch : { *(.altcodepatch) }
altcodepatch_end = .; altcodepatch_end = .;
/* writable data */ /* writable data - in a separate page for memory protection purposes */
. = ALIGN (0x1000); . = ALIGN (0x2000);
__data_start = .; __data_start = .;
.data : { *(.data .data.* .gnu.linkonce.d.*) } :data .data : { *(.data .data.* .gnu.linkonce.d.*) } :data
@@ -58,10 +58,12 @@ SECTIONS
.dynamic : { *(.dynamic) } :dynamic :data .dynamic : { *(.dynamic) } :dynamic :data
/* uninitialized data (in same segment as writable data) */ /* uninitialized data (in same segment as writable data) */
. = ALIGN(0x8);
__bss_start = .; __bss_start = .;
.bss : { *(.bss .bss.* .gnu.linkonce.b.*) } :data .bss : { *(.bss .bss.* .gnu.linkonce.b.*) } :data
. = ALIGN(0x1000); /* make sure to end on a page boundary */
. = ALIGN(0x2000);
_end = . ; _end = . ;
/* Strip unnecessary stuff */ /* Strip unnecessary stuff */