diff options
author | kib <kib@FreeBSD.org> | 2015-10-08 17:42:08 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2015-10-08 17:42:08 +0000 |
commit | b2d840b61f56cbfedd019495716c72ad05e2b46c (patch) | |
tree | 7ec5d2391d1ce937db12fe46445cab4cc4e60e82 /sys | |
parent | 48b0cbf71b32ca05aa12ce0a6cc627de9cf5b979 (diff) | |
download | FreeBSD-src-b2d840b61f56cbfedd019495716c72ad05e2b46c.zip FreeBSD-src-b2d840b61f56cbfedd019495716c72ad05e2b46c.tar.gz |
Build changes that allow the modules on arm64.
- Move the required kernel compiler flags from Makefile.arm64 to kern.mk.
- Build arm64 modules as PIC; non-PIC relocations in .o for shared object
output cannot be handled.
- Do not try to install aarch64 symlink.
- A hack for arm64 to avoid ld -r stage. See the comment for the explanation.
Some functionality is lost, like ctf handling, but hopefully will be
restored after newer linker is available.
Reviewed by: andrew, emaste
Tested by: andrew (on real hardware)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3796
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arm64/conf/GENERIC | 1 | ||||
-rw-r--r-- | sys/conf/Makefile.arm64 | 6 | ||||
-rw-r--r-- | sys/conf/kern.mk | 7 | ||||
-rw-r--r-- | sys/conf/kern.post.mk | 2 | ||||
-rw-r--r-- | sys/conf/kmod.mk | 16 |
5 files changed, 23 insertions, 9 deletions
diff --git a/sys/arm64/conf/GENERIC b/sys/arm64/conf/GENERIC index 26ca51d..1486f07 100644 --- a/sys/arm64/conf/GENERIC +++ b/sys/arm64/conf/GENERIC @@ -22,7 +22,6 @@ cpu ARM64 ident GENERIC makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -makeoptions NO_MODULES=1 # We don't yet support modules on arm64 options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption diff --git a/sys/conf/Makefile.arm64 b/sys/conf/Makefile.arm64 index 46c191c..324daa7 100644 --- a/sys/conf/Makefile.arm64 +++ b/sys/conf/Makefile.arm64 @@ -27,12 +27,6 @@ S= ../../.. INCLUDES+= -I$S/contrib/libfdt -# We generally don't want fpu instructions in the kernel. -CFLAGS += -mgeneral-regs-only - -# Reserve x18 for pcpu data -CFLAGS += -ffixed-x18 - .if !empty(DDB_ENABLED) CFLAGS += -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer .endif diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index 7f1c026..56ddbda 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -97,6 +97,13 @@ INLINE_LIMIT?= 8000 INLINE_LIMIT?= 8000 .endif +.if ${MACHINE_CPUARCH} == "aarch64" +# We generally don't want fpu instructions in the kernel. +CFLAGS += -mgeneral-regs-only +# Reserve x18 for pcpu data +CFLAGS += -ffixed-x18 +.endif + # # For sparc64 we want the medany code model so modules may be located # anywhere in the 64-bit address space. We also tell GCC to use floating diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk index 0703cc8..55b4fd7 100644 --- a/sys/conf/kern.post.mk +++ b/sys/conf/kern.post.mk @@ -212,7 +212,7 @@ SRCS= assym.s vnode_if.h ${BEFORE_DEPEND} ${CFILES} \ mv .newdep .depend _ILINKS= machine -.if ${MACHINE} != ${MACHINE_CPUARCH} +.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" _ILINKS+= ${MACHINE_CPUARCH} .endif .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 47bc593..06e4cfc 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -113,6 +113,10 @@ CFLAGS+= ${DEBUG_FLAGS} CFLAGS+= -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer .endif +.if ${MACHINE_CPUARCH} == "aarch64" +CFLAGS+= -fPIC +.endif + # Temporary workaround for PR 196407, which contains the fascinating details. # Don't allow clang to use fpu instructions or registers in kernel modules. .if ${MACHINE_CPUARCH} == arm @@ -182,7 +186,17 @@ ${PROG}.debug: ${FULLPROG} .if ${__KLD_SHARED} == yes ${FULLPROG}: ${KMOD}.kld +.if ${MACHINE_CPUARCH} != "aarch64" ${LD} -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 +# symbols which are defined by other object in the linking set +# 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} +.endif .if !defined(DEBUG_FLAGS) ${OBJCOPY} --strip-debug ${.TARGET} .endif @@ -220,7 +234,7 @@ ${FULLPROG}: ${OBJS} .endif _ILINKS=machine -.if ${MACHINE} != ${MACHINE_CPUARCH} +.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" _ILINKS+=${MACHINE_CPUARCH} .endif .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" |