Always pass -m to ld for converting binary files to kernel ELF objects

This is in preparation for linking with LLVM's lld, which does not have
a compiled-in default output emulation. lld requires that it is
specified via the -m option, or obtained from the object file(s) being
linked.

This will also allow all build targets to share a common linker binary.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7837
This commit is contained in:
Ed Maste 2016-09-20 17:07:14 +00:00
parent 43f24e2096
commit 1dd50172b0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=306041
3 changed files with 25 additions and 3 deletions

View File

@ -244,3 +244,23 @@ CFLAGS+= -std=iso9899:1999
.else # CSTD
CFLAGS+= -std=${CSTD}
.endif # CSTD
# Set target-specific linker emulation name. Used by ld -b binary to convert
# binary files into ELF objects.
LD_EMULATION_aarch64=aarch64elf
LD_EMULATION_amd64=elf_x86_64_fbsd
LD_EMULATION_arm=armelf_fbsd
LD_EMULATION_armeb=armelf_fbsd
LD_EMULATION_armv6=armelf_fbsd
LD_EMULATION_i386=elf_i386_fbsd
LD_EMULATION_mips= elf32btsmip_fbsd
LD_EMULATION_mips64= elf64btsmip_fbsd
LD_EMULATION_mipsel= elf32ltsmip_fbsd
LD_EMULATION_mips64el= elf64ltsmip_fbsd
LD_EMULATION_mipsn32= elf32btsmipn32_fbsd
LD_EMULATION_mipsn32el= elf32btsmipn32_fbsd # I don't think this is a thing that works
LD_EMULATION_powerpc= elf32ppc_fbsd
LD_EMULATION_powerpc64= elf64ppc_fbsd
LD_EMULATION_riscv= elf64riscv
LD_EMULATION_sparc64= elf64_sparc_fbsd
LD_EMULATION=${LD_EMULATION_${MACHINE_ARCH}}

View File

@ -119,7 +119,7 @@ NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \
-o ${.TARGET} ${.ALLSRC:M*.fw}
-m ${LD_EMULATION} -o ${.TARGET} ${.ALLSRC:M*.fw}
# Common for dtrace / zfs
CDDL_CFLAGS= -DFREEBSD_NAMECACHE -nostdinc -I$S/cddl/compat/opensolaris -I$S/cddl/contrib/opensolaris/uts/common -I$S -I$S/cddl/contrib/opensolaris/common ${CFLAGS} -Wno-unknown-pragmas -Wno-missing-prototypes -Wno-undef -Wno-strict-prototypes -Wno-cast-qual -Wno-parentheses -Wno-redundant-decls -Wno-missing-braces -Wno-uninitialized -Wno-unused -Wno-inline -Wno-switch -Wno-pointer-arith -Wno-unknown-pragmas

View File

@ -171,11 +171,13 @@ ${_firmw:C/\:.*$/.fwo/:T}: ${_firmw:C/\:.*$//}
@${ECHO} ${_firmw:C/\:.*$//} ${.ALLSRC:M*${_firmw:C/\:.*$//}}
@if [ -e ${_firmw:C/\:.*$//} ]; then \
${LD} -b binary --no-warn-mismatch ${_LDFLAGS} \
-r -d -o ${.TARGET} ${_firmw:C/\:.*$//}; \
-m ${LD_EMULATION} -r -d \
-o ${.TARGET} ${_firmw:C/\:.*$//}; \
else \
ln -s ${.ALLSRC:M*${_firmw:C/\:.*$//}} ${_firmw:C/\:.*$//}; \
${LD} -b binary --no-warn-mismatch ${_LDFLAGS} \
-r -d -o ${.TARGET} ${_firmw:C/\:.*$//}; \
-m ${LD_EMULATION} -r -d \
-o ${.TARGET} ${_firmw:C/\:.*$//}; \
rm ${_firmw:C/\:.*$//}; \
fi