Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/conf Use another ld script for kaslr kernels, ...



details:   https://anonhg.NetBSD.org/src/rev/099d66c1c69a
branches:  trunk
changeset: 827702:099d66c1c69a
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Nov 09 15:46:48 2017 +0000

description:
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.

diffstat:

 sys/arch/amd64/conf/Makefile.amd64      |   5 +-
 sys/arch/amd64/conf/kern.ldscript.kaslr |  62 +++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+), 2 deletions(-)

diffs (89 lines):

diff -r 70d696b9969d -r 099d66c1c69a sys/arch/amd64/conf/Makefile.amd64
--- a/sys/arch/amd64/conf/Makefile.amd64        Thu Nov 09 15:40:23 2017 +0000
+++ b/sys/arch/amd64/conf/Makefile.amd64        Thu Nov 09 15:46:48 2017 +0000
@@ -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 @@
 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
diff -r 70d696b9969d -r 099d66c1c69a sys/arch/amd64/conf/kern.ldscript.kaslr
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amd64/conf/kern.ldscript.kaslr   Thu Nov 09 15:46:48 2017 +0000
@@ -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));
+       }
+}
+



Home | Main Index | Thread Index | Old Index