3 # Use the following command to build local debug version of dynamic
5 # make DEBUG_FLAGS=-g WITHOUT_TESTS=yes all
7 RTLD_ELF_DIR:= ${.PARSEDIR}
11 MK_PIE= no # Always position independent using local rules
12 # Not compatible with sanitizer instrumentation or SSP.
17 .if !defined(NEED_COMPAT)
21 .if (${PROG:M*ld-elf32*} != "")
38 CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding
39 CFLAGS+= -I${SRCTOP}/lib/csu/common
40 .if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/})
41 RTLD_ARCH= ${MACHINE_ARCH:S/powerpc64le/powerpc64/}
43 RTLD_ARCH= ${MACHINE_CPUARCH}
45 CFLAGS+= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR}
51 SYMLINKS= ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG}
52 MLINKS?= rtld.1 ld-elf.so.1.1 \
55 CFLAGS+= -fpic -DPIC $(DEBUG)
57 LDFLAGS+= -shared -Wl,-Bsymbolic -Wl,-z,defs -nostdlib -e ${RTLD_ENTRY}
58 # Pull in the dependencies that we use from libc
59 .include "rtld-libc/Makefile.inc"
60 .if ${MK_TOOLCHAIN} == "no"
61 LDFLAGS+= -L${LIBCDIR}
64 VERSION_DEF= ${LIBCSRCDIR}/Versions.def
65 SYMBOL_MAPS= ${RTLD_ELF_DIR}/Symbol.map
66 VERSION_MAP= Version.map
67 LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
69 .if exists(${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map)
70 SYMBOL_MAPS+= ${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map
73 .sinclude "${RTLD_ELF_DIR}/${RTLD_ARCH}/Makefile.inc"
74 RTLD_ENTRY?= .rtld_start
76 # Since moving rtld-elf to /libexec, we need to create a symlink.
77 # Fixup the existing binary that's there so we can symlink over it.
79 .if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no"
80 -chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
83 .PATH: ${RTLD_ELF_DIR}/${RTLD_ARCH} ${SRCTOP}/lib/csu/common
85 .if ${.CURDIR} == ${RTLD_ELF_DIR}
87 SUBDIR.${MK_TESTS}+= tests
90 # Some of the required math functions (div & mod) are implemented in
91 # libcompiler_rt on some architectures.
94 .include <bsd.prog.mk>
95 ${PROG_FULL}: ${VERSION_MAP}
96 .include <bsd.symver.mk>
98 .if ${COMPILER_TYPE} == "gcc"
99 # GCC warns about redeclarations even though they have __exported
100 # and are therefore not identical to the ones from the system headers.
101 CFLAGS+= -Wno-redundant-decls