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 7.include <src.opts.mk> 8PACKAGE= clibs 9MK_SSP= no 10 11CONFS= libmap.conf 12PROG?= ld-elf.so.1 13.if (${PROG:M*ld-elf32*} != "") 14TAGS+= lib32 15.endif 16SRCS= \ 17 rtld_start.S \ 18 reloc.c \ 19 rtld.c \ 20 rtld_lock.c \ 21 rtld_malloc.c \ 22 rtld_printf.c \ 23 map_object.c \ 24 xmalloc.c \ 25 debug.c \ 26 libmap.c 27MAN= rtld.1 28CSTD?= gnu99 29CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD -ffreestanding 30CFLAGS+= -I${SRCTOP}/lib/csu/common 31.if exists(${.CURDIR}/${MACHINE_ARCH}) 32RTLD_ARCH= ${MACHINE_ARCH} 33.else 34RTLD_ARCH= ${MACHINE_CPUARCH} 35.endif 36CFLAGS+= -I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR} 37.if ${MACHINE_ARCH} == "powerpc64" 38LDFLAGS+= -nostdlib -e _rtld_start 39.else 40LDFLAGS+= -nostdlib -e .rtld_start 41.endif 42 43NO_WCAST_ALIGN= yes 44WARNS?= 6 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 52.if ${MACHINE_CPUARCH} == "sparc64" 53CFLAGS+= -fPIC 54.else 55CFLAGS+= -fpic 56.endif 57CFLAGS+= -DPIC $(DEBUG) 58.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" 59CFLAGS+= -fvisibility=hidden 60.endif 61.if ${MACHINE_CPUARCH} == "mips" 62CFLAGS.reloc.c+=-fno-jump-tables 63.endif 64LDFLAGS+= -shared -Wl,-Bsymbolic -Wl,-z,defs 65LIBADD= c_nossp_pic 66.if ${MK_TOOLCHAIN} == "no" 67LDFLAGS+= -L${LIBCDIR} 68.endif 69 70.if ${MACHINE_CPUARCH} == "arm" 71# Some of the required math functions (div & mod) are implemented in 72# libcompiler_rt on ARM. The library also needs to be placed first to be 73# correctly linked. As some of the functions are used before we have 74# shared libraries. 75LIBADD+= compiler_rt 76.endif 77 78 79 80.if ${MK_SYMVER} == "yes" 81VERSION_DEF= ${LIBCSRCDIR}/Versions.def 82SYMBOL_MAPS= ${.CURDIR}/Symbol.map 83VERSION_MAP= Version.map 84LDFLAGS+= -Wl,--version-script=${VERSION_MAP} 85 86.if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map) 87SYMBOL_MAPS+= ${.CURDIR}/${RTLD_ARCH}/Symbol.map 88.endif 89.endif 90 91.sinclude "${.CURDIR}/${RTLD_ARCH}/Makefile.inc" 92 93# Since moving rtld-elf to /libexec, we need to create a symlink. 94# Fixup the existing binary that's there so we can symlink over it. 95beforeinstall: 96.if exists(${DESTDIR}/usr/libexec/${PROG}) && ${MK_STAGING} == "no" 97 -chflags -h noschg ${DESTDIR}/usr/libexec/${PROG} 98.endif 99 100.PATH: ${.CURDIR}/${RTLD_ARCH} 101 102HAS_TESTS= 103SUBDIR.${MK_TESTS}+= tests 104 105.include <bsd.prog.mk> 106${PROG_FULL}: ${VERSION_MAP} 107.include <bsd.symver.mk> 108 109.if ${COMPILER_TYPE} == "gcc" 110# GCC warns about redeclarations even though they have __exported 111# and are therefore not identical to the ones from the system headers. 112CFLAGS+= -Wno-redundant-decls 113.if ${COMPILER_VERSION} < 40300 114# Silence -Wshadow false positives in ancient GCC 115CFLAGS+= -Wno-shadow 116.endif 117.endif 118