2000-03-27 16:11:27 +00:00
|
|
|
|
2014-08-29 10:44:58 +00:00
|
|
|
# Use the following command to build local debug version of dynamic
|
|
|
|
# linker:
|
2019-04-14 18:04:53 +00:00
|
|
|
# make DEBUG_FLAGS=-g WITHOUT_TESTS=yes all
|
2014-08-29 10:44:58 +00:00
|
|
|
|
2019-11-07 22:58:10 +00:00
|
|
|
RTLD_ELF_DIR:= ${.PARSEDIR}
|
|
|
|
|
2014-05-06 04:22:01 +00:00
|
|
|
.include <src.opts.mk>
|
2016-02-05 21:01:08 +00:00
|
|
|
PACKAGE= clibs
|
2019-02-15 22:22:38 +00:00
|
|
|
MK_PIE= no # Always position independent using local rules
|
2021-08-02 08:48:21 +00:00
|
|
|
# Not compatible with sanitizer instrumentation or SSP.
|
|
|
|
MK_ASAN= no
|
2009-02-21 15:04:31 +00:00
|
|
|
MK_SSP= no
|
2021-08-02 08:48:21 +00:00
|
|
|
MK_UBSAN= no
|
2007-05-13 14:12:40 +00:00
|
|
|
|
2023-07-27 04:10:45 +00:00
|
|
|
.include <bsd.compat.pre.mk>
|
|
|
|
|
2024-05-13 05:23:50 +00:00
|
|
|
# SSP forced off already implies FORTIFY_SOURCE=0, but we must make sure that
|
|
|
|
# one cannot turn it back on.
|
|
|
|
FORTIFY_SOURCE= 0
|
|
|
|
|
2021-10-13 12:40:26 +00:00
|
|
|
.if !defined(NEED_COMPAT)
|
2018-09-18 00:25:00 +00:00
|
|
|
CONFS= libmap.conf
|
2021-10-13 12:40:26 +00:00
|
|
|
.endif
|
2004-03-21 01:21:26 +00:00
|
|
|
PROG?= ld-elf.so.1
|
2023-07-27 04:10:45 +00:00
|
|
|
.for _libcompat in ${_ALL_libcompats}
|
|
|
|
.if ${PROG:M*ld-elf${_libcompat}[-.]*} != ""
|
|
|
|
TAGS+= lib${_libcompat}
|
2016-02-05 21:01:08 +00:00
|
|
|
.endif
|
2023-07-27 04:10:45 +00:00
|
|
|
.endfor
|
2019-01-30 16:28:27 +00:00
|
|
|
SRCS= \
|
2020-07-16 22:01:01 +00:00
|
|
|
crtbrand.S \
|
2019-01-30 16:28:27 +00:00
|
|
|
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
|
2019-11-07 22:58:10 +00:00
|
|
|
MAN?= rtld.1
|
2020-07-16 22:01:01 +00:00
|
|
|
ACFLAGS+= -DLOCORE
|
2023-12-12 23:30:00 +00:00
|
|
|
CFLAGS+= -Wall -DIN_RTLD -ffreestanding
|
2015-12-01 22:20:04 +00:00
|
|
|
CFLAGS+= -I${SRCTOP}/lib/csu/common
|
2020-09-23 00:21:51 +00:00
|
|
|
.if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/})
|
|
|
|
RTLD_ARCH= ${MACHINE_ARCH:S/powerpc64le/powerpc64/}
|
2010-08-24 23:19:14 +00:00
|
|
|
.else
|
|
|
|
RTLD_ARCH= ${MACHINE_CPUARCH}
|
|
|
|
.endif
|
2019-11-07 22:58:10 +00:00
|
|
|
CFLAGS+= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR}
|
2018-10-29 21:08:19 +00:00
|
|
|
|
|
|
|
NO_WCAST_ALIGN= yes
|
2004-11-03 18:01:21 +00:00
|
|
|
INSTALLFLAGS= -C -b
|
|
|
|
PRECIOUSPROG=
|
2012-12-04 12:51:33 +00:00
|
|
|
BINDIR= /libexec
|
2017-03-07 05:10:38 +00:00
|
|
|
SYMLINKS= ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG}
|
2019-11-12 22:31:59 +00:00
|
|
|
MLINKS?= rtld.1 ld-elf.so.1.1 \
|
2003-02-13 23:07:28 +00:00
|
|
|
rtld.1 ld.so.1
|
1998-09-04 19:03:57 +00:00
|
|
|
|
2020-01-11 09:18:58 +00:00
|
|
|
CFLAGS+= -fpic -DPIC $(DEBUG)
|
2020-04-29 16:05:50 +00:00
|
|
|
|
2020-01-11 09:18:58 +00:00
|
|
|
LDFLAGS+= -shared -Wl,-Bsymbolic -Wl,-z,defs -nostdlib -e ${RTLD_ENTRY}
|
2019-06-30 11:49:58 +00:00
|
|
|
# Pull in the dependencies that we use from libc
|
|
|
|
.include "rtld-libc/Makefile.inc"
|
2007-04-03 19:01:06 +00:00
|
|
|
|
2015-12-01 22:20:04 +00:00
|
|
|
VERSION_DEF= ${LIBCSRCDIR}/Versions.def
|
2019-11-07 22:58:10 +00:00
|
|
|
SYMBOL_MAPS= ${RTLD_ELF_DIR}/Symbol.map
|
2007-04-03 19:01:06 +00:00
|
|
|
VERSION_MAP= Version.map
|
|
|
|
LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
|
|
|
|
|
2019-11-07 22:58:10 +00:00
|
|
|
.if exists(${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map)
|
|
|
|
SYMBOL_MAPS+= ${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map
|
2007-04-03 19:01:06 +00:00
|
|
|
.endif
|
1999-04-09 00:28:43 +00:00
|
|
|
|
2019-11-07 22:58:10 +00:00
|
|
|
.sinclude "${RTLD_ELF_DIR}/${RTLD_ARCH}/Makefile.inc"
|
2020-01-11 09:18:58 +00:00
|
|
|
RTLD_ENTRY?= .rtld_start
|
1998-03-07 19:24:35 +00:00
|
|
|
|
2024-02-28 00:04:37 +00:00
|
|
|
# Always produce the map file so that may be inspected to confirm
|
|
|
|
# undesired code is not linked from libsys/libc.
|
|
|
|
MAPFILE= ld-elf.so.1.map
|
|
|
|
LDFLAGS+= -Wl,-Map=${MAPFILE} -Wl,--cref
|
|
|
|
CLEANFILES+= ${MAPFILE}
|
|
|
|
|
2024-02-28 23:40:41 +00:00
|
|
|
afterbuild:
|
|
|
|
@if grep __libsys_interposing ${MAPFILE} >/dev/null ; then \
|
|
|
|
echo "libsys_interposing leaked" 1>&2 ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi
|
|
|
|
@if grep __libc_interposing ${MAPFILE} >/dev/null ; then \
|
|
|
|
echo "libc_interposing leaked" 1>&2 ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi
|
|
|
|
@if grep xlocale ${MAPFILE} >/dev/null ; then \
|
|
|
|
echo "xlocale leaked" 1>&2 ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi
|
|
|
|
@if grep fprintf ${MAPFILE} >/dev/null ; then \
|
|
|
|
echo "stdio leaked" 1>&2 ; \
|
|
|
|
exit 1 ; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2003-08-17 18:50:56 +00:00
|
|
|
# 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:
|
2015-09-18 23:12:38 +00:00
|
|
|
.if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no"
|
2012-12-04 14:36:01 +00:00
|
|
|
-chflags -h noschg ${DESTDIR}/usr/libexec/${PROG}
|
2004-11-14 22:18:31 +00:00
|
|
|
.endif
|
2003-08-17 18:50:56 +00:00
|
|
|
|
2020-07-16 22:01:01 +00:00
|
|
|
.PATH: ${RTLD_ELF_DIR}/${RTLD_ARCH} ${SRCTOP}/lib/csu/common
|
1998-03-07 19:24:35 +00:00
|
|
|
|
2019-11-07 22:58:10 +00:00
|
|
|
.if ${.CURDIR} == ${RTLD_ELF_DIR}
|
2017-08-02 08:50:42 +00:00
|
|
|
HAS_TESTS=
|
2017-08-02 08:35:51 +00:00
|
|
|
SUBDIR.${MK_TESTS}+= tests
|
2019-11-07 22:58:10 +00:00
|
|
|
.endif
|
2014-06-20 17:14:59 +00:00
|
|
|
|
2020-12-28 08:44:25 +00:00
|
|
|
# Some of the required math functions (div & mod) are implemented in
|
|
|
|
# libcompiler_rt on some architectures.
|
|
|
|
LIBADD+= compiler_rt
|
|
|
|
|
1998-03-07 19:24:35 +00:00
|
|
|
.include <bsd.prog.mk>
|
2016-07-03 17:28:39 +00:00
|
|
|
${PROG_FULL}: ${VERSION_MAP}
|
2015-12-01 22:50:32 +00:00
|
|
|
.include <bsd.symver.mk>
|
2018-10-29 21:08:19 +00:00
|
|
|
|
2018-10-29 21:08:28 +00:00
|
|
|
.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
|