Permalink
Browse files

Put shared library debug info into separate .symbols file

Sponsored by: ADARA Networks
  • Loading branch information...
1 parent 15a5cdc commit 4e712d334b7cd15ac18d7f60fe1340d57cc09932 @emaste emaste committed Dec 15, 2012
Showing with 22 additions and 2 deletions.
  1. +20 −2 share/mk/bsd.lib.mk
  2. +2 −0 share/mk/sys.mk
View
@@ -173,11 +173,15 @@ SOLINKOPTS+= -Wl,--fatal-warnings -Wl,--warn-shared-textrel
.if target(beforelinking)
${SHLIB_NAME}: beforelinking
.endif
+.if defined(DEBUG_FLAGS)
+${SHLIB_NAME}.debug: ${SOBJS}
+.else
${SHLIB_NAME}: ${SOBJS}
+.endif
@${ECHO} building shared library ${SHLIB_NAME}
- @rm -f ${.TARGET} ${SHLIB_LINK}
+ @rm -f ${SHLIB_NAME} ${SHLIB_LINK}
.if defined(SHLIB_LINK)
- @ln -fs ${.TARGET} ${SHLIB_LINK}
+ @ln -fs ${SHLIB_NAME} ${SHLIB_LINK}
.endif
.if !defined(NM)
@${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
@@ -191,6 +195,15 @@ ${SHLIB_NAME}: ${SOBJS}
.if ${MK_CTF} != "no"
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
.endif
+
+.if defined(DEBUG_FLAGS)
+${SHLIB_NAME}: ${SHLIB_NAME}.debug ${SHLIB_NAME}.symbols
+ ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.symbols \
+ ${SHLIB_NAME}.debug ${.TARGET}
+
+${SHLIB_NAME}.symbols: ${SHLIB_NAME}.debug
+ ${OBJCOPY} --only-keep-debug ${SHLIB_NAME}.debug ${.TARGET}
+.endif
.endif
.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
@@ -267,6 +280,11 @@ _libinstall:
${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
+.if defined(DEBUG_FLAGS)
+ ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
+ ${SHLIB_NAME}.symbols ${DESTDIR}${SHLIBDIR}
+.endif
.if defined(SHLIB_LINK)
# ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building
# and when building 32 bits library shims. ${_SHLIBDIRPREFIX} is the directory
View
@@ -134,6 +134,8 @@ NM ?= nm
OBJC ?= cc
OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
+OBJCOPY ?= objcopy
+
PC ?= pc
PFLAGS ?=

0 comments on commit 4e712d3

Please sign in to comment.