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
This commit is contained in:
Mark Johnston 2019-10-25 20:15:04 +00:00
parent 5e921ff49e
commit ecae3df1db
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354096

View File

@ -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