summaryrefslogtreecommitdiff
path: root/sys/arch/powerpc64/conf
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-07-18 13:16:33 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-07-18 13:16:33 +0000
commit996316ddcd1fc353a6ffabf383fd771a03568975 (patch)
treef2efcaeaef1c305d94efb97589cde683e6e98683 /sys/arch/powerpc64/conf
parentfb5ebc8d61699e6b0dc96233f1804bab8446ed1d (diff)
Improve kernel linker script. Split binary in a .text, .rodata and .data
segment, but continue to cover these with a single PT_LOAD segment such that we can continue to load kernels from the firmware Linux kernel. This is important since our bootloader is a stripped down OpenBSD kernel as well. Proper page protections are installed by pmap_bootstrap(). This allows us to add "relro" sections to the .rodata segment.
Diffstat (limited to 'sys/arch/powerpc64/conf')
-rw-r--r--sys/arch/powerpc64/conf/ld.script34
1 files changed, 30 insertions, 4 deletions
diff --git a/sys/arch/powerpc64/conf/ld.script b/sys/arch/powerpc64/conf/ld.script
index 0b5bd8125d9..1103644328f 100644
--- a/sys/arch/powerpc64/conf/ld.script
+++ b/sys/arch/powerpc64/conf/ld.script
@@ -1,4 +1,4 @@
-/* $OpenBSD: ld.script,v 1.3 2020/06/06 22:36:22 kettenis Exp $ */
+/* $OpenBSD: ld.script,v 1.4 2020/07/18 13:16:32 kettenis Exp $ */
/*
* Copyright (c) 2013 Mark Kettenis <kettenis@openbsd.org>
@@ -22,6 +22,7 @@ PHDRS
{
text PT_LOAD;
dynamic PT_DYNAMIC;
+ openbsd_randomize PT_OPENBSD_RANDOMIZE;
}
SECTIONS
@@ -30,18 +31,35 @@ SECTIONS
.text :
{
*(.text)
- *(.rodata*)
} :text
PROVIDE (etext = .);
PROVIDE (_etext = .);
- .hash : { *(.hash) }
+ . = ALIGN(4096);
+ .rela.dyn : { *(.rela.dyn) }
+
+ .dynamic :
+ {
+ *(.dynamic)
+ } :dynamic :text
+
+ .rodata :
+ {
+ *(.rodata)
+ *(.data.rel.ro)
+ } :text
+
+ .openbsd.randomdata :
+ {
+ *(.openbsd.randomdata)
+ } :openbsd_randomize :text
+ PROVIDE (_erodata = .);
. = ALIGN(4096);
.data :
{
*(.data)
- }
+ } :text
. = ALIGN(4096);
.got : { *(.got) }
@@ -54,4 +72,12 @@ SECTIONS
}
PROVIDE (end = .);
PROVIDE (_end = .);
+
+ /DISCARD/ :
+ {
+ *(.dynsym)
+ *(.dynstr)
+ *(.gnu.hash)
+ *(.hash)
+ }
}