From 44f36b23abbf45d6f0f4d73c8b1727788458c126 Mon Sep 17 00:00:00 2001 From: lukem Date: Mon, 8 Nov 2010 06:54:52 +0000 Subject: [PATCH] Preserve date on original shared library or program when stripping the debug symbols and adding the debug-link to .debug. Use '(rm -f file; false)' in the failure path to force failure. Based on solution proposed by Nicolas Joly on tech-toolchain in July 2010. Should fix PR toolchain/44046 from Andreas Gustafsson. --- share/mk/bsd.lib.mk | 10 +++++----- share/mk/bsd.prog.mk | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 91cccfe846fb..e0afd37b7f9a 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.lib.mk,v 1.308 2010/07/06 05:59:56 mrg Exp $ +# $NetBSD: bsd.lib.mk,v 1.309 2010/11/08 06:54:52 lukem Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .include @@ -589,10 +589,10 @@ lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOLIB} ${DPADD} ${DPLIBC} \ .if defined(_LIB.debug) ${_LIB.debug}: ${_LIB.so} ${_MKTARGET_CREATE} - ${OBJCOPY} --only-keep-debug ${_LIB.so} ${_LIB.debug} - ${OBJCOPY} --strip-debug \ - -R .gnu_debuglink --add-gnu-debuglink=${_LIB.debug} ${_LIB.so} \ - || rm -f ${_LIB.debug} + ( ${OBJCOPY} --only-keep-debug ${_LIB.so} ${_LIB.debug} \ + && ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ + --add-gnu-debuglink=${_LIB.debug} ${_LIB.so} \ + ) || (rm -f ${_LIB.debug}; false) .endif .if !empty(LOBJS) # { diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index f7f42f4a7b05..eccffd587e82 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -1,4 +1,4 @@ -# $NetBSD: bsd.prog.mk,v 1.250 2010/10/31 11:52:53 mbalmer Exp $ +# $NetBSD: bsd.prog.mk,v 1.251 2010/11/08 06:54:52 lukem Exp $ # @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 .ifndef HOSTPROG @@ -315,9 +315,10 @@ ${_P}.ro: ${OBJS.${_P}} ${DPADD} .if defined(_PROGDEBUG.${_P}) ${_PROGDEBUG.${_P}}: ${_P} ${_MKTARGET_CREATE} - ${OBJCOPY} --only-keep-debug ${_P} ${_PROGDEBUG.${_P}} - ${OBJCOPY} --strip-debug -R .gnu_debuglink --add-gnu-debuglink=${_PROGDEBUG.${_P}} ${_P} \ - || rm -f ${_PROGDEBUG.${_P}} + ( ${OBJCOPY} --only-keep-debug ${_P} ${_PROGDEBUG.${_P}} \ + && ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ + --add-gnu-debuglink=${_PROGDEBUG.${_P}} ${_P} \ + ) || (rm -f ${_PROGDEBUG.${_P}}; false) .endif .endif # defined(OBJS.${_P}) && !empty(OBJS.${_P}) # }