From owner-freebsd-chat Sun Dec 31 3:46:17 2000 From owner-freebsd-chat@FreeBSD.ORG Sun Dec 31 03:46:14 2000 Return-Path: Delivered-To: freebsd-chat@freebsd.org Received: from david.siemens.de (david.siemens.de [192.35.17.14]) by hub.freebsd.org (Postfix) with ESMTP id 3B63337B400 for ; Sun, 31 Dec 2000 03:46:13 -0800 (PST) X-Envelope-Sender-Is: andre.albsmeier@mchp.siemens.de (at relayer david.siemens.de) Received: from mail2.siemens.de (mail2.siemens.de [139.25.208.11]) by david.siemens.de (8.11.0/8.11.0) with ESMTP id eBVBjvr25717; Sun, 31 Dec 2000 12:46:01 +0100 (MET) Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.42.7]) by mail2.siemens.de (8.11.0/8.11.0) with ESMTP id eBVBju918445; Sun, 31 Dec 2000 12:45:56 +0100 (MET) Received: (from localhost) by curry.mchp.siemens.de (8.11.1/8.11.1) id eBVBju045506; Date: Sun, 31 Dec 2000 12:45:56 +0100 From: Andre Albsmeier To: Greg Lehey Cc: "G. Adam Stanislav" , chat@FreeBSD.ORG Subject: Re: Removing GNU from kernel Message-ID: <20001231124556.A99615@curry.mchp.siemens.de> References: <20001230122630.A247@whizkidtech.net> <20001231121623.D3496@wantadilla.lemis.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20001231121623.D3496@wantadilla.lemis.com>; from grog@lemis.com on Sun, Dec 31, 2000 at 12:16:23PM +1030 X-Echelon: BND CIA NSA Mossad KGB MI6 IRA detonator nuclear assault strike Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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