System.map and .config in zImage (was Re: A couple "normal user" questions.. (fwd))

Ion Badulescu (ionut@moisil.wal.rhno.columbia.edu)
Sat, 1 Feb 1997 01:54:23 -0500 (EST)


On Fri, 31 Jan 1997, Jim Nance wrote:

> How about slipping a compressed copy of System.map and .Config into the
> compressed kernel image, but not do anything with them at boot time.
> This way they do not take up any kernel space, but you could still extract
> they with some sort of utility if you wanted to.

Just appending them to zImage seems to be fine with lilo, I assume loadlin
won't have problems either. This way they don't get loaded at boot time,
and a script can extract them from zImage easily; the script could be
called from the rc.* scripts to generate System.map on the fly.

The size of zImage increases by 25-30k, which is no big deal.

See the attached patched for a (working) example, and feel free to improve
upon it. :-)

Ionut

--
  It is better to keep your mouth shut and be thought a fool,
            than to open it and remove all doubt.

--- linux-2.1.24/arch/i386/boot/Makefile.old Sat Feb 1 01:47:41 1997 +++ linux-2.1.24/arch/i386/boot/Makefile Sat Feb 1 01:40:34 1997 @@ -21,6 +21,8 @@ $(OBJCOPY) compressed/vmlinux compressed/vmlinux.out; \ fi tools/build bootsect setup compressed/vmlinux.out $(ROOT_DEV) > zImage + (echo -e '\n-- start .config file --'; gzip -c $(TOPDIR)/.config) >> zImage + (echo -e '\n-- start System.map file --'; gzip -c $(TOPDIR)/System.map) >> zImage sync bzImage: $(CONFIGURE) bbootsect setup compressed/bvmlinux tools/bbuild @@ -30,6 +32,8 @@ $(OBJCOPY) compressed/bvmlinux compressed/bvmlinux.out; \ fi tools/bbuild bbootsect setup compressed/bvmlinux.out $(ROOT_DEV) > bzImage + (echo -e '\n-- start .config file --'; gzip -c $(TOPDIR)/.config) >> bzImage + (echo -e '\n-- start System.map file --'; gzip -c $(TOPDIR)/System.map) >> bzImage sync compressed/vmlinux: $(TOPDIR)/vmlinux --- linux-2.1.24/scripts/analyse_kernel.pl.old Sat Feb 1 01:48:11 1997 +++ linux-2.1.24/scripts/analyse_kernel.pl Sat Feb 1 01:46:17 1997 @@ -0,0 +1,18 @@ +#!/usr/bin/perl +if ($#ARGV == -1) { + die "Usage: $0 <compressed-kernel-file>\n"; +} +open(ZIMAGE, "<$ARGV[0]") || die "Cannot open kernel file $ARGV[0].\n"; +open(OUTPUT, ">/dev/null"); +while (<ZIMAGE>) { + if (m|^-- start .config file --$|) { + close OUTPUT; + open(OUTPUT, "|gzip -cd >.config 2>/dev/null") || die "Cannot create .config\n"; + } elsif (m|^-- start System.map file --$|) { + close OUTPUT; + open(OUTPUT, "|gzip -cd >System.map 2>/dev/null") || die "Cannot create System.map\n"; + } else { + print OUTPUT $_; + } +} +close OUTPUT;