Date: Sun, 29 Jul 2001 19:24:49 +0200 From: Sheldon Hearn <sheldonh@starjuice.net> To: hackers@FreeBSD.org Subject: Why objcopy --strip-debug instead of strip? Message-ID: <82186.996427489@axl.seasidesoftware.co.za>
next in thread | raw e-mail | index | archive | help
Hi folks, When the kernel is built as kernel.debug, why is it passed through objcopy --strip-debug before being installed, instead of being passed through strip? Background: I recently found that the Handbook instructions for "Debugging Loadable Modules Using GDB" is mostly useless for post-mortem crash dump analysis, because buildkernel doesn't build modules with debugging support, even when CONFIGARGS=-g. The attached patch (for the i386 only) fixes this so that, if kernel.debug is built, foo.ko.debug etc. are built. For each foo.ko.debug, we produce foo.ko with objcopy --strip-debug and install foo.ko. What I'm unsure of is why it's worth going to all this trouble. Why not simply build all the modules with debugging support compiled in (assuming debugging support was requested for the kernel), and strip them at install time (install -s)? Ciao, Sheldon. Index: /usr/src/sys/conf/Makefile.i386 =================================================================== RCS file: /home/ncvs/src/sys/conf/Makefile.i386,v retrieving revision 1.240 diff -u -d -r1.240 Makefile.i386 --- /usr/src/sys/conf/Makefile.i386 2001/07/26 23:04:46 1.240 +++ /usr/src/sys/conf/Makefile.i386 2001/07/29 16:51:56 @@ -272,6 +272,9 @@ .if defined(MODULES_OVERRIDE) MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" .endif +.if defined(DEBUG) +MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}" +.endif modules: @mkdir -p ${.OBJDIR}/modules Index: /usr/src/sys/conf/kmod.mk =================================================================== RCS file: /home/ncvs/src/sys/conf/kmod.mk,v retrieving revision 1.104 diff -u -d -r1.104 kmod.mk --- /usr/src/sys/conf/kmod.mk 2001/07/18 09:59:55 1.104 +++ /usr/src/sys/conf/kmod.mk 2001/07/29 17:15:59 @@ -77,6 +77,7 @@ KMODLOAD?= /sbin/kldload KMODUNLOAD?= /sbin/kldunload +OBJCOPY?= objcopy TARGET_ARCH?= ${MACHINE_ARCH} @@ -131,7 +132,15 @@ PROG= ${KMOD}.ko .endif -${PROG}: ${KMOD}.kld +.if !defined(DEBUG) +FULLPROG= ${PROG} +.else +FULLPROG= ${PROG}.debug +${PROG}: ${FULLPROG} + ${OBJCOPY} --strip-debug ${FULLPROG} ${PROG} +.endif + +${FULLPROG}: ${KMOD}.kld ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld ${KMOD}.kld: ${OBJS} @@ -188,7 +197,7 @@ ${ECHO} ${.TARGET} "->" $$path ; \ ln -s $$path ${.TARGET} -CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS} ${_ILINKS} symb.tmp tmp.o +CLEANFILES+= ${PROG} ${FULLPROG} ${KMOD}.kld ${OBJS} ${_ILINKS} symb.tmp tmp.o .if !target(install) .if !target(beforeinstall) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?82186.996427489>