1# $FreeBSD$ 2 3# Use the following command to build local debug version of dynamic 4# linker: 5# make DEBUG_FLAGS=-g WITHOUT_TESTS=yes all 6 7RTLD_ELF_DIR:= ${.PARSEDIR} 8 9.include <src.opts.mk> 10PACKAGE= clibs 11MK_PIE= no # Always position independent using local rules 12MK_SSP= no 13 14.if !defined(NEED_COMPAT) 15CONFS= libmap.conf 16.endif 17PROG?= ld-elf.so.1 18.if (${PROG:M*ld-elf32*} != "") 19TAGS+= lib32 20.endif 21SRCS= \ 22 crtbrand.S \ 23 rtld_start.S \ 24 reloc.c \ 25 rtld.c \ 26 rtld_lock.c \ 27 rtld_malloc.c \ 28 rtld_printf.c \ 29 map_object.c \ 30 xmalloc.c \ 31 debug.c \ 32 libmap.c 33MAN?= rtld.1 34ACFLAGS+= -DLOCORE 35CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding 36CFLAGS+= -I${SRCTOP}/lib/csu/common 37.if exists(${RTLD_ELF_DIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/}) 38RTLD_ARCH= ${MACHINE_ARCH:S/powerpc64le/powerpc64/} 39.else 40RTLD_ARCH= ${MACHINE_CPUARCH} 41.endif 42CFLAGS+= -I${RTLD_ELF_DIR}/${RTLD_ARCH} -I${RTLD_ELF_DIR} 43 44NO_WCAST_ALIGN= yes 45INSTALLFLAGS= -C -b 46PRECIOUSPROG= 47BINDIR= /libexec 48SYMLINKS= ../..${BINDIR}/${PROG} ${LIBEXECDIR}/${PROG} 49MLINKS?= rtld.1 ld-elf.so.1.1 \ 50 rtld.1 ld.so.1 51 52CFLAGS+= -fpic -DPIC $(DEBUG) 53 54LDFLAGS+= -shared -Wl,-Bsymbolic -Wl,-z,defs -nostdlib -e ${RTLD_ENTRY} 55# Pull in the dependencies that we use from libc 56.include "rtld-libc/Makefile.inc" 57.if ${MK_TOOLCHAIN} == "no" 58LDFLAGS+= -L${LIBCDIR} 59.endif 60 61VERSION_DEF= ${LIBCSRCDIR}/Versions.def 62SYMBOL_MAPS= ${RTLD_ELF_DIR}/Symbol.map 63VERSION_MAP= Version.map 64LDFLAGS+= -Wl,--version-script=${VERSION_MAP} 65 66.if exists(${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map) 67SYMBOL_MAPS+= ${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map 68.endif 69 70.sinclude "${RTLD_ELF_DIR}/${RTLD_ARCH}/Makefile.inc" 71RTLD_ENTRY?= .rtld_start 72 73# Since moving rtld-elf to /libexec, we need to create a symlink. 74# Fixup the existing binary that's there so we can symlink over it. 75beforeinstall: 76.if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no" 77 -chflags -h noschg ${DESTDIR}/usr/libexec/${PROG} 78.endif 79 80.PATH: ${RTLD_ELF_DIR}/${RTLD_ARCH} ${SRCTOP}/lib/csu/common 81 82.if ${.CURDIR} == ${RTLD_ELF_DIR} 83HAS_TESTS= 84SUBDIR.${MK_TESTS}+= tests 85.endif 86 87# Some of the required math functions (div & mod) are implemented in 88# libcompiler_rt on some architectures. 89LIBADD+= compiler_rt 90 91.include <bsd.prog.mk> 92${PROG_FULL}: ${VERSION_MAP} 93.include <bsd.symver.mk> 94 95.if ${COMPILER_TYPE} == "gcc" 96# GCC warns about redeclarations even though they have __exported 97# and are therefore not identical to the ones from the system headers. 98CFLAGS+= -Wno-redundant-decls 99.endif 100