blob: fc49cf49fce4698194c7c1d358d8df88bfefebfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# $OpenBSD: Makefile,v 1.68 2017/08/27 22:16:14 deraadt Exp $
SUBDIR=ldconfig ldd
MAN= ld.so.1
.include <bsd.own.mk>
.if defined(NOPIC)
NOPROG=
.else
PROG= ld.so
BINMODE=444
VERSION_SCRIPT= ${.CURDIR}/Symbols.map
ELF_LDFLAGS+=--version-script=${VERSION_SCRIPT}
VPATH=${.CURDIR}/../../lib/libc/string
SRCS= ldasm.S boot.c loader.c resolve.c dlfcn.c dl_printf.c rtld_machine.c
SRCS+= path.c util.c sod.c strsep.c strtol.c dir.c library_subr.c
SRCS+= dl_realpath.c dl_uname.c dl_dirname.c strlcat.c strlen.c trace.c
SRCS+= malloc.c reallocarray.c tib.c
syscall=__syscall close exit fstat __getcwd getdents getentropy getthrid \
issetugid mprotect munmap open pledge read readlink sendsyslog \
__set_tcb sysctl thrkill utrace write
.for _i in ${syscall}
OBJS+=dl_${_i}.o
dl_${_i}.o: SYS.h
printf '#include "SYS.h"\nDL_SYSCALL(${_i})\n' | \
${CC} ${DEBUG} -c -fPIC ${CFLAGS:M-[ID]*} ${CFLAGS:M-pipe} ${AINC} -P \
-x assembler-with-cpp - ${DFLAGS} -MF ${.TARGET:R}.d -o ${.TARGET}
.endfor
.if (${MACHINE_ARCH} == "i386")
SRCS+= library_mquery.c
.else
SRCS+= library.c
.endif
.include "${.CURDIR}/${MACHINE_CPU}/Makefile.inc"
.PATH: ${.CURDIR}/${MACHINE_CPU}
DEBUG?= -g
CFLAGS += -fno-builtin
CFLAGS += -Wall -Werror
CFLAGS += -I${.CURDIR} -I${.CURDIR}/${MACHINE_CPU} \
-D'DEF_WEAK(x)=asm("")' -D'DEF_STRONG(x)=asm("")' \
-Dstrsep=_dl_strsep -Dstrlcat=_dl_strlcat -Dstrlen=_dl_strlen
CDIAGFLAGS=
INSTALL_STRIP=
ELF_LDFLAGS+=--shared -Bsymbolic --no-undefined
test_prog= test-$(PROG)
CLEANFILES+= test-$(PROG)
candidate= $(PROG).test
CLEANFILES+= ${candidate}
$(test_prog):
printf '#include <stdio.h>\nint main(int argc, char **argv){ printf("%%s: ", argv[0]); printf("%%s!\\n", argv[1] ? argv[1] : "foo"); }\n' | \
$(CC) -x c - -Wl,-dynamic-linker,./$(candidate) -o $@
$(PROG): $(test_prog) ${VERSION_SCRIPT} $(OBJS)
$(LD) ${DEBUG} -x -e _dl_start $(ELF_LDFLAGS) -o $(candidate) \
`echo ${OBJS} | tr " " "\n" | sort -R`
.ifndef CROSSDIR
ulimit -c 0; [ "`${.OBJDIR}/$(test_prog) ok`" = "${.OBJDIR}/$(test_prog): ok!" ]
.endif
cp $(candidate) $@
.endif
.include <bsd.prog.mk>
boot.o: boot.c
${COMPILE.c} -fno-stack-protector ${.IMPSRC}
|