having System.map reflect the running kernel

Marty Leisner (leisner@sdsp.mc.xerox.com)
Mon, 28 Aug 1995 10:06:29 PDT

Some applications (lsof? maybe others?) need a system map
file which is an accurate reflection of the running kernel.

I found the following scheme very convenient...
I produce system.map files of form
You can easily comment this out and use
to get the default behavior

I assume boot/arch/i386/zImage and vmlinux are the same kernels if I do
make; make zImage

I then move the map file into /, zip it and have a script which runs out
of rc.local which figures out which map file to unzip and install in

I found it very aggravating to have mismatched maps and kernels

I also made a seperate target to make the map, that can easily be
backed out...(mostly for debugging...)

I also think instead of building vmlinuz and zImage, it may be a good
idea to build vmlinuz.build# and force removal by hand
(or have this be an easily configurable behavior...)

Comments? I'm doing some kernel hacking and I want a little ore

--- Makefile 1995/08/26 20:00:16 1.1
+++ Makefile 1995/08/26 20:00:17
@@ -2,6 +2,8 @@

+BUILD_NUM=$(shell cat .version)
ARCH = i386

@@ -118,13 +120,19 @@
boot: vmlinux
@$(MAKE) -C arch/$(ARCH)/boot

-vmlinux: $(CONFIGURATION) init/main.o init/version.o linuxsubdirs
+vmlinux: $(CONFIGURATION) init/main.o init/version.o linuxsubdirs $(MAP_FILE)
$(LD) $(LINKFLAGS) $(HEAD) init/main.o init/version.o \
$(LIBS) -o vmlinux
- $(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( a \)' | sort > System.map
+map: $(MAP_FILE)
+ifdef MAP_FILE
+ $(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( a \)' | sort > $(MAP_FILE)

rm -f include/asm

getmap script:
#! /bin/bash

version=$(uname -a | cut -f 3 -d ' ')
patch=$(uname -a | cut -f 4 -d ' '| sed 's/\#/build/' )

#echo $version $patch

if [ -e /System.map ]; then
rm /System.map

if [ -e $mapfile ]; then
echo using $mapfile for system map
zcat /$mapfile >/zSystem.map
echo Cannot find $mapfile, no system map

marty leisner@sdsp.mc.xerox.com
Member of the League for Programming Freedom (http://www.lpf.org)
Any sufficiently advanced technology is indistinguishable from magic
Arthur C. Clarke, The Lost Worlds of 2001