Module Name: src
Committed By: maxv
Date: Thu Nov 9 15:46:48 UTC 2017
Modified Files:
src/sys/arch/amd64/conf: Makefile.amd64
Added Files:
src/sys/arch/amd64/conf: kern.ldscript.kaslr
Log Message:
Use another ld script for kaslr kernels, in which there are no alignment
directives. They don't matter since the bootloader overwrites them.
But, normally we still need to make sure .data.read_mostly is aligned.
Unfortunately I couldn't find any way to force sh_addralign to be 64, so
I'm leaving the alignment there as a useless reminder.
To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/amd64/conf/Makefile.amd64
cvs rdiff -u -r0 -r1.1 src/sys/arch/amd64/conf/kern.ldscript.kaslr
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/amd64/conf/Makefile.amd64
diff -u src/sys/arch/amd64/conf/Makefile.amd64:1.60 src/sys/arch/amd64/conf/Makefile.amd64:1.61
--- src/sys/arch/amd64/conf/Makefile.amd64:1.60 Wed Nov 1 09:31:24 2017
+++ src/sys/arch/amd64/conf/Makefile.amd64 Thu Nov 9 15:46:48 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.amd64,v 1.60 2017/11/01 09:31:24 maxv Exp $
+# $NetBSD: Makefile.amd64,v 1.61 2017/11/09 15:46:48 maxv Exp $
# Makefile for NetBSD
#
@@ -63,11 +63,12 @@ KERN_AS= library
TEXTADDR?= 0xffffffff80200000
.if defined(KASLR)
EXTRA_LINKFLAGS= -z max-page-size=0x200000 -r -d
+KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript.kaslr
.else
EXTRA_LINKFLAGS= -z max-page-size=0x200000
+KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript
.endif
LINKFLAGS_NORMAL= -X
-KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript
##
## (6) port specific target dependencies
Added files:
Index: src/sys/arch/amd64/conf/kern.ldscript.kaslr
diff -u /dev/null src/sys/arch/amd64/conf/kern.ldscript.kaslr:1.1
--- /dev/null Thu Nov 9 15:46:48 2017
+++ src/sys/arch/amd64/conf/kern.ldscript.kaslr Thu Nov 9 15:46:48 2017
@@ -0,0 +1,62 @@
+/* $NetBSD: kern.ldscript.kaslr,v 1.1 2017/11/09 15:46:48 maxv Exp $ */
+
+#include "assym.h"
+
+ENTRY(_start)
+SECTIONS
+{
+ .text :
+ {
+ *(.text)
+ *(.text.*)
+ *(.stub)
+ } =0xCC
+ _etext = . ;
+ PROVIDE (etext = .) ;
+
+ __rodata_start = . ;
+ .rodata :
+ {
+ *(.rodata)
+ *(.rodata.*)
+ }
+
+ __data_start = . ;
+ .data :
+ {
+ *(.data)
+ }
+
+ . = ALIGN(COHERENCY_UNIT);
+ .data.cacheline_aligned :
+ {
+ *(.data.cacheline_aligned)
+ }
+ . = ALIGN(COHERENCY_UNIT);
+ .data.read_mostly :
+ {
+ *(.data.read_mostly)
+ }
+ . = ALIGN(COHERENCY_UNIT);
+
+ _edata = . ;
+ PROVIDE (edata = .) ;
+ __bss_start = . ;
+ .bss :
+ {
+ *(.bss)
+ *(.bss.*)
+ *(COMMON)
+ }
+
+ /* End of the kernel image */
+ __kernel_end = . ;
+
+ _end = . ;
+ PROVIDE (end = .) ;
+ .note.netbsd.ident :
+ {
+ KEEP(*(.note.netbsd.ident));
+ }
+}
+