1 # $NetBSD: Makefile,v 1.114 2012/08/23 21:21:15 joerg Exp $
3 # NOTE: when changing ld.so, ensure that ldd still compiles.
8 # Minix Clang binaries references /libexec/ld.elf_so
9 SYMLINKS
+= ${SHLINKINSTALLDIR}/${PROG} /libexec
/ld.elf_so
10 # And the minix gcc currently references /libexec/ld-elf.so.1
11 SYMLINKS
+= ${SHLINKINSTALLDIR}/${PROG} /libexec
/ld-elf.so
.1
13 # This needs to be before bsd.init.mk
14 .if defined
(BSD_MK_COMPAT_FILE
)
15 .
include <${BSD_MK_COMPAT_FILE}>
18 # We are not building this with PIE
21 .
include <bsd.init.mk
> # for MKPIC definition
22 .
include <bsd.shlib.mk
> # for SHLINKINSTALLDIR definition
24 .if defined
(LDELFSO_MACHINE_CPU
) && !empty
(LDELFSO_MACHINE_CPU
) && \
25 exists
(${.CURDIR
}/arch
/${LDELFSO_MACHINE_CPU})
26 ARCHSUBDIR
= ${LDELFSO_MACHINE_CPU}
28 ARCHSUBDIR
= ${MACHINE_CPU}
30 M
= ${.CURDIR
}/arch
/${ARCHSUBDIR}
32 .if
((${MACHINE_ARCH} == "alpha") || \
33 (${MACHINE_CPU} == "arm") || \
34 (${MACHINE_ARCH} == "hppa") || \
35 (${MACHINE_ARCH} == "i386") || \
36 (${MACHINE_ARCH} == "m68k") || \
37 (${MACHINE_CPU} == "mips") || \
38 (${MACHINE_ARCH} == "powerpc") || \
39 (${MACHINE_CPU} == "sh3") || \
40 (${MACHINE_ARCH} == "sparc") || \
41 (${MACHINE_ARCH} == "sparc64") || \
42 (${MACHINE_ARCH} == "x86_64") || \
43 (${MACHINE_ARCH} == "vax")) && \
46 LDFLAGS
+= ${${ACTIVE_CC} == "clang":?
-Wl
,-Bsymbolic
: -symbolic
} \
47 -shared
-nostartfiles
-nodefaultlibs
49 LDFLAGS
+= -Wl
,--warn-shared-textrel
51 COPTS
+= -fvisibility
=hidden
53 # Adds SRCS, CPPFLAGS, LDFLAGS, etc. Must go first so MD startup source
55 .if exists
($M/Makefile.inc
)
56 .
include "$M/Makefile.inc"
59 # Support compat ld.elf_so.
61 PROG
= ld.elf_so-
${MLIBDIR}
62 CPPFLAGS
+= -DRTLD_ARCH_SUBDIR
=\"${MLIBDIR}\"
67 CLIBOBJ
!= cd
${NETBSDSRCDIR}/lib
/libc
&& ${PRINTOBJDIR}
69 SRCS
+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
70 map_object.c load.c search.c headers.c paths.c expand.c \
71 tls.c symver.c diagassert.c
73 .if
${USE_FORT} == "yes"
74 .PATH.c
: ${NETBSDSRCDIR}/lib
/libc
/misc
75 SRCS
+= stack_protector.c
78 .PATH.c
: ${NETBSDSRCDIR}/lib
/libc
/stdlib
81 errlist_concat.h
: ${NETBSDSRCDIR}/lib
/libc
/gen
/errlist.awk
${NETBSDSRCDIR}/sys
/sys
/errno.h
82 ${TOOL_AWK} -v concat
=1 -f
${.ALLSRC
} > ${.TARGET
}.tmp
&& \
83 mv
-f
${.TARGET
}.tmp
${.TARGET
}
85 xprintf.c
: errlist_concat.h
87 CLEANFILES
+= errlist_concat.h
89 BINDIR
= ${SHLINKINSTALLDIR}
91 CPPFLAGS
+= -DLIBDIR
=\"${LIBDIR}\" -D_PATH_RTLD
=\"${BINDIR}/${PROG}\"
92 CPPFLAGS
+= -I
${.CURDIR
} -I.
93 CPPFLAGS
+= -DRTLD_LOADER
94 CPPFLAGS
+= -D_RTLD_SOURCE
95 CPPFLAGS
+= -DCOMBRELOC
97 #CPPFLAGS+= -DRTLD_DEBUG
98 #CPPFLAGS+= -DRTLD_DEBUG_RELOC
100 COPTS
= -O3
-fomit-frame-pointer
102 .if
${MACHINE_ARCH} == "i386" ||
${MACHINE_ARCH} == "x86_64"
103 COPTS
+= -mno-3dnow
-mno-mmx
-mno-sse
-mno-sse2
-mno-sse3
107 .if
${SHLIBDIR} != ${LIBDIR}
108 CPPFLAGS
+= -DRTLD_DEFAULT_LIBRARY_PATH
=\"${SHLIBDIR}:${LIBDIR}\"
111 # rtld.c and symbol.c use alloca, so disable SSP warnings.
112 COPTS.rtld.c
+= -Wno-stack-protector
113 COPTS.symbol.c
+=-Wno-stack-protector
115 LDADD
+= -L
${CLIBOBJ} -L
${DESTDIR}${LIBDIR}
116 .if
${MKPICLIB} != "no"
118 .if
${MKPICINSTALL} != "no"
121 DPADD
+= ${CLIBOBJ}/libc_pic.a
124 DPADD
+= ${CLIBOBJ}/libc.a
127 .if
${MACHINE_CPU} == "hppa" ||
${MACHINE_CPU} == "sh3"
128 # for $$divU, $$remU etc. (millicode)
137 ${PROG}: ${OBJS} ${DPADD}
138 ${_MKMSG_LINK} ${PROG}
139 ${CC} ${LDFLAGS} -o
${PROG} ${OBJS} ${LDADD}
141 .if
${SHLINKINSTALLDIR} != "/usr/libexec"
142 SYMLINKS
+= ${SHLINKINSTALLDIR}/${PROG} /usr
/libexec
/${PROG}
145 .
include <bsd.prog.mk
>
150 .
include <bsd.man.mk
>