83aa9cc00c
particular on ARM, do require working init arrays. Traditional FreeBSD crt1 calls _init and _fini of the binary, instead of allowing runtime linker to arrange the calls. This was probably done to have the same crt code serve both statically and dynamically linked binaries. Since ABI mandates that first is called preinit array functions, then init, and then init array functions, the init have to be called from rtld now. To provide binary compatibility to old FreeBSD crt1, which calls _init itself, rtld only calls intializers and finalizers for main binary if binary has a note indicating that new crt was used for linking. Add parsing of ELF notes to rtld, and cache p_osrel value since we parsed it anyway. The patch is inspired by init_array support for DragonflyBSD, written by John Marino. Reviewed by: kan Tested by: andrew (arm, previous version), flo (sparc64, previous version) MFC after: 3 weeks
71 lines
1.6 KiB
Makefile
71 lines
1.6 KiB
Makefile
# $FreeBSD$
|
|
|
|
.include <bsd.own.mk>
|
|
MK_SSP= no
|
|
|
|
PROG?= ld-elf.so.1
|
|
SRCS= rtld_start.S \
|
|
reloc.c rtld.c rtld_lock.c rtld_printf.c map_object.c \
|
|
malloc.c xmalloc.c debug.c libmap.c
|
|
MAN= rtld.1
|
|
CSTD?= gnu99
|
|
CFLAGS+= -Wall -DFREEBSD_ELF -DIN_RTLD
|
|
CFLAGS+= -I${.CURDIR}/../../lib/csu/common
|
|
.if exists(${.CURDIR}/${MACHINE_ARCH})
|
|
RTLD_ARCH= ${MACHINE_ARCH}
|
|
.else
|
|
RTLD_ARCH= ${MACHINE_CPUARCH}
|
|
.endif
|
|
CFLAGS+= -I${.CURDIR}/${RTLD_ARCH} -I${.CURDIR}
|
|
.if ${MACHINE_ARCH} == "powerpc64"
|
|
CFLAGS+= -mcall-aixdesc
|
|
LDFLAGS+= -nostdlib -e _rtld_start
|
|
.else
|
|
LDFLAGS+= -nostdlib -e .rtld_start
|
|
.endif
|
|
WARNS?= 2
|
|
INSTALLFLAGS= -C -b
|
|
PRECIOUSPROG=
|
|
BINDIR= /libexec
|
|
SYMLINKS= ${BINDIR}/${PROG} /usr/libexec/${PROG}
|
|
MLINKS= rtld.1 ld-elf.so.1.1 \
|
|
rtld.1 ld.so.1
|
|
|
|
.if ${MACHINE_CPUARCH} == "sparc64"
|
|
CFLAGS+= -fPIC
|
|
.else
|
|
CFLAGS+= -fpic
|
|
.endif
|
|
CFLAGS+= -DPIC $(DEBUG)
|
|
LDFLAGS+= -shared -Wl,-Bsymbolic
|
|
DPADD= ${LIBC_PIC}
|
|
LDADD= -lc_pic -lssp_nonshared
|
|
|
|
.if ${MK_SYMVER} == "yes"
|
|
LIBCDIR= ${.CURDIR}/../../lib/libc
|
|
VERSION_DEF= ${LIBCDIR}/Versions.def
|
|
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
|
|
VERSION_MAP= Version.map
|
|
LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
|
|
|
|
${PROG}: ${VERSION_MAP}
|
|
|
|
.if exists(${.CURDIR}/${RTLD_ARCH}/Symbol.map)
|
|
SYMBOL_MAPS+= ${.CURDIR}/${RTLD_ARCH}/Symbol.map
|
|
.endif
|
|
.endif
|
|
|
|
.sinclude "${.CURDIR}/${RTLD_ARCH}/Makefile.inc"
|
|
|
|
# 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:
|
|
.if exists(${DESTDIR}/usr/libexec/${PROG})
|
|
-chflags noschg ${DESTDIR}/usr/libexec/${PROG}
|
|
.endif
|
|
|
|
.PATH: ${.CURDIR}/${RTLD_ARCH}
|
|
|
|
.include <bsd.symver.mk>
|
|
.include <bsd.prog.mk>
|