Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Dec 2000 12:45:56 +0100
From:      Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
To:        Greg Lehey <grog@lemis.com>
Cc:        "G. Adam Stanislav" <adam@whizkidtech.net>, chat@FreeBSD.ORG
Subject:   Re: Removing GNU from kernel
Message-ID:  <20001231124556.A99615@curry.mchp.siemens.de>
In-Reply-To: <20001231121623.D3496@wantadilla.lemis.com>; from grog@lemis.com on Sun, Dec 31, 2000 at 12:16:23PM %2B1030
References:  <20001230122630.A247@whizkidtech.net> <20001231121623.D3496@wantadilla.lemis.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 31-Dec-2000 at 12:16:23 +1030, Greg Lehey wrote:
> On Saturday, 30 December 2000 at 12:26:30 -0600, G. Adam Stanislav wrote:
> > Several weeks ago, I mentioned how I built my own kernel for the first
> > time, and how happy I was with the result.
> >
> > Still, I noticed the string "GCC: (GNU) 2.7.2.1" appearing in my kernel
> > several hundred times. I decided to try to get rid of it. As root, I typed:
> >
> >  # strip -R .comment kernel
> >
> > Sure enough, my kernel was reduced from 1,225,217 bytes to 994,864 bytes.
> > The GNU strings are gone. The kernel still boots just as before.
> 
> This is puzzling for a number of reasons.  First, the kernel is very
> small by modern standards, even before the stripping.  I've just
> checked my last 3.x kernel, and I find:
> 
> -rwxr-xr-x  1 grog  lemis  9954685 Jun  8  2000 kernel.debug
> -rwxr-xr-x  1 root  lemis  1778344 Dec 31 12:13 kernel
> -rwxr-xr-x  1 root  lemis  1770936 Dec 31 12:13 kernel.stripped
> 
> The file kernel is kernel.debug stripped normally.  And yes, it has a
> few lines of the form GCC: (GNU) 2.7.2.3 in it.  The third file is the
> result of stripping the comments; I saved rather over 7 kB.
> Definitely worth doing, so much in fact that we have already done it.
> Here's the some thing on a 5.x kernel; 4.x looks the same:
> 
>   $ strings -a kernel.debug | grep GNU
>   $

What does a 

strings -a kernel.debug | grep GCC

say? I get here (on 4.2):

$ strings -a kernel.debug | grep GCC | head
[ASM_FILE_END]GCC: (c) 2.95.2 19991024 (release)
[ASM_FILE_END]GCC: (c) 2.95.2 19991024 (release)
[ASM_FILE_END]GCC: (c) 2.95.2 19991024 (release)
[ASM_FILE_END]GCC: (c) 2.95.2 19991024 (release)
[ASM_FILE_END]GCC: (c) 2.95.2 19991024 (release)
[ASM_FILE_END]GCC: (c) 2.95.2 19991024 (release)
[ASM_FILE_END]GCC: (c) 2.95.2 19991024 (release)
[ASM_FILE_END]GCC: (c) 2.95.2 19991024 (release)
[ASM_FILE_END]GCC: (c) 2.95.2 19991024 (release)
[ASM_FILE_END]GCC: (c) 2.95.2 19991024 (release)
$

And I can do:

$ strings -a kernel.debug | grep GCC | wc
     381    1905   18669
$


Some thoughts:

$ rm kernel
$ make
objcopy --strip-debug kernel.debug kernel
$ ls -l kernel*
-rwxr-xr-x  1 root  wheel  2218267 Dec 31 12:40 kernel
-rwxr-xr-x  1 root  wheel  8499829 Dec 31 11:33 kernel.debug
$ objcopy --strip-debug -R .comment kernel.debug kernel
$ ls -l kernel*                                        
-rwxr-xr-x  1 root  wheel  2199151 Dec 31 12:41 kernel
-rwxr-xr-x  1 root  wheel  8499829 Dec 31 11:33 kernel.debug
$ strings -a kernel | grep GCC
$


	-Andre


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001231124556.A99615>