From: miod Date: Wed, 1 Jan 2014 07:54:15 +0000 (+0000) Subject: Add a linker script to force the .openbsd.randomdata section to be put after X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=56a1885ac7c603506dd34ae52a06291ce5f7b48e;p=openbsd Add a linker script to force the .openbsd.randomdata section to be put after .data, so that it will not get mapped read-only by pmap_bootstrap(). --- diff --git a/sys/arch/sparc/conf/Makefile.sparc b/sys/arch/sparc/conf/Makefile.sparc index be2e25c9f8f..96667b8237e 100644 --- a/sys/arch/sparc/conf/Makefile.sparc +++ b/sys/arch/sparc/conf/Makefile.sparc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.sparc,v 1.78 2013/10/15 19:23:30 guenther Exp $ +# $OpenBSD: Makefile.sparc,v 1.79 2014/01/01 07:54:15 miod Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -41,7 +41,7 @@ CMACHFLAGS+= -fno-stack-protector COPTS?= -O2 CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} AFLAGS= -D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} -LINKFLAGS= -N -e start -Ttext F8004000 --warn-common -nopie +LINKFLAGS= -N -e start -T ${_machdir}/conf/ld.script --warn-common -nopie .if ${IDENT:M-DDDB_STRUCT} DB_STRUCTINFO= db_structinfo.h diff --git a/sys/arch/sparc/conf/ld.script b/sys/arch/sparc/conf/ld.script new file mode 100644 index 00000000000..9d855f62955 --- /dev/null +++ b/sys/arch/sparc/conf/ld.script @@ -0,0 +1,59 @@ +/* $OpenBSD: ld.script,v 1.1 2014/01/01 07:54:15 miod Exp $ */ + +/* + * Copyright (c) 2013 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +OUTPUT_FORMAT("elf32-big") +OUTPUT_ARCH(sparc) +ENTRY(start) + +PHDRS +{ + text PT_LOAD; + data PT_LOAD; + openbsd_randomize 0x65a3dbe6; /* PT_OPENBSD_RANDOMIZE */ +} + +SECTIONS +{ + . = 0xF8004000; + .text : + { + *(.text) + PROVIDE(etext = ABSOLUTE(.)); + } :text + .rodata : + { + *(.rodata*) + } + . = ALIGN(0x2000); + .data : + { + PROVIDE(__data_start = ABSOLUTE(.)); + *(.data) + PROVIDE(edata = ABSOLUTE(.)); + } :data + .openbsd.randomdata : + { + *(.openbsd.randomdata) + } :data :openbsd_randomize + .bss : + { + *(.bss) + /* . = ALIGN(64 / 8); */ + } :data + PROVIDE(end = ABSOLUTE(.)); +}