Map the rodata segment independently on amd64, and remove the W permission
on it.
This commit is contained in:
parent
a23ebbfe56
commit
a819d82371
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: locore.S,v 1.87 2016/05/12 06:45:16 maxv Exp $ */
|
/* $NetBSD: locore.S,v 1.88 2016/05/12 07:21:18 maxv Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright-o-rama!
|
* Copyright-o-rama!
|
||||||
|
@ -564,6 +564,8 @@ no_NOX:
|
||||||
*
|
*
|
||||||
* (PROC0 STK + L4 + L3 + L2 + L1) is later referred to as BOOTSTRAP TABLES.
|
* (PROC0 STK + L4 + L3 + L2 + L1) is later referred to as BOOTSTRAP TABLES.
|
||||||
*
|
*
|
||||||
|
* Important note: the kernel segments are properly 4k-aligned
|
||||||
|
* (see kern.ldscript), so there's no need to enforce alignment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Find end of kernel image; brings us on (1). */
|
/* Find end of kernel image; brings us on (1). */
|
||||||
|
@ -616,16 +618,16 @@ no_NOX:
|
||||||
shrl $(PGSHIFT-3),%ecx /* ((n >> PGSHIFT) << 3) for # PDEs */
|
shrl $(PGSHIFT-3),%ecx /* ((n >> PGSHIFT) << 3) for # PDEs */
|
||||||
addl %ecx,%ebx
|
addl %ecx,%ebx
|
||||||
|
|
||||||
/*
|
/* Map the kernel text RX. */
|
||||||
* Compute &__rodata_start - KERNBASE. This can't be > 4G, or we can't
|
movl $RELOC(__rodata_start),%ecx
|
||||||
* deal with it anyway, since we can't load it in 32 bit mode. So use
|
subl %eax,%ecx
|
||||||
* the bottom 32 bits.
|
shrl $PGSHIFT,%ecx
|
||||||
*/
|
orl $(PG_V|PG_KR),%eax
|
||||||
movl $RELOC(__rodata_start),%edx
|
fillkpt
|
||||||
andl $~PGOFSET,%edx
|
|
||||||
|
|
||||||
/* Map the kernel text read-only. */
|
/* Map the kernel rodata ROX. */
|
||||||
movl %edx,%ecx
|
movl $RELOC(__rodata_start),%eax
|
||||||
|
movl $RELOC(__data_start),%ecx
|
||||||
subl %eax,%ecx
|
subl %eax,%ecx
|
||||||
shrl $PGSHIFT,%ecx
|
shrl $PGSHIFT,%ecx
|
||||||
orl $(PG_V|PG_KR),%eax
|
orl $(PG_V|PG_KR),%eax
|
||||||
|
@ -639,11 +641,12 @@ no_NOX:
|
||||||
* +--------+----------+-------------------+------------------+
|
* +--------+----------+-------------------+------------------+
|
||||||
* We just map everything from < to > with RWX rights.
|
* We just map everything from < to > with RWX rights.
|
||||||
*/
|
*/
|
||||||
leal (PG_V|PG_KW)(%edx),%eax
|
movl $RELOC(__data_start),%eax
|
||||||
movl $TABLESIZE,%ecx
|
movl %esi,%ecx /* start of BOOTSTRAP TABLES */
|
||||||
addl %esi,%ecx /* end of tables */
|
addl $TABLESIZE,%ecx /* end of BOOTSTRAP TABLES */
|
||||||
subl %edx,%ecx /* subtract end of text */
|
subl %eax,%ecx /* subtract start of DATA */
|
||||||
shrl $PGSHIFT,%ecx
|
shrl $PGSHIFT,%ecx
|
||||||
|
orl $(PG_V|PG_KW),%eax
|
||||||
fillkpt
|
fillkpt
|
||||||
|
|
||||||
/* We are on (4). Map ISA I/O mem (later atdevbase) RWX. */
|
/* We are on (4). Map ISA I/O mem (later atdevbase) RWX. */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: kern.ldscript,v 1.19 2016/05/12 06:45:16 maxv Exp $ */
|
/* $NetBSD: kern.ldscript,v 1.20 2016/05/12 07:21:18 maxv Exp $ */
|
||||||
|
|
||||||
#include "assym.h"
|
#include "assym.h"
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ SECTIONS
|
||||||
*(.rodata.*)
|
*(.rodata.*)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
. = ALIGN(__PAGE_SIZE);
|
||||||
|
|
||||||
__data_start = . ;
|
__data_start = . ;
|
||||||
.data :
|
.data :
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue