svn commit: r316514 - head/sys/conf

John Baldwin jhb at FreeBSD.org
Wed Apr 5 03:05:06 UTC 2017


Author: jhb
Date: Wed Apr  5 03:05:04 2017
New Revision: 316514
URL: https://svnweb.freebsd.org/changeset/base/316514

Log:
  Always pass the linker emulation via -m when linking modules and kernels.
  
  Previously the linker emulation was only passed when building binary
  objects for firmware modules.  This change always passes the desired
  output format for kernel modules and kernels rather than requiring the
  toolchain's default output format to match the desired output format.
  This in turn permits use of external toolchains whose default output
  format does not match the desired output format.
  
  Reviewed by:	imp, emaste
  Sponsored by:	DARPA / AFRL
  Differential Revision:	https://reviews.freebsd.org/D10085

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

Modified: head/sys/conf/Makefile.arm
==============================================================================
--- head/sys/conf/Makefile.arm	Wed Apr  5 03:00:52 2017	(r316513)
+++ head/sys/conf/Makefile.arm	Wed Apr  5 03:05:04 2017	(r316514)
@@ -56,8 +56,8 @@ CFLAGS += -mllvm -arm-enable-ehabi
 # hack because genassym.c includes sys/bus.h which includes these.
 genassym.o: bus_if.h device_if.h
 
-SYSTEM_LD_ = ${LD} -Bdynamic -T ldscript.$M.noheader ${_LDFLAGS} \
-	--no-warn-mismatch --warn-common --export-dynamic \
+SYSTEM_LD_ = ${LD} -m ${LD_EMULATION} -Bdynamic -T ldscript.$M.noheader \
+	${_LDFLAGS} --no-warn-mismatch --warn-common --export-dynamic \
 	--dynamic-linker /red/herring \
 	-o ${FULLKERNEL}.noheader -X ${SYSTEM_OBJS} vers.o
 SYSTEM_LD_TAIL +=;sed s/" + SIZEOF_HEADERS"// ldscript.$M\

Modified: head/sys/conf/kern.mk
==============================================================================
--- head/sys/conf/kern.mk	Wed Apr  5 03:00:52 2017	(r316513)
+++ head/sys/conf/kern.mk	Wed Apr  5 03:05:04 2017	(r316514)
@@ -254,8 +254,7 @@ CFLAGS+=        -std=iso9899:1999
 CFLAGS+=        -std=${CSTD}
 .endif # CSTD
 
-# Set target-specific linker emulation name. Used by ld -b binary to convert
-# binary files into ELF objects.
+# Set target-specific linker emulation name.
 LD_EMULATION_aarch64=aarch64elf
 LD_EMULATION_amd64=elf_x86_64_fbsd
 LD_EMULATION_arm=armelf_fbsd

Modified: head/sys/conf/kern.pre.mk
==============================================================================
--- head/sys/conf/kern.pre.mk	Wed Apr  5 03:00:52 2017	(r316513)
+++ head/sys/conf/kern.pre.mk	Wed Apr  5 03:05:04 2017	(r316514)
@@ -184,8 +184,9 @@ MD_ROOT_SIZE_CONFIGURED!=	grep MD_ROOT_S
 SYSTEM_OBJS+= embedfs_${MFS_IMAGE:T:R}.o
 .endif
 .endif
-SYSTEM_LD= @${LD} -Bdynamic -T ${LDSCRIPT} ${_LDFLAGS} --no-warn-mismatch \
-	--warn-common --export-dynamic --dynamic-linker /red/herring \
+SYSTEM_LD= @${LD} -m ${LD_EMULATION} -Bdynamic -T ${LDSCRIPT} ${_LDFLAGS} \
+	--no-warn-mismatch --warn-common --export-dynamic \
+	--dynamic-linker /red/herring \
 	-o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
 	${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}

Modified: head/sys/conf/kmod.mk
==============================================================================
--- head/sys/conf/kmod.mk	Wed Apr  5 03:00:52 2017	(r316513)
+++ head/sys/conf/kmod.mk	Wed Apr  5 03:05:04 2017	(r316514)
@@ -210,7 +210,8 @@ ${PROG}.debug: ${FULLPROG}
 .if ${__KLD_SHARED} == yes
 ${FULLPROG}: ${KMOD}.kld
 .if ${MACHINE_CPUARCH} != "aarch64"
-	${LD} -Bshareable ${_LDFLAGS} -o ${.TARGET} ${KMOD}.kld
+	${LD} -m ${LD_EMULATION} -Bshareable ${_LDFLAGS} -o ${.TARGET} \
+	    ${KMOD}.kld
 .else
 #XXXKIB Relocatable linking in aarch64 ld from binutils 2.25.1 does
 #       not work.  The linker corrupts the references to the external
@@ -218,7 +219,7 @@ ${FULLPROG}: ${KMOD}.kld
 #       and should therefore loose the GOT entry.  The problem seems
 #       to be fixed in the binutils-gdb git HEAD as of 2015-10-04.  Hack
 #       below allows to get partially functioning modules for now.
-	${LD} -Bshareable ${_LDFLAGS} -o ${.TARGET} ${OBJS}
+	${LD} -m ${LD_EMULATION} -Bshareable ${_LDFLAGS} -o ${.TARGET} ${OBJS}
 .endif
 .if !defined(DEBUG_FLAGS)
 	${OBJCOPY} --strip-debug ${.TARGET}
@@ -235,7 +236,7 @@ ${KMOD}.kld: ${OBJS}
 .else
 ${FULLPROG}: ${OBJS}
 .endif
-	${LD} ${_LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
+	${LD} -m ${LD_EMULATION} ${_LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
 .if ${MK_CTF} != "no"
 	${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}
 .endif


More information about the svn-src-all mailing list