Module Name: src
Committed By: matt
Date: Wed Aug 7 17:36:12 UTC 2013
Modified Files:
src/share/mk: bsd.kmodule.mk
Log Message:
Add support for generating tramponlines in the module at link time.
This is done using some awk scripts and KMODTRAMPOLINE in <machine/asm.h>
It's not as efficient as having the kloader do it but it is a lot simpler.
To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/share/mk/bsd.kmodule.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/share/mk/bsd.kmodule.mk
diff -u src/share/mk/bsd.kmodule.mk:1.38 src/share/mk/bsd.kmodule.mk:1.39
--- src/share/mk/bsd.kmodule.mk:1.38 Tue Aug 6 06:08:39 2013
+++ src/share/mk/bsd.kmodule.mk Wed Aug 7 17:36:11 2013
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.kmodule.mk,v 1.38 2013/08/06 06:08:39 skrll Exp $
+# $NetBSD: bsd.kmodule.mk,v 1.39 2013/08/07 17:36:11 matt Exp $
# We are not building this with PIE
MKPIE=no
@@ -27,7 +27,7 @@ CFLAGS+= -fno-strict-aliasing -Wno-point
# relocations inside the loader and removing this workaround, as the
# resulting code would be much faster.
.if ${MACHINE_CPU} == "arm"
-CFLAGS+= -mlong-calls
+CFLAGS+= -fno-common
.elif ${MACHINE_CPU} == "hppa"
CFLAGS+= -mlong-calls
.elif ${MACHINE_CPU} == "powerpc"
@@ -104,11 +104,46 @@ OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
${OBJS} ${LOBJS}: ${DPSRCS}
+.if ${MACHINE_CPU} == "arm"
+# The solution to limited branch space involves generating trampolines for
+# those relocations while creating the module, as the resulting code will
+# be much faster and simplifies the loader.
+ARCHDIR= $S/modules/arch/${MACHINE_CPU}
+ASM_H= $S/arch/${MACHINE_CPU}/include/asm.h
+CLEANFILES+= tmp.o tmp.S ${KMOD}_tmp.o ${KMOD}_tramp.o ${KMOD}_tramp.S
+${KMOD}_tmp.o: ${OBJS} ${DPADD}
+ ${_MKTARGET_LINK}
+ ${LD} -r -o tmp.o ${OBJS}
+ ${LD} -r \
+ `${OBJDUMP} --syms --reloc tmp.o | \
+ ${TOOL_AWK} -f ${ARCHDIR}/kmodwrap.awk` \
+ -o ${.TARGET} tmp.o
+
+${KMOD}_tramp.S: ${KMOD}_tmp.o ${ARCHDIR}/kmodtramp.awk ${ASM_H}
+ ${_MKTARGET_CREATE}
+ ${OBJDUMP} --syms --reloc ${KMOD}_tmp.o | \
+ ${TOOL_AWK} -f ${ARCHDIR}/kmodtramp.awk \
+ > tmp.S && \
+ mv tmp.S ${.TARGET}
+
+${PROG}: ${KMOD}_tmp.o ${KMOD}_tramp.o
+ ${_MKTARGET_LINK}
+.if exists(${ARCHDIR}/kmodhide.awk)
+ ${LD} -r -o tmp.o ${KMOD}_tmp.o ${KMOD}_tramp.o
+ ${OBJCOPY} \
+ `${NM} tmp.o | ${TOOL_AWK} -f ${ARCHDIR}/kmodhide.awk` \
+ tmp.o ${.TARGET} && \
+ rm tmp.o
+.else
+ ${LD} -r -o ${.TARGET} ${KMOD}_tmp.o ${KMOD}_tramp.o
+.endif
+.else
${PROG}: ${OBJS} ${DPADD}
${_MKTARGET_LINK}
${CC} ${LDFLAGS} -nostdlib -r -Wl,-T,${KMODSCRIPT},-d \
-o ${.TARGET} ${OBJS}
.endif
+.endif
##### Install rules
.if !target(kmodinstall)