Subject: Add NO_RCSID option?
To: None <tech-kern@netbsd.org>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-kern
Date: 04/28/2005 12:58:07
Sometimes it's required to build kernel as small as possibly. For example, for 
embedded devices etc. In this case, every 10k of data can be valuable. On the 
other hand, production embedded device rarely needs fully idented executable 
files (sometimes it's even very undesirable).

Proposal: why not to add config(9) option like NO_RCSID? The goal of this 
option is to remove $NetBSD& ident strings from binary kernel file. The 
following patch below does this.

For NetBSD-current GENERIC v1.668 i got the following numbers:

$ ls -l
total 31344
-rwxr-xr-x  1 ianzag  wheel  7973414 Apr 28 12:44 netbsd.new
-rwxr-xr-x  1 ianzag  wheel  8045658 Apr 28 12:32 netbsd.orig

where new/orig are kernels with/without defined "options NO_RCSID" in kernel 
config file. We saved 72kb :) Well, for the most of cases this is not 
important at all, but who knows. If we can cut 50k here, 50k there and so on, 
resulting kernel size can be significantly smaller.

---cut---
Index: cdefs_aout.h
===================================================================
RCS file: /cvsroot/src/sys/sys/cdefs_aout.h,v
retrieving revision 1.15
diff -u -r1.15 cdefs_aout.h
--- cdefs_aout.h	7 Jun 2004 18:42:18 -0000	1.15
+++ cdefs_aout.h	28 Apr 2005 05:19:22 -0000
@@ -59,7 +59,12 @@
 
 #undef __KERNEL_RCSID
 
+#ifdef NO_RCSID
+#define	__RCSID(_s)
+#else
 #define	__RCSID(_s)	__IDSTRING(rcsid,_s)
+#endif /* !NO_RCSID */
+
 #define	__SCCSID(_s)
 #define	__SCCSID2(_s)
 #if 0	/* XXX userland __COPYRIGHTs have \ns in them */
Index: cdefs_elf.h
===================================================================
RCS file: /cvsroot/src/sys/sys/cdefs_elf.h,v
retrieving revision 1.22
diff -u -r1.22 cdefs_elf.h
--- cdefs_elf.h	26 Feb 2005 22:25:34 -0000	1.22
+++ cdefs_elf.h	28 Apr 2005 05:19:22 -0000
@@ -97,7 +97,12 @@
 
 #define	__IDSTRING(_n,_s)		__SECTIONSTRING(.ident,_s)
 
+#ifdef NO_RCSID
+#define	__RCSID(_s)
+#else
 #define	__RCSID(_s)			__IDSTRING(rcsid,_s)
+#endif /* !NO_RCSID */
+
 #define	__SCCSID(_s)
 #define __SCCSID2(_s)
 #if 0	/* XXX userland __COPYRIGHTs have \ns in them */
---cut---

// wbr