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