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