Index: lib/libcompiler_rt/Makefile =================================================================== --- lib/libcompiler_rt/Makefile +++ lib/libcompiler_rt/Makefile @@ -4,7 +4,8 @@ PACKAGE= lib${LIB} LIB= compiler_rt -NO_PIC= +NO_SHLIB= +BUILD_NOSSP_PIC_ARCHIVE= WARNS?= 2 CFLAGS+= ${PICFLAG} Index: libexec/rtld-elf/Makefile =================================================================== --- libexec/rtld-elf/Makefile +++ libexec/rtld-elf/Makefile @@ -82,6 +82,11 @@ SUBDIR.${MK_TESTS}+= tests .endif +# Some of the required math functions (div & mod) are implemented in +# libcompiler_rt on some architectures. We link a special static build of the +# library without -fstack-protector (SSP). +LIBADD+= compiler_rt_nossp_pic + .include ${PROG_FULL}: ${VERSION_MAP} .include Index: libexec/rtld-elf/arm/Makefile.inc =================================================================== --- libexec/rtld-elf/arm/Makefile.inc +++ libexec/rtld-elf/arm/Makefile.inc @@ -1,8 +1,3 @@ # $FreeBSD$ -# Some of the required math functions (div & mod) are implemented in -# libcompiler_rt on ARM. The library also needs to be placed first to be -# correctly linked. As some of the functions are used before we have -# shared libraries. -LIBADD+= compiler_rt CFLAGS+= -mfpu=none Index: libexec/rtld-elf/rtld-libc/Makefile.inc =================================================================== --- libexec/rtld-elf/rtld-libc/Makefile.inc +++ libexec/rtld-elf/rtld-libc/Makefile.inc @@ -57,22 +57,14 @@ # ARM needs aeabi_unwind_cpp for _setjmp _libc_other_objects+=aeabi_unwind_cpp .elif ${LIBC_ARCH} == "i386" -# __udivdi3 is needed by kvprintf() in rtld_printf.c -# i386 also needs i386_set_gsbase for allocate_initial_tls() -_libc_other_objects+=umoddi3 udivdi3 qdivrem i386_set_gsbase +# i386 needs i386_set_gsbase for allocate_initial_tls() +_libc_other_objects+=i386_set_gsbase .elif ${LIBC_ARCH} == "powerpc" || ${LIBC_ARCH} == "powerpcspe" -# ppc needs __syncicache for reloc.c and __umoddi3+__udivdi3 for rtld_printf.c -_libc_other_objects+=syncicache umoddi3 udivdi3 qdivrem -# for some reason there is also a reference to abs() -_libc_other_objects+=abs +# ppc needs __syncicache and abs for reloc.c +_libc_other_objects+=syncicache abs .elif ${LIBC_ARCH} == "powerpc64" # ppc64 needs __syncicache for reloc.c _libc_other_objects+=syncicache -.elif ${LIBC_ARCH} == "mips" -# 32-bit MIPS needs __umoddi3+__udivdi3 for rtld_printf.c -.if ${MACHINE_ARCH:Mmipsn32*} == "" && ${MACHINE_ARCH:Mmips64*} == "" -_libc_other_objects+=umoddi3 udivdi3 qdivrem -.endif .endif # Extract all the .o files from libc_nossp_pic.a. This ensures that Index: share/mk/bsd.lib.mk =================================================================== --- share/mk/bsd.lib.mk +++ share/mk/bsd.lib.mk @@ -25,9 +25,11 @@ # INSTALL_PIC_ARCHIVE will be defined only if we are to create a PIC archive. # BUILD_NOSSP_PIC_ARCHIVE will be defined only if we are to create a PIC archive. .if defined(NO_PIC) -.undef SHLIB_NAME .undef INSTALL_PIC_ARCHIVE .undef BUILD_NOSSP_PIC_ARCHIVE +.endif +.if defined(NO_PIC) || defined(NO_SHLIB) +.undef SHLIB_NAME .else .if !defined(SHLIB) && defined(LIB) SHLIB= ${LIB} Index: share/mk/src.libnames.mk =================================================================== --- share/mk/src.libnames.mk +++ share/mk/src.libnames.mk @@ -36,6 +36,7 @@ amu \ bsnmptools \ c_nossp_pic \ + compiler_rt_nossp_pic \ cron \ elftc \ fifolog \ @@ -592,6 +593,9 @@ LIBC_NOSSP_PICDIR= ${_LIB_OBJTOP}/lib/libc LIBC_NOSSP_PIC?= ${LIBC_NOSSP_PICDIR}/libc_nossp_pic.a +LIBCOMPILER_RT_NOSSP_PICDIR= ${_LIB_OBJTOP}/lib/libcompiler_rt +LIBCOMPILER_RT_NOSSP_PIC?= ${LIBCOMPILER_RT_NOSSP_PICDIR}/libcompiler_rt_nossp_pic.a + # Define a directory for each library. This is useful for adding -L in when # not using a --sysroot or for meta mode bootstrapping when there is no # Makefile.depend. These are sorted by directory.