Date: Thu, 21 Oct 2004 01:30:53 +0300 From: Maxim Sobolev <sobomax@portaone.com> To: Scott Long <scottl@FreeBSD.ORG> Cc: freebsd-arch@FreeBSD.ORG Subject: Re: [Fwd: What do people think about not installing a stripped /kernel ?] Message-ID: <4176E71D.9090500@portaone.com> In-Reply-To: <4176E329.9090500@portaone.com> References: <41767CF1.2020005@FreeBSD.org> <20041020.105839.100358845.imp@bsdimp.com> <20041020170907.GA1216@orion.daedalusnetworks.priv> <200410201913.42879.max@love2party.net> <20041020194547.GD2195@ip.net.ua> <4176C0C8.4060408@freebsd.org> <4176E329.9090500@portaone.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Maxim Sobolev wrote: > OK, I've just checked objcopy manpage and found that there is actually a > better way which combines best properties of both approach. In modern > GNU toolchain it is possible to split executable and debugging info into > two separate files, but put a reference into executable, so that you > don't have to worry about how to load debugging symbols: > > --only-keep-debug > Strip a file, removing any sections that would be stripped by > --strip-debug and leaving the debugging sections. > > The intention is that this option will be used in conjunction with > --add-gnu-debuglink to create a two part executable. One a > stripped binary which will occupy less space in RAM and in a dis- > tribution and the second a debugging information file which is only > needed if debugging abilities are required. The suggested proce- > dure to create these files is as follows: > > 1.<Link the executable as normal. Assuming that is is called> > "foo" then... > > 1.<Run "objcopy --only-keep-debug foo foo.dbg" to> > create a file containing the debugging info. > > 1.<Run "objcopy --strip-debug foo" to create a> > stripped executable. > > 1.<Run "objcopy --add-gnu-debuglink=foo.dbg foo"> > to add a link to the debugging info into the stripped exe- > cutable. > > I checked, this works like a charm with our current toolchain/gdb. This > allows us to do the following clever trick WRT kernel debug: > > 1. Compile kernel/modules with debugging symbols; > 2. Split out executable and debugging pieces for each module; > 3. Associate each executable file with appropriate debug file; > 4. Install executable into /boot/kernel as usually; > 5. Install real debugging into /var/something, put symlink to it into > /boot/kernel. > > By the way, this approach can be extended to be an option of buildworld > as well! It can be good way to trade developers' time for some hdd > space, since with this option "on" you will always be able to debug > misbehaving application/library without the need to recompile/reinstall > everything! BTW, it also allows us to do create separate "debug" distribution for release CDs. So that one can do binary install and then add debugging symbols if necessary. -Maxim
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4176E71D.9090500>