Module Name:    src
Committed By:   jmmv
Date:           Mon Jan 18 23:39:08 UTC 2010

Modified Files:
        src/share/mk: bsd.kmodule.mk

Log Message:
Generate long calls in modules for arm32 and powerpc to avoid unsupported
relocations by the module loader in the kernel.  This makes modules work
in, at least, shark and macppc respectively.

This is obviously a workaround that results in slower code, but at least
makes modules work.  I'm adding a comment detailing what the real solution
would be so that the whole thing can be revisited in the future.  (Read:
I don't have time now to dig the details of how to implement trampoline
generation.)

(Based on the old bsd.kmod.mk file, I understand that hppa needs this
workaround too, but I can't check this platform.)


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 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.23 src/share/mk/bsd.kmodule.mk:1.24
--- src/share/mk/bsd.kmodule.mk:1.23	Mon Dec 14 08:51:16 2009
+++ src/share/mk/bsd.kmodule.mk	Mon Jan 18 23:39:07 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.kmodule.mk,v 1.23 2009/12/14 08:51:16 mrg Exp $
+#	$NetBSD: bsd.kmodule.mk,v 1.24 2010/01/18 23:39:07 jmmv Exp $
 
 # We are not building this with PIE
 MKPIE=no
@@ -23,6 +23,18 @@
 CFLAGS+=	-fno-strict-aliasing -Wno-pointer-sign
 .endif
 
+# XXX This is a workaround for platforms that have relative relocations
+# that, when relocated by the module loader, result in addresses that
+# overflow the size of the relocation (e.g. R_PPC_REL24 in powerpc).
+# The real solution to this involves generating trampolines for those
+# relocations inside the loader and removing this workaround, as the
+# resulting code would be much faster.
+.if ${MACHINE_CPU} == "arm"
+CFLAGS+=	-mlong-calls
+.elif ${MACHINE_CPU} == "powerpc"
+CFLAGS+=	-mlongcall
+.endif
+
 _YKMSRCS=	${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
 DPSRCS+=	${_YKMSRCS}
 CLEANFILES+=	${_YKMSRCS}

Reply via email to