Author: emaste
Date: Tue Sep 20 17:07:14 2016
New Revision: 306041
URL: https://svnweb.freebsd.org/changeset/base/306041

Log:
  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

Modified:
  head/sys/conf/kern.mk
  head/sys/conf/kern.pre.mk
  head/sys/conf/kmod.mk

Modified: head/sys/conf/kern.mk
==============================================================================
--- head/sys/conf/kern.mk       Tue Sep 20 16:55:59 2016        (r306040)
+++ head/sys/conf/kern.mk       Tue Sep 20 17:07:14 2016        (r306041)
@@ -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}}

Modified: head/sys/conf/kern.pre.mk
==============================================================================
--- head/sys/conf/kern.pre.mk   Tue Sep 20 16:55:59 2016        (r306040)
+++ head/sys/conf/kern.pre.mk   Tue Sep 20 17:07:14 2016        (r306041)
@@ -119,7 +119,7 @@ NORMAL_M= ${AWK} -f $S/tools/makeobjops.
 
 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

Modified: head/sys/conf/kmod.mk
==============================================================================
--- head/sys/conf/kmod.mk       Tue Sep 20 16:55:59 2016        (r306040)
+++ head/sys/conf/kmod.mk       Tue Sep 20 17:07:14 2016        (r306041)
@@ -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
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to