Formalize the use of linker scripts for kernel modules.

Automatically apply ldscript.kmod.${MACHINE_ARCH} if it exists.
We already have an i386-specific linker script; rename it accordingly.

Note that the linker script is applied when the object files are
partially linked.  (For amd64 this is also the final link.)

Reviewed by:	imp, kib
Discussed with:	jhb
MFC after:	1 week
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21887
This commit is contained in:
markj 2019-10-16 22:19:56 +00:00
parent 341d641470
commit 39a2929b65
2 changed files with 4 additions and 6 deletions

View File

@ -242,18 +242,16 @@ 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}
.endif
.if ${__KLD_SHARED} == yes
${KMOD}.kld: ${OBJS}
.else
${FULLPROG}: ${OBJS}
.endif
.if !defined(FIRMWS) && (${MACHINE_CPUARCH} == "i386")
${LD} -m ${LD_EMULATION} ${_LDFLAGS} -r \
-T ${SYSDIR}/conf/ldscript.set_padding \
-d -o ${.TARGET} ${OBJS}
.else
${LD} -m ${LD_EMULATION} ${_LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
.endif
.if ${MK_CTF} != "no"
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}
.endif