d3980376e8
functions to be used by the dynamic linker. This can be called by threads packages at start-up time. I will add the call to libc_r soon. Also add a default locking method that is used up until dllockinit() is called. The default method works by blocking SIGVTALRM, SIGPROF, and SIGALRM in critical sections. It is based on the observation that most user-space threads packages implement thread preemption with one of these signals (usually SIGVTALRM). The dynamic linker has never been reentrant, but it became less reentrant in revision 1.34 of "src/libexec/rtld-elf/rtld.c". Starting with that revision, multiple threads each doing lazy binding could interfere with each other. The usual symptom was that a symbol was falsely reported as undefined at start-up time. It was rare but not unseen. This commit fixes it.
43 lines
1.0 KiB
Makefile
43 lines
1.0 KiB
Makefile
#
|
|
# $FreeBSD$
|
|
#
|
|
MAINTAINER= jdp
|
|
PROG= ld-elf.so.1
|
|
SRCS= rtld_start.S rtld.c lockdflt.c map_object.c malloc.c \
|
|
xmalloc.c debug.c reloc.c
|
|
NOMAN= true
|
|
CFLAGS+= -Wall -DFREEBSD_ELF -I${.CURDIR}/${MACHINE_ARCH} -I${.CURDIR}
|
|
LDFLAGS+= -nostdlib -e .rtld_start
|
|
INSTALLFLAGS+= -fschg -C
|
|
|
|
.if exists(${.CURDIR}/${MACHINE_ARCH}/Makefile.inc)
|
|
.include "${.CURDIR}/${MACHINE_ARCH}/Makefile.inc"
|
|
.endif
|
|
|
|
# If LDSCRIPT is defined, we build the dynamic linker as an
|
|
# executable. Otherwise we build it as a shared object. We ignore
|
|
# LDSCRIPT if the running kernel is too old to support it.
|
|
.if defined(LDSCRIPT)
|
|
KERN_OSRELDATE!= /sbin/sysctl -n kern.osreldate 2>/dev/null || echo 0
|
|
.if ${KERN_OSRELDATE} >= 400001
|
|
LDSO_IS_EXECUTABLE= yes
|
|
.endif
|
|
.endif
|
|
|
|
.ifdef LDSO_IS_EXECUTABLE
|
|
OBJS+= dyn_hack.so
|
|
LDFLAGS+= -Wl,-T,${LDSCRIPT} -Wl,-E -Wl,-Bstatic
|
|
LDADD+= -lc
|
|
.else
|
|
CFLAGS+= -fpic -DPIC
|
|
LDFLAGS+= -shared -Wl,-Bsymbolic
|
|
LDADD+= -lc_pic
|
|
.endif
|
|
|
|
dyn_hack.so:
|
|
${CC} -shared -nostdlib -o dyn_hack.so -x c /dev/null
|
|
|
|
.PATH: ${.CURDIR}/${MACHINE_ARCH}
|
|
|
|
.include <bsd.prog.mk>
|