diff options
-rw-r--r-- | sys/arch/amd64/amd64/locore.S | 19 | ||||
-rw-r--r-- | sys/arch/amd64/conf/Makefile.amd64 | 5 |
2 files changed, 18 insertions, 6 deletions
diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S index c0076f2d5c4..123c9761446 100644 --- a/sys/arch/amd64/amd64/locore.S +++ b/sys/arch/amd64/amd64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.55 2014/10/09 04:18:09 tedu Exp $ */ +/* $OpenBSD: locore.S,v 1.56 2014/11/05 05:40:02 mlarkin Exp $ */ /* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */ /* @@ -440,11 +440,24 @@ bi_size_ok: orl $(PG_V|PG_KR),%eax fillkpt + /* Map .rodata read-only, and NX if available */ + movl $RELOC(__rodata_start), %eax + movl $RELOC(erodata), %ecx + addl $PGOFSET, %ecx + andl $~PGOFSET, %ecx + subl %eax, %ecx + shrl $PGSHIFT, %ecx + orl $(PG_V|PG_KR), %eax + fillkpt + + /* Reload %edx for data_start */ + movl $RELOC(__data_start), %edx + /* Map the data, BSS, and bootstrap tables read-write. */ leal (PG_V|PG_KW)(%edx),%eax movl $TABLESIZE,%ecx - addl %esi,%ecx /* %ecx = &end[TABLESIZE] */ - subl %edx,%ecx /* %ecx = %ecx - etext */ + addl %esi,%ecx /* %ecx = end + TABLESIZE */ + subl %edx,%ecx /* %ecx = %ecx - data_start */ shrl $PGSHIFT,%ecx fillkpt diff --git a/sys/arch/amd64/conf/Makefile.amd64 b/sys/arch/amd64/conf/Makefile.amd64 index a108be9bafe..16b562ffc75 100644 --- a/sys/arch/amd64/conf/Makefile.amd64 +++ b/sys/arch/amd64/conf/Makefile.amd64 @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.amd64,v 1.60 2014/10/04 18:10:14 brad Exp $ +# $OpenBSD: Makefile.amd64,v 1.61 2014/11/05 05:40:02 mlarkin Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -42,7 +42,7 @@ CMACHFLAGS+= -Wa,-n COPTS?= -O2 CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} AFLAGS= -D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} -LINKFLAGS= -Ttext 0xffffffff810001e0 -e start --warn-common -nopie +LINKFLAGS= -T ${_machdir}/conf/kern.ldscript -X --warn-common -nopie .if ${IDENT:M-DDDB_STRUCT} DB_STRUCTINFO= db_structinfo.h @@ -80,7 +80,6 @@ SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@ DEBUG?= .if ${DEBUG} == "-g" -LINKFLAGS+= -X STRIPFLAGS= -g -x SYSTEM_LD_TAIL+=; \ echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ |