rtld-elf: link libcompiler_rt on all architectures

Statically link rtld-elf with libcompiler_rt on all architectures so
that we don't need to try to pick and choose the bits we need from it
for each architecture (we now leave that to the linker).  Compilers may
emit calls to support functions in this library, but because of the use
of the linker flag -nostdlib for rtld's special needs, the library is
not linked as normal.

Previously we had two different solutions.  On some architectures, we
were able to extract reimplementations of the necessary builtin
functions from our special build of libc.  On ARM, we just linked
libcompiler_rt.

This is motivated by the same issue as D26199 and D27665, but should be
a simpler solution that will apply to all architectures.

Reviewed by:	arichardson, kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D27736
This commit is contained in:
Ryan Libby 2020-12-28 00:44:25 -08:00
parent 85b8932d0a
commit 63f93c7e11
3 changed files with 8 additions and 17 deletions

View File

@ -82,6 +82,10 @@ HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests SUBDIR.${MK_TESTS}+= tests
.endif .endif
# Some of the required math functions (div & mod) are implemented in
# libcompiler_rt on some architectures.
LIBADD+= compiler_rt
.include <bsd.prog.mk> .include <bsd.prog.mk>
${PROG_FULL}: ${VERSION_MAP} ${PROG_FULL}: ${VERSION_MAP}
.include <bsd.symver.mk> .include <bsd.symver.mk>

View File

@ -1,8 +1,3 @@
# $FreeBSD$ # $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 CFLAGS+= -mfpu=none

View File

@ -57,22 +57,14 @@ _libc_other_objects= sigsetjmp lstat stat fstat fstatat fstatfs syscall \
# ARM needs aeabi_unwind_cpp for _setjmp # ARM needs aeabi_unwind_cpp for _setjmp
_libc_other_objects+=aeabi_unwind_cpp _libc_other_objects+=aeabi_unwind_cpp
.elif ${LIBC_ARCH} == "i386" .elif ${LIBC_ARCH} == "i386"
# __udivdi3 is needed by kvprintf() in rtld_printf.c # i386 needs i386_set_gsbase for allocate_initial_tls()
# i386 also needs i386_set_gsbase for allocate_initial_tls() _libc_other_objects+=i386_set_gsbase
_libc_other_objects+=umoddi3 udivdi3 qdivrem i386_set_gsbase
.elif ${LIBC_ARCH} == "powerpc" || ${LIBC_ARCH} == "powerpcspe" .elif ${LIBC_ARCH} == "powerpc" || ${LIBC_ARCH} == "powerpcspe"
# ppc needs __syncicache for reloc.c and __umoddi3+__udivdi3 for rtld_printf.c # ppc needs __syncicache and abs for reloc.c
_libc_other_objects+=syncicache umoddi3 udivdi3 qdivrem _libc_other_objects+=syncicache abs
# for some reason there is also a reference to abs()
_libc_other_objects+=abs
.elif ${LIBC_ARCH} == "powerpc64" .elif ${LIBC_ARCH} == "powerpc64"
# ppc64 needs __syncicache for reloc.c # ppc64 needs __syncicache for reloc.c
_libc_other_objects+=syncicache _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 .endif
# Extract all the .o files from libc_nossp_pic.a. This ensures that # Extract all the .o files from libc_nossp_pic.a. This ensures that