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.
This commit is contained in:
lukem 2010-11-08 06:54:52 +00:00
parent 05eafeb6bd
commit 44f36b23ab
2 changed files with 10 additions and 9 deletions

View File

@ -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 <bsd.init.mk>
@ -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) # {

View File

@ -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}) # }