Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/share/mk/bsd.lib.mk,v rcsdiff: /ftp/cvs/cvsroot/src/share/mk/bsd.lib.mk,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.369 retrieving revision 1.372 diff -u -p -r1.369 -r1.372 --- src/share/mk/bsd.lib.mk 2017/04/20 09:29:11 1.369 +++ src/share/mk/bsd.lib.mk 2017/05/29 03:52:43 1.372 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.lib.mk,v 1.369 2017/04/20 09:29:11 ozaki-r Exp $ +# $NetBSD: bsd.lib.mk,v 1.372 2017/05/29 03:52:43 christos Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .include @@ -42,7 +42,8 @@ realinstall: checkver libinstall # XXX: This is needed for programs that link with .a libraries # Perhaps a more correct solution is to always generate _pic.a # files or always have a shared library. -# XXX: This breaks profiling (__mcount relocation is wrong) +# Another fix is to provide rcrt0.o like OpenBSD does and +# do relocations for static PIE. .if defined(MKPIE) && (${MKPIE} != "no") && !defined(NOPIE) CFLAGS+= ${PIE_CFLAGS} AFLAGS+= ${PIE_AFLAGS} @@ -632,7 +633,8 @@ ${_LIB.so.full}: ${_LIB.so.link} ${_LIB. ${_MKTARGET_CREATE} ( ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ --add-gnu-debuglink=${_LIB.so.debug} \ - ${_LIB.so.link} ${_LIB.so.full} \ + ${_LIB.so.link} ${_LIB.so.full}.tmp && \ + mv -f ${_LIB.so.full}.tmp ${_LIB.so.full} \ ) || (rm -f ${.TARGET}; false) ${_LIB.so.link}: ${_MAINLIBDEPS} .else # aka no MKDEBUG @@ -641,9 +643,13 @@ ${_LIB.so.full}: ${_MAINLIBDEPS} ${_MKTARGET_BUILD} rm -f ${.TARGET} ${LIBCC} ${LDLIBC} -shared ${SHLIB_SHFLAGS} \ - ${_LDFLAGS.${_LIB}} -o ${.TARGET} ${_LIBLDOPTS} \ + ${_LDFLAGS.${_LIB}} -o ${.TARGET}.tmp ${_LIBLDOPTS} \ -Wl,--whole-archive ${SOLIB} \ -Wl,--no-whole-archive ${_LDADD.${_LIB}} +.if ${MKSTRIPIDENT} != "no" + ${OBJCOPY} -R .ident ${.TARGET}.tmp +.endif + mv -f ${.TARGET}.tmp ${.TARGET} # We don't use INSTALL_SYMLINK here because this is just # happening inside the build directory/objdir. XXX Why does # this spend so much effort on libraries that aren't live??? XXX @@ -656,9 +662,6 @@ ${_LIB.so.full}: ${_MAINLIBDEPS} .endif ${HOST_LN} -sf ${_LIB.so.full} ${_LIB.so}.tmp mv -f ${_LIB.so}.tmp ${_LIB.so} -.if ${MKSTRIPIDENT} != "no" - ${OBJCOPY} -R .ident ${.TARGET} -.endif .if !empty(LOBJS) # { LLIBS?= -lc