For those who are curious, here is the surprisingly small diff.
No C code.

Perhaps in the future some valient soul will add a linker to the
bootblocks, and we can boot a "bsd.a" file.  For now this mechanism is
easier; we can take a shot at adding KVA and KPA ASLR to the mix on
a per-arch basis.

===================================================================
RCS file: /cvs/src/etc/Makefile,v
retrieving revision 1.457
diff -u -p -u -r1.457 Makefile
--- etc/Makefile        12 Jun 2017 18:49:33 -0000      1.457
+++ etc/Makefile        12 Jun 2017 21:48:04 -0000
@@ -29,6 +29,13 @@ kernels: ${ALL_KERNELS}
        cp ../sys/arch/${MACHINE}/compile/${CONF}/obj/bsd ${RELEASEDIR}/$K
        chmod a+r ${RELEASEDIR}/$K
 .endfor
+       cd ${.CURDIR}/../sys/arch/${MACHINE}/compile/ && \
+               tar -chzf ${DESTDIR}/usr/share/compile.tgz -s ',/obj/,/,' \
+               GENERIC*/obj/*.o GENERIC*/obj/Makefile \
+               GENERIC*/obj/ld.script GENERIC*/obj/gap.S \
+               GENERIC*/obj/machine
+       chown root:wheel ${DESTDIR}/usr/share/compile.tgz
+       chmod 644 ${DESTDIR}/usr/share/compile.tgz
 
 # -rw-r--r--
 BINOWN= root
Index: etc/rc
===================================================================
RCS file: /cvs/src/etc/rc,v
retrieving revision 1.501
diff -u -p -u -r1.501 rc
--- etc/rc      6 Jun 2017 13:59:37 -0000       1.501
+++ etc/rc      11 Jun 2017 23:00:29 -0000
@@ -219,6 +219,37 @@ reorder_libs() {
        fi
 }
 
+# Re-link the kernel, placing the objects in a random order.
+# Replace current with relinked kernel and inform root about it.
+reorder_kernel() {
+       (
+       set -e
+       _compile_dir=/usr/share/compile
+       _kernel=$(sysctl -n kern.osversion)
+       _kernel=${_kernel%#*}
+       _kernel_dir=$_compile_dir/$_kernel
+       _sha256=$_kernel_dir/SHA256
+
+       if [[ -f /usr/share/compile.tgz ]]; then
+               rm -rf $_compile_dir
+               mkdir -m 700 -p $_compile_dir
+               tar -C $_compile_dir -xzf /usr/share/compile.tgz $_kernel
+               rm -f /usr/share/compile.tgz
+       fi
+
+       [[ -f $_sha256 ]] && sha256 -q -C $_sha256 /bsd
+
+       cd $_kernel_dir
+       make newbsd >$_kernel_dir/log 2>&1
+       make install
+       sha256 -h $_sha256 /bsd
+
+       (echo "Kernel has been relinked and is active on next reboot\n"; \
+               cat $_sha256; echo "\nRelink log:\n"; cat $_kernel_dir/log ) |
+               mail -Es "$(hostname) Kernel relink info" root >/dev/null
+       ) >/dev/null 2>&1 &
+}
+
 # Run rc.* script and email output to root.
 # Usage: run_upgrade_script firsttime|sysmerge
 run_upgrade_script() {
@@ -585,6 +616,8 @@ mixerctl_conf
 echo -n 'starting local daemons:'
 start_daemon apmd sensorsd hotplugd watchdogd cron wsmoused xenodm
 echo '.'
+
+reorder_kernel
 
 date
 exit 0
Index: distrib/amd64/iso/Makefile
===================================================================
RCS file: /cvs/src/distrib/amd64/iso/Makefile,v
retrieving revision 1.17
diff -u -p -u -r1.17 Makefile
--- distrib/amd64/iso/Makefile  7 Sep 2015 01:41:35 -0000       1.17
+++ distrib/amd64/iso/Makefile  12 Jun 2017 00:07:13 -0000
@@ -7,8 +7,8 @@ TOP=    ${.CURDIR}/..
 CDROM=         install${REV}.iso
 
 FS=            install${REV}.fs
-FSSIZE=                573440
-FSTYPE=                install280
+FSSIZE=                737280
+FSTYPE=                install360
 
 RAMDISK=       RAMDISK_CD
 
Index: distrib/i386/iso/Makefile
===================================================================
RCS file: /cvs/src/distrib/i386/iso/Makefile,v
retrieving revision 1.12
diff -u -p -u -r1.12 Makefile
--- distrib/i386/iso/Makefile   21 Sep 2014 13:44:44 -0000      1.12
+++ distrib/i386/iso/Makefile   12 Jun 2017 00:14:07 -0000
@@ -7,8 +7,8 @@ TOP=    ${.CURDIR}/..
 CDROM=         install${REV}.iso
 
 FS=            install${REV}.fs
-FSSIZE=                491520
-FSTYPE=                install240
+FSSIZE=                737280
+FSTYPE=                install360
 
 RAMDISK=       RAMDISK_CD
 
Index: distrib/sets/lists/base/mi
===================================================================
RCS file: /cvs/src/distrib/sets/lists/base/mi,v
retrieving revision 1.842
diff -u -p -u -r1.842 mi
--- distrib/sets/lists/base/mi  3 Jun 2017 10:01:04 -0000       1.842
+++ distrib/sets/lists/base/mi  11 Jun 2017 23:00:29 -0000
@@ -2571,6 +2571,7 @@
 ./usr/share/calendar/ru_RU.UTF-8/calendar.orthodox
 ./usr/share/calendar/ru_RU.UTF-8/calendar.pagan
 ./usr/share/calendar/ru_RU.UTF-8/calendar.primety
+./usr/share/compile.tgz
 ./usr/share/dict
 ./usr/share/dict/README
 ./usr/share/dict/american
Index: etc/Makefile
Index: etc/etc.amd64/disktab
===================================================================
RCS file: /cvs/src/etc/etc.amd64/disktab,v
retrieving revision 1.18
diff -u -p -u -r1.18 disktab
--- etc/etc.amd64/disktab       30 Dec 2016 22:26:27 -0000      1.18
+++ etc/etc.amd64/disktab       12 Jun 2017 00:34:44 -0000
@@ -5,6 +5,11 @@ mini34|gzip bsd.rd disk image 4.34375MB:
        :pa#8896:oa#64:ba#8192:fa#1024:ta=4.2BSD: \
        :pc#8960:oc#0:
 
+install360|install.fs disk image 360MB:\
+       :dt=rdroot:se#512:nt#1:ns#64:nc#11520:\
+       :pa#737216:oa#64:ba#8192:fa#1024:ta=4.2BSD: \
+       :pc#737280:oc#0:
+
 install280|install.fs disk image 280MB:\
        :dt=rdroot:se#512:nt#1:ns#64:nc#8960:\
        :pa#573376:oa#64:ba#8192:fa#1024:ta=4.2BSD: \
Index: etc/etc.i386/disktab
===================================================================
RCS file: /cvs/src/etc/etc.i386/disktab,v
retrieving revision 1.26
diff -u -p -u -r1.26 disktab
--- etc/etc.i386/disktab        30 Dec 2016 22:26:29 -0000      1.26
+++ etc/etc.i386/disktab        12 Jun 2017 00:34:34 -0000
@@ -5,6 +5,11 @@ mini34|gzip bsd.rd disk image 4.34375MB:
        :pa#7872:oa#64:ba#8192:fa#1024:ta=4.2BSD: \
        :pc#7936:oc#0:
 
+install360|install.fs disk image 360MB:\
+       :dt=rdroot:se#512:nt#1:ns#64:nc#11520:\
+       :pa#737216:oa#64:ba#8192:fa#1024:ta=4.2BSD: \
+       :pc#737280:oc#0:
+
 install240|install.fs disk image 240MB:\
        :dt=rdroot:se#512:nt#1:ns#64:nc#7680:\
        :pa#491456:oa#64:ba#8192:fa#1024:ta=4.2BSD: \
Index: sys/arch/alpha/conf/Makefile.alpha
===================================================================
RCS file: /cvs/src/sys/arch/alpha/conf/Makefile.alpha,v
retrieving revision 1.100
diff -u -p -u -r1.100 Makefile.alpha
--- sys/arch/alpha/conf/Makefile.alpha  11 Jun 2017 22:51:21 -0000      1.100
+++ sys/arch/alpha/conf/Makefile.alpha  13 Jun 2017 00:21:39 -0000
@@ -93,6 +93,12 @@ 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
Index: sys/arch/amd64/conf/Makefile.amd64
===================================================================
RCS file: /cvs/src/sys/arch/amd64/conf/Makefile.amd64,v
retrieving revision 1.83
diff -u -p -u -r1.83 Makefile.amd64
--- sys/arch/amd64/conf/Makefile.amd64  11 Jun 2017 22:51:21 -0000      1.83
+++ sys/arch/amd64/conf/Makefile.amd64  13 Jun 2017 00:21:40 -0000
@@ -96,6 +96,12 @@ 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
Index: sys/arch/arm64/conf/Makefile.arm64
===================================================================
RCS file: /cvs/src/sys/arch/arm64/conf/Makefile.arm64,v
retrieving revision 1.13
diff -u -p -u -r1.13 Makefile.arm64
--- sys/arch/arm64/conf/Makefile.arm64  11 Jun 2017 22:51:21 -0000      1.13
+++ sys/arch/arm64/conf/Makefile.arm64  13 Jun 2017 00:20:09 -0000
@@ -94,6 +94,12 @@ 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
Index: sys/arch/armv7/conf/Makefile.armv7
===================================================================
RCS file: /cvs/src/sys/arch/armv7/conf/Makefile.armv7,v
retrieving revision 1.25
diff -u -p -u -r1.25 Makefile.armv7
--- sys/arch/armv7/conf/Makefile.armv7  11 Jun 2017 22:51:21 -0000      1.25
+++ sys/arch/armv7/conf/Makefile.armv7  13 Jun 2017 00:20:02 -0000
@@ -86,6 +86,12 @@ 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
Index: sys/arch/hppa/conf/Makefile.hppa
===================================================================
RCS file: /cvs/src/sys/arch/hppa/conf/Makefile.hppa,v
retrieving revision 1.94
diff -u -p -u -r1.94 Makefile.hppa
--- sys/arch/hppa/conf/Makefile.hppa    11 Jun 2017 22:51:21 -0000      1.94
+++ sys/arch/hppa/conf/Makefile.hppa    13 Jun 2017 00:19:00 -0000
@@ -101,6 +101,12 @@ 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
Index: sys/arch/i386/conf/Makefile.i386
===================================================================
RCS file: /cvs/src/sys/arch/i386/conf/Makefile.i386,v
retrieving revision 1.109
diff -u -p -u -r1.109 Makefile.i386
--- sys/arch/i386/conf/Makefile.i386    11 Jun 2017 22:51:21 -0000      1.109
+++ sys/arch/i386/conf/Makefile.i386    11 Jun 2017 23:02:46 -0000
@@ -97,6 +97,12 @@ 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
Index: sys/arch/landisk/conf/Makefile.landisk
===================================================================
RCS file: /cvs/src/sys/arch/landisk/conf/Makefile.landisk,v
retrieving revision 1.65
diff -u -p -u -r1.65 Makefile.landisk
--- sys/arch/landisk/conf/Makefile.landisk      11 Jun 2017 22:51:21 -0000      
1.65
+++ sys/arch/landisk/conf/Makefile.landisk      13 Jun 2017 00:19:52 -0000
@@ -93,6 +93,12 @@ 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
Index: sys/arch/loongson/conf/Makefile.loongson
===================================================================
RCS file: /cvs/src/sys/arch/loongson/conf/Makefile.loongson,v
retrieving revision 1.59
diff -u -p -u -r1.59 Makefile.loongson
--- sys/arch/loongson/conf/Makefile.loongson    11 Jun 2017 22:51:21 -0000      
1.59
+++ sys/arch/loongson/conf/Makefile.loongson    13 Jun 2017 00:19:28 -0000
@@ -98,6 +98,12 @@ 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
Index: sys/arch/octeon/conf/Makefile.octeon
===================================================================
RCS file: /cvs/src/sys/arch/octeon/conf/Makefile.octeon,v
retrieving revision 1.35
diff -u -p -u -r1.35 Makefile.octeon
--- sys/arch/octeon/conf/Makefile.octeon        11 Jun 2017 22:51:21 -0000      
1.35
+++ sys/arch/octeon/conf/Makefile.octeon        13 Jun 2017 00:19:47 -0000
@@ -99,6 +99,12 @@ 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
Index: sys/arch/sgi/conf/Makefile.sgi
===================================================================
RCS file: /cvs/src/sys/arch/sgi/conf/Makefile.sgi,v
retrieving revision 1.83
diff -u -p -u -r1.83 Makefile.sgi
--- sys/arch/sgi/conf/Makefile.sgi      11 Jun 2017 22:51:21 -0000      1.83
+++ sys/arch/sgi/conf/Makefile.sgi      13 Jun 2017 00:19:37 -0000
@@ -98,6 +98,12 @@ 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
Index: sys/arch/sparc64/conf/Makefile.sparc64
===================================================================
RCS file: /cvs/src/sys/arch/sparc64/conf/Makefile.sparc64,v
retrieving revision 1.86
diff -u -p -u -r1.86 Makefile.sparc64
--- sys/arch/sparc64/conf/Makefile.sparc64      13 Jun 2017 00:16:09 -0000      
1.86
+++ sys/arch/sparc64/conf/Makefile.sparc64      13 Jun 2017 00:18:57 -0000
@@ -91,6 +91,12 @@ 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

Reply via email to