diff --git a/sys/conf/Makefile.arm b/sys/conf/Makefile.arm --- a/sys/conf/Makefile.arm +++ b/sys/conf/Makefile.arm @@ -70,9 +70,6 @@ # Generate the .bin (no elf headers) kernel as an extra build output. # We must relink to generate the .bin kernel, because without headers the # location of everything changes. We also strip the ARM marker symbols. -KERNEL_EXTRA+= ${KERNEL_KO}.bin -KERNEL_EXTRA_INSTALL+= ${KERNEL_KO}.bin - ${KERNEL_KO}.bin: ${SYSTEM_DEP} vers.o @echo "linking ${.TARGET}" @${SYSTEM_LD_BASECMD} \ @@ -101,8 +98,6 @@ %CLEAN -CLEAN+= ${KERNEL_KO}.bin - %RULES .include "$S/conf/kern.post.mk" diff --git a/sys/conf/Makefile.arm64 b/sys/conf/Makefile.arm64 --- a/sys/conf/Makefile.arm64 +++ b/sys/conf/Makefile.arm64 @@ -57,11 +57,6 @@ --strip-symbol='$$[adtx]*' \ ${.TARGET} -# Generate the .bin (booti images) kernel as an extra build output. -# The targets and rules to generate these appear near the end of the file. -KERNEL_EXTRA+= ${KERNEL_KO}.bin -KERNEL_EXTRA_INSTALL+= ${KERNEL_KO}.bin - .if !empty(DDB_ENABLED) || !empty(DTRACE_ENABLED) || !empty(HWPMC_ENABLED) CFLAGS += -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer .endif @@ -77,7 +72,6 @@ %FILES.m %CLEAN -CLEAN+= ${KERNEL_KO}.bin %RULES diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk --- a/sys/conf/kern.opts.mk +++ b/sys/conf/kern.opts.mk @@ -60,6 +60,7 @@ EXTRA_TCP_STACKS \ INIT_ALL_PATTERN \ INIT_ALL_ZERO \ + KERNEL_BIN \ KERNEL_RETPOLINE \ RATELIMIT \ REPRODUCIBLE_BUILD @@ -96,6 +97,11 @@ BROKEN_OPTIONS+=EFI .endif +# We only generate kernel.bin on arm and arm64, otherwise they break the build. +.if ${MACHINE} != "arm" ${MACHINE} != "arm64" +BROKEN_OPTIONS+=KERNEL_SYMBOLS +.endif + .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" __DEFAULT_NO_OPTIONS += FDT .else diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -470,4 +470,10 @@ .endif .endif +.if ${MK_KERNEL_BIN} != "no" +KERNEL_EXTRA+= ${KERNEL_KO}.bin +KERNEL_EXTRA_INSTALL+= ${KERNEL_KO}.bin +CLEAN+= ${KERNEL_KO}.bin +.endif + .include "kern.mk" diff --git a/tools/build/options/WITH_KERNEL_BIN b/tools/build/options/WITH_KERNEL_BIN new file mode 100644 --- /dev/null +++ b/tools/build/options/WITH_KERNEL_BIN @@ -0,0 +1,2 @@ +Generate and install kernel.bin from kernel as part of the normal build and +install processes for the kernel. Available only on arm and arm64.