DragonFly kernel List (threaded) for 2007-08
DragonFly BSD
DragonFly kernel List (threaded) for 2007-08
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: error in creating amd64 port rtld modules


From: "Noah yan" <noah.yan@xxxxxxxxx>
Date: Fri, 31 Aug 2007 15:14:25 -0500

a module is stripped, but contains the gnu debug link to the debug
symbols to save the RAM size when load to memory.

Attached is the patch for sys/conf/kmod.mk. hope somebody check this.

Noah

On 8/31/07, Simon 'corecode' Schubert <corecode@fs.ei.tum.de> wrote:
> Noah yan wrote:
> > thanks Joerg, you are right. I checked with freebsd kmod.mk, amd64
> > module linking is special. After merged it in dfly, it is something
> > like this, i.e. use objcopy to create the rtld module:
>
> [btw, it is "kld", not "rtld"]
>
> > ld  -r -d -o scsi_low.ko.debug scsi_low.o scsi_low_pisa.o
> > awk -f /home/yanyh/gitscm/dragonfly.cvs2git/sys/bus/cam/scsi/../../../conf/kmod_syms.awk
> > scsi_low.ko.debug  export_syms | xargs -J% objcopy % scsi_low.ko.debug
> > objcopy --only-keep-debug scsi_low.ko.debug scsi_low.ko.symbols
> > objcopy --strip-debug --add-gnu-debuglink=scsi_low.ko.symbols
> > scsi_low.ko.debug scsi_low.ko
>
> could you please change this so that all modules per default carry debug info, i.e. don't get stripped?
>
> thanks
>   simon
>
--- sys/conf/kmod.mk.orig	2007-08-31 14:57:04 -0500
+++ sys/conf/kmod.mk	2007-08-31 14:58:52 -0500
@@ -1,6 +1,6 @@
 #	From: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
 # $FreeBSD: src/sys/conf/kmod.mk,v 1.82.2.15 2003/02/10 13:11:50 nyan Exp $
-# $DragonFly: src/sys/conf/kmod.mk,v 1.33 2007/08/26 07:53:25 corecode Exp $
+# $DragonFly: src/sys/conf/kmod.mk,v 1.32 2007/01/19 07:23:42 dillon Exp $
 #
 # The include file <bsd.kmod.mk> handles installing Kernel Loadable Device
 # drivers (KLD's).
@@ -58,9 +58,11 @@
 # bsd.man.mk: maninstall
 #
 
+AWK?=		awk
 OBJCOPY?=	objcopy
 KMODLOAD?=	/sbin/kldload
 KMODUNLOAD?=	/sbin/kldunload
+DEBUG_FLAGS?=	-g
 
 .include <bsd.init.mk>
 
@@ -125,6 +127,9 @@
 .endif
 
 CFLAGS+=	${DEBUG_FLAGS}
+.if ${MACHINE_ARCH} == amd64
+CFLAGS+=	-fno-omit-frame-pointer
+.endif
 
 .include <bsd.patch.mk>
 
@@ -134,8 +139,38 @@
 PROG=	${KMOD}.ko
 .endif
 
-${PROG}: ${KMOD}.kld ${KMODDEPS}
+.if !defined(DEBUG_FLAGS)
+FULLPROG=	${PROG}
+.else
+FULLPROG=	${PROG}.debug
+${PROG}: ${FULLPROG} ${PROG}.symbols
+	${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROG}.symbols\
+	    ${FULLPROG} ${.TARGET}
+${PROG}.symbols: ${FULLPROG}
+	${OBJCOPY} --only-keep-debug ${FULLPROG} ${.TARGET}
+.endif
+
+.if ${MACHINE_ARCH} != amd64
+${FULLPROG}: ${KMOD}.kld ${KMODDEPS}
 	${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld ${KMODDEPS}
+.if !defined(DEBUG_FLAGS)
+	${OBJCOPY} --strip-debug ${.TARGET}
+.endif
+.endif
+
+.if ${MACHINE_ARCH} != amd64
+${KMOD}.kld: ${OBJS}
+.else
+${FULLPROG}: ${OBJS}
+.endif
+	${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
+.if !defined(DEBUG_FLAGS) && ${MACHINE_ARCH} == amd64
+	${OBJCOPY} --strip-debug ${.TARGET}
+.endif
+
+.if defined(DEBUG_FLAGS)
+CLEANFILES+= ${FULLPROG} ${PROG}.symbols
+.endif
 
 .if defined(KMODDEPS)
 .for dep in ${KMODDEPS}
@@ -147,9 +182,6 @@
 .endfor
 .endif
 
-${KMOD}.kld: ${OBJS}
-	${LD} ${LDFLAGS} -r -o ${.TARGET} ${OBJS}
-
 .if !defined(NOMAN)
 .include <bsd.man.mk>
 .endif
@@ -167,13 +199,12 @@
 _ILINKS+=${ARCH}
 .endif
 
-all: objwarn fwheaders ${PROG}
+all: objwarn ${PROG}
 .if !defined(NOMAN)
 all: _manpages
 .endif
 
-beforedepend: fwheaders
-fwheaders: ${_ILINKS} ${FORWARD_HEADERS_COOKIE}
+beforedepend: ${_ILINKS} ${FORWARD_HEADERS_COOKIE}
 # Ensure that the links exist without depending on it when it exists which
 # causes all the modules to be rebuilt when the directory pointed to changes.
 .for _link in ${_ILINKS}


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]