63f93c7e11
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
98 lines
2.4 KiB
Makefile
98 lines
2.4 KiB
Makefile
# $FreeBSD$
|
|
|
|
# Use the following command to build local debug version of dynamic
|
|
# linker:
|
|
# make DEBUG_FLAGS=-g WITHOUT_TESTS=yes all
|
|
|
|
RTLD_ELF_DIR:= ${.PARSEDIR}
|
|
|
|
.include <src.opts.mk>
|
|
PACKAGE= clibs
|
|
MK_PIE= no # Always position independent using local rules
|
|
MK_SSP= no
|
|
|
|
CONFS= libmap.conf
|
|
PROG?= ld-elf.so.1
|
|
.if (${PROG:M*ld-elf32*} != "")
|
|
TAGS+= lib32
|
|
.endif
|
|
SRCS= \
|
|
crtbrand.S \
|
|
rtld_start.S \
|
|
reloc.c \
|
|
rtld.c \
|
|
rtld_lock.c \
|
|
rtld_malloc.c \
|
|
rtld_printf.c \
|
|
map_object.c \
|
|
xmalloc.c \
|
|
debug.c \
|
|
libmap.c
|
|
MAN?= rtld.1
|
|
ACFLAGS+= -DLOCORE
|
|
CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding
|
|
CFLAGS+= -I${SRCTOP}/lib/csu/common
|
|
.if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/})
|
|
RTLD_ARCH= ${MACHINE_ARCH:S/powerpc64le/powerpc64/}
|
|
.else
|
|
RTLD_ARCH= ${MACHINE_CPUARCH}
|
|
.endif
|
|
CFLAGS+= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR}
|
|
|
|
NO_WCAST_ALIGN= yes
|
|
INSTALLFLAGS= -C -b
|
|
PRECIOUSPROG=
|
|
BINDIR= /libexec
|
|
SYMLINKS= ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG}
|
|
MLINKS?= rtld.1 ld-elf.so.1.1 \
|
|
rtld.1 ld.so.1
|
|
|
|
CFLAGS+= -fpic -DPIC $(DEBUG)
|
|
|
|
LDFLAGS+= -shared -Wl,-Bsymbolic -Wl,-z,defs -nostdlib -e ${RTLD_ENTRY}
|
|
# Pull in the dependencies that we use from libc
|
|
.include "rtld-libc/Makefile.inc"
|
|
.if ${MK_TOOLCHAIN} == "no"
|
|
LDFLAGS+= -L${LIBCDIR}
|
|
.endif
|
|
|
|
VERSION_DEF= ${LIBCSRCDIR}/Versions.def
|
|
SYMBOL_MAPS= ${RTLD_ELF_DIR}/Symbol.map
|
|
VERSION_MAP= Version.map
|
|
LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
|
|
|
|
.if exists(${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map)
|
|
SYMBOL_MAPS+= ${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map
|
|
.endif
|
|
|
|
.sinclude "${RTLD_ELF_DIR}/${RTLD_ARCH}/Makefile.inc"
|
|
RTLD_ENTRY?= .rtld_start
|
|
|
|
# Since moving rtld-elf to /libexec, we need to create a symlink.
|
|
# Fixup the existing binary that's there so we can symlink over it.
|
|
beforeinstall:
|
|
.if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no"
|
|
-chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
|
|
.endif
|
|
|
|
.PATH: ${RTLD_ELF_DIR}/${RTLD_ARCH} ${SRCTOP}/lib/csu/common
|
|
|
|
.if ${.CURDIR} == ${RTLD_ELF_DIR}
|
|
HAS_TESTS=
|
|
SUBDIR.${MK_TESTS}+= tests
|
|
.endif
|
|
|
|
# Some of the required math functions (div & mod) are implemented in
|
|
# libcompiler_rt on some architectures.
|
|
LIBADD+= compiler_rt
|
|
|
|
.include <bsd.prog.mk>
|
|
${PROG_FULL}: ${VERSION_MAP}
|
|
.include <bsd.symver.mk>
|
|
|
|
.if ${COMPILER_TYPE} == "gcc"
|
|
# GCC warns about redeclarations even though they have __exported
|
|
# and are therefore not identical to the ones from the system headers.
|
|
CFLAGS+= -Wno-redundant-decls
|
|
.endif
|