From: deraadt Date: Thu, 22 Jun 2017 16:01:45 +0000 (+0000) Subject: Generate a gap.link script, and use that to generate gap.o. On multi-ABI X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=226329da4068eb9ad21ac65c174f0628c5ec1ea3;p=openbsd Generate a gap.link script, and use that to generate gap.o. On multi-ABI architectures we must also link against a gapdummy.o to repair the ABI of the resulting .o file. Woe is me. Also repair install: target to update the linkkit & hash when a kernel is installed. ok rpe tb mlarkin and tested by others also --- diff --git a/sys/arch/alpha/conf/Makefile.alpha b/sys/arch/alpha/conf/Makefile.alpha index 6fbabd80d2c..d0817666124 100644 --- a/sys/arch/alpha/conf/Makefile.alpha +++ b/sys/arch/alpha/conf/Makefile.alpha @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.alpha,v 1.101 2017/06/13 16:40:00 deraadt Exp $ +# $OpenBSD: Makefile.alpha,v 1.102 2017/06/22 16:01:45 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -93,12 +93,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -127,19 +121,19 @@ ioconf.o: ioconf.c ld.script: ${_machdir}/conf/ld.script cp ${_machdir}/conf/ld.script $@ +makegap.sh: $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh + sh makegap.sh 0x00000000 + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile - umask 007; sh $S/conf/makegap.sh 0x00 > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -154,16 +148,12 @@ db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl locore0.o: ${_machdir}/${_mach}/locore0.S assym.h locore.o: ${_machdir}/${_mach}/locore.s assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/amd64/conf/Makefile.amd64 b/sys/arch/amd64/conf/Makefile.amd64 index 22e4488f042..5d8ae7d837f 100644 --- a/sys/arch/amd64/conf/Makefile.amd64 +++ b/sys/arch/amd64/conf/Makefile.amd64 @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.amd64,v 1.84 2017/06/13 16:40:01 deraadt Exp $ +# $OpenBSD: Makefile.amd64,v 1.85 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -96,12 +96,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -130,19 +124,19 @@ ioconf.o: ioconf.c ld.script: ${_machdir}/conf/ld.script cp ${_machdir}/conf/ld.script $@ +makegap.sh: $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh + sh makegap.sh 0xcccccccc + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile - umask 007; sh $S/conf/makegap.sh 0xcc > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -158,16 +152,12 @@ locore0.o: ${_machdir}/${_mach}/locore0.S assym.h locore.o mutex.o vector.o copy.o spl.o: assym.h mptramp.o acpi_wakecode.o vmm_support.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/arm64/conf/Makefile.arm64 b/sys/arch/arm64/conf/Makefile.arm64 index 01e94b7b237..be24a6cde18 100644 --- a/sys/arch/arm64/conf/Makefile.arm64 +++ b/sys/arch/arm64/conf/Makefile.arm64 @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.arm64,v 1.14 2017/06/13 16:40:01 deraadt Exp $ +# $OpenBSD: Makefile.arm64,v 1.15 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -94,12 +94,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -130,19 +124,23 @@ ld.script: ${_archdir}/conf/kern.ldscript sed -e 's/@KERNEL_BASE_PHYS@/${KERNEL_BASE_PHYS}/' \ -e 's/@KERNEL_BASE_VIRT@/${KERNEL_BASE_VIRT}/' > ld.script +gapdummy.o: + echo 'const char gapdummy;' > gapdummy.c + ${CC} -c ${CFLAGS} ${CPPFLAGS} gapdummy.c -o $@ + +makegap.sh: $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh gapdummy.o + sh makegap.sh 0xd4d4d4d4 gapdummy.o + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile - umask 007; sh $S/conf/makegap.sh 0xd4 > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -159,16 +157,12 @@ in_cksum_arm.o fiq_subr.o bcopyinout.o copystr.o sigcode.o copy.o: assym.h vectors.o cpuswitch.o exception.o bcopy_page.o irq_dispatch.o support.o: assym.h locore.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/armv7/conf/Makefile.armv7 b/sys/arch/armv7/conf/Makefile.armv7 index b9fb44d46c0..0acdd50a978 100644 --- a/sys/arch/armv7/conf/Makefile.armv7 +++ b/sys/arch/armv7/conf/Makefile.armv7 @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.armv7,v 1.27 2017/06/14 13:12:49 patrick Exp $ +# $OpenBSD: Makefile.armv7,v 1.28 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -91,12 +91,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -128,19 +122,23 @@ ld.script: ${_archdir}/conf/ldscript.head ${_archdir}/conf/ldscript.tail -e 's/@KERNEL_BASE_VIRT@/${KERNEL_BASE_VIRT}/' \ -e 's/(KERNEL_BASE_phys)/(KERNEL_BASE_virt)/' > ld.script +gapdummy.o: + echo 'const char gapdummy;' > gapdummy.c + ${CC} -c ${CFLAGS} ${CPPFLAGS} gapdummy.c -o $@ + +makegap.sh: Makefile $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh gapdummy.o + sh makegap.sh 0xd4d4d4d4 gapdummy.o + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile - umask 007; sh $S/conf/makegap.sh 0xd4 > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -157,16 +155,12 @@ in_cksum_arm.o fiq_subr.o bcopyinout.o copystr.o sigcode.o: assym.h vectors.o cpuswitch7.o exception.o bcopy_page.o irq_dispatch.o: assym.h ${_mach}_start.o locore.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/hppa/conf/Makefile.hppa b/sys/arch/hppa/conf/Makefile.hppa index fa768b4b18b..3e0a0d8788f 100644 --- a/sys/arch/hppa/conf/Makefile.hppa +++ b/sys/arch/hppa/conf/Makefile.hppa @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.hppa,v 1.95 2017/06/13 16:40:01 deraadt Exp $ +# $OpenBSD: Makefile.hppa,v 1.96 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -101,12 +101,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -135,19 +129,19 @@ ioconf.o: ioconf.c ld.script: ${_machdir}/conf/ld.script cp ${_machdir}/conf/ld.script $@ +makegap.sh: $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh + sh makegap.sh 0x00000000 # BREAK 0,0 -> trap + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile - umask 007; sh $S/conf/makegap.sh 0xcc > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -163,16 +157,12 @@ locore0.o: ${_machdir}/${_mach}/locore0.S assym.h locore.o: ${_machdir}/${_mach}/locore.S assym.h fpemu.o spcopy.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/i386/conf/Makefile.i386 b/sys/arch/i386/conf/Makefile.i386 index 7ec7d6cbaa3..9b2c40e4d42 100644 --- a/sys/arch/i386/conf/Makefile.i386 +++ b/sys/arch/i386/conf/Makefile.i386 @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.i386,v 1.110 2017/06/13 16:40:01 deraadt Exp $ +# $OpenBSD: Makefile.i386,v 1.111 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -97,12 +97,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -131,19 +125,19 @@ ioconf.o: ioconf.c ld.script: ${_machdir}/conf/ld.script cp ${_machdir}/conf/ld.script $@ +makegap.sh: $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh + sh makegap.sh 0xcccccccc + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile - umask 007; sh $S/conf/makegap.sh 0xcc > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -159,16 +153,12 @@ locore0.o: ${_machdir}/${_mach}/locore0.S assym.h locore.o mutex.o in_cksum.o mptramp.o: assym.h kvm86call.o acpi_wakecode.o vmm_support.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/landisk/conf/Makefile.landisk b/sys/arch/landisk/conf/Makefile.landisk index 96bafd7922e..83c2b17964c 100644 --- a/sys/arch/landisk/conf/Makefile.landisk +++ b/sys/arch/landisk/conf/Makefile.landisk @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.landisk,v 1.67 2017/06/13 16:40:01 deraadt Exp $ +# $OpenBSD: Makefile.landisk,v 1.68 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -93,12 +93,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -127,19 +121,19 @@ ioconf.o: ioconf.c ld.script: ${_machdir}/conf/ld.script cp ${_machdir}/conf/ld.script $@ +makegap.sh: $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh + sh makegap.sh 0xc3c3c3c3 + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile - umask 007; sh $S/conf/makegap.sh 0xc3 > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -155,16 +149,12 @@ locore.o: ${_machdir}/${_mach}/locore.S assym.h locore0.o: ${_machdir}/${_mach}/locore0.S assym.h locore_subr.o vectors.o in_cksum.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/loongson/conf/Makefile.loongson b/sys/arch/loongson/conf/Makefile.loongson index 8c6a926b005..84750f485d9 100644 --- a/sys/arch/loongson/conf/Makefile.loongson +++ b/sys/arch/loongson/conf/Makefile.loongson @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.loongson,v 1.60 2017/06/13 16:40:01 deraadt Exp $ +# $OpenBSD: Makefile.loongson,v 1.61 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -98,12 +98,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -132,19 +126,23 @@ ioconf.o: ioconf.c ld.script: ${_machdir}/conf/ld.script cp ${_machdir}/conf/ld.script $@ +gapdummy.o: + echo 'const char gapdummy;' > gapdummy.c + ${CC} -c ${CFLAGS} ${CPPFLAGS} gapdummy.c -o $@ + +makegap.sh: Makefile $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh gapdummy.o + sh makegap.sh 0xefefefef gapdummy.o + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile $S/conf/makegap.sh - umask 007; sh $S/conf/makegap.sh 0xef > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -165,16 +163,12 @@ context.o cp0access.o exception.o locore.o: assym.h lcore_access.o lcore_ddb.o lcore_float.o tlbhandler.o: assym.h pmon32.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/macppc/conf/Makefile.macppc b/sys/arch/macppc/conf/Makefile.macppc index 3a827ddf541..a3c3047f118 100644 --- a/sys/arch/macppc/conf/Makefile.macppc +++ b/sys/arch/macppc/conf/Makefile.macppc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.macppc,v 1.83 2017/06/13 01:44:27 deraadt Exp $ +# $OpenBSD: Makefile.macppc,v 1.84 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -93,12 +93,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -127,19 +121,20 @@ ioconf.o: ioconf.c ld.script: ${_machdir}/conf/ld.script cp ${_machdir}/conf/ld.script $@ +makegap.sh: $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh + sh makegap.sh 0xcccccccc # XXX choose a trap instruction + + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile - umask 007; sh $S/conf/makegap.sh 0xcc > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -155,16 +150,12 @@ locore0.o: ${_machdir}/${_mach}/locore0.S assym.h locore.o: ${_machdir}/${_mach}/locore.S assym.h mutex.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/octeon/conf/Makefile.octeon b/sys/arch/octeon/conf/Makefile.octeon index 2961017a2f0..4bebc8cd407 100644 --- a/sys/arch/octeon/conf/Makefile.octeon +++ b/sys/arch/octeon/conf/Makefile.octeon @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.octeon,v 1.36 2017/06/13 16:40:01 deraadt Exp $ +# $OpenBSD: Makefile.octeon,v 1.37 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -99,12 +99,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -133,19 +127,23 @@ ioconf.o: ioconf.c ld.script: ${_machdir}/conf/ld.script cp ${_machdir}/conf/ld.script $@ +gapdummy.o: + echo 'const char gapdummy;' > gapdummy.c + ${CC} -c ${CFLAGS} ${CPPFLAGS} gapdummy.c -o $@ + +makegap.sh: Makefile $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh gapdummy.o + sh makegap.sh 0xefefefef gapdummy.o + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile $S/conf/makegap.sh - umask 007; sh $S/conf/makegap.sh 0xef > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -166,16 +164,12 @@ context.o cp0access.o exception.o locore.o: assym.h lcore_access.o lcore_ddb.o lcore_float.o tlbhandler.o: assym.h mips64r2.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/sgi/conf/Makefile.sgi b/sys/arch/sgi/conf/Makefile.sgi index 99b390159cd..c077d67d154 100644 --- a/sys/arch/sgi/conf/Makefile.sgi +++ b/sys/arch/sgi/conf/Makefile.sgi @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.sgi,v 1.84 2017/06/13 16:40:01 deraadt Exp $ +# $OpenBSD: Makefile.sgi,v 1.85 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -98,12 +98,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -132,19 +126,23 @@ ioconf.o: ioconf.c ld.script: ${_machdir}/conf/ld.script cp ${_machdir}/conf/ld.script $@ +gapdummy.o: + echo 'const char gapdummy;' > gapdummy.c + ${CC} -c ${CFLAGS} ${CPPFLAGS} gapdummy.c -o $@ + +makegap.sh: $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh gapdummy.o + sh makegap.sh 0xefefefef gapdummy.o + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile $S/conf/makegap.sh - umask 007; sh $S/conf/makegap.sh 0xef > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -166,16 +164,12 @@ lcore_access.o lcore_ddb.o lcore_float.o locore.o: assym.h tlb_tfp.o tlbhandler.o: assym.h cache_tfp_subr.o ip30_nmi.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/arch/sparc64/conf/Makefile.sparc64 b/sys/arch/sparc64/conf/Makefile.sparc64 index f24028fb23f..f9ca4b9ae46 100644 --- a/sys/arch/sparc64/conf/Makefile.sparc64 +++ b/sys/arch/sparc64/conf/Makefile.sparc64 @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.sparc64,v 1.87 2017/06/13 16:40:01 deraadt Exp $ +# $OpenBSD: Makefile.sparc64,v 1.88 2017/06/22 16:01:48 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -91,12 +91,6 @@ LINKFLAGS+= -S %LOAD -newbsd: - ${SYSTEM_LD_HEAD} - ${SYSTEM_LD} swapgeneric.o - ${SYSTEM_LD_TAIL} - mv -f newbsd bsd - # cc's -MD puts the source and output paths in the dependency file; # since those are temp files here we need to fix it up. It also # puts the file in /tmp, so we use -MF to put it in the current @@ -125,19 +119,19 @@ ioconf.o: ioconf.c ld.script: ${_machdir}/conf/ld.script cp ${_machdir}/conf/ld.script $@ +makegap.sh: $S/conf/makegap.sh + cp $S/conf/makegap.sh $@ + +gap.o: Makefile makegap.sh + sh makegap.sh 0x00000000 + vers.o: ${SYSTEM_DEP:Ngap.o} ${SYSTEM_SWAP_DEP} sh $S/conf/newvers.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -gap.S: ${SYSTEM_SWAP_DEP} Makefile - umask 007; sh $S/conf/makegap.sh 0x00 > gap.S - -gap.o: gap.S - umask 007; ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c gap.S - clean: rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ - gap.S lorder param.c + gap.link ld.script lorder makegap.sh param.c cleandir: clean rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c @@ -152,16 +146,12 @@ db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl locore.o: ${_machdir}/${_mach}/locore.s assym.h hvcall.o in_cksum.o mutex.o: assym.h -# The install target can be redefined by putting a -# install-kernel-${MACHINE_NAME} target into /etc/mk.conf -MACHINE_NAME!= uname -n -install: install-kernel-${MACHINE_NAME} -.if !target(install-kernel-${MACHINE_NAME}}) -install-kernel-${MACHINE_NAME}: +newinstall: cmp -s bsd /bsd || ln -f /bsd /obsd - umask 077; cp bsd /nbsd - mv /nbsd /bsd -.endif + umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ + sha256 -h /var/db/kernel.SHA256 /bsd + +install: update-link newinstall # pull in the dependency information .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) diff --git a/sys/conf/makegap.sh b/sys/conf/makegap.sh index da50aa602f8..d57cbc07002 100644 --- a/sys/conf/makegap.sh +++ b/sys/conf/makegap.sh @@ -1,32 +1,62 @@ #!/bin/sh - -PADBYTE=$1 - -cat << __EOF__ -#include -#include - - .text - .balign PAGE_SIZE, $PADBYTE - .space $RANDOM, $PADBYTE - .balign PAGE_SIZE, $PADBYTE - - .globl endboot -endboot: - .space PAGE_SIZE, $PADBYTE - .space $RANDOM % PAGE_SIZE, $PADBYTE - .balign 16, $PADBYTE - - /* - * Randomly bias future data, bss, and rodata objects, - * does not help for objects in locore0.S though - */ - .data - .space $RANDOM % PAGE_SIZE, $PADBYTE - - .section .bss - .space $RANDOM % PAGE_SIZE - - .section .rodata - .space $RANDOM % PAGE_SIZE, $PADBYTE +umask 007 + +PAGE_SIZE=`sysctl -n hw.pagesize` +PAD=$1 +GAPDUMMY=$2 + +RANDOM1=$((RANDOM % (3 * PAGE_SIZE))) +RANDOM2=$((RANDOM % PAGE_SIZE)) +RANDOM3=$((RANDOM % PAGE_SIZE)) +RANDOM4=$((RANDOM % PAGE_SIZE)) +RANDOM5=$((RANDOM % PAGE_SIZE)) + +cat > gap.link << __EOF__ + +PHDRS { + text PT_LOAD FILEHDR PHDRS; + rodata PT_LOAD; + data PT_LOAD; + bss PT_LOAD; +} + +SECTIONS { + .text : ALIGN($PAGE_SIZE) { + LONG($PAD); + . += $RANDOM1; + . = ALIGN($PAGE_SIZE); + endboot = .; + PROVIDE (endboot = .); + . = ALIGN($PAGE_SIZE); + . += $RANDOM2; + . = ALIGN(16); + *(.text .text.*) + } :text =$PAD + + .rodata : { + LONG($PAD); + . += $RANDOM3; + . = ALIGN(16); + *(.rodata .rodata.*) + } :rodata =$PAD + + .data : { + LONG($PAD); + . = . + $RANDOM4; /* fragment of page */ + . = ALIGN(16); + *(.data .data.*) + } :data =$PAD + + .bss : { + . = . + $RANDOM5; /* fragment of page */ + . = ALIGN(16); + *(.bss .bss.*) + } :bss + + note.ABI-tag 0 : { *(.note.ABI-tag) } + .MIPS.options : { *(.MIPS.options) } +} __EOF__ + +ld -r gap.link $GAPDUMMY -o gap.o