From ecae3df1db025f84d0b4c77c00c5c2e66ac70f1e Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Fri, 25 Oct 2019 20:15:04 +0000 Subject: [PATCH] Apply kernel module linker scripts to firmware files. Use a separate make variable to specify the linker script so that it is only applied at link time and not during intermediate generation of .fwo files. This ensures that the .text padding inserted by the amd64 linker script is applied to the stub module load handlers embedded in firmware modules. Reviewed by: kib MFC after: 2 weeks Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D22125 --- sys/conf/kmod.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 4218d0ed7416..8b7d57207ce0 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -242,8 +242,8 @@ EXPORT_SYMS?= NO CLEANFILES+= export_syms .endif -.if !defined(FIRMWS) && exists(${SYSDIR}/conf/ldscript.kmod.${MACHINE_ARCH}) -_LDFLAGS+=-T ${SYSDIR}/conf/ldscript.kmod.${MACHINE_ARCH} +.if exists(${SYSDIR}/conf/ldscript.kmod.${MACHINE_ARCH}) +LDSCRIPT_FLAGS?= -T ${SYSDIR}/conf/ldscript.kmod.${MACHINE_ARCH} .endif .if ${__KLD_SHARED} == yes @@ -251,7 +251,8 @@ ${KMOD}.kld: ${OBJS} .else ${FULLPROG}: ${OBJS} .endif - ${LD} -m ${LD_EMULATION} ${_LDFLAGS} -r -d -o ${.TARGET} ${OBJS} + ${LD} -m ${LD_EMULATION} ${_LDFLAGS} ${LDSCRIPT_FLAGS} -r -d \ + -o ${.TARGET} ${OBJS} .if ${MK_CTF} != "no" ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} .endif