Skip to contentSkip to conversation

: __crc_* symbols in System.map

PATCH In review David S. Miller 2 participants 6 messages Aug 12, 2004 – Aug 13, 2004 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : __crc_* symbols in System.map

Shouldn't we be grepping these things out of the System.map file?

For one thing, these can confuse readprofile. It's algorithm is to start at _stext, then stop when it sees a line in the System.map which is not text (mode is one of 'T' 't' 'W' or 'w')

It will exit early if there are some intermixed __crc_* things in there (since they are are mode 'A').

For example, in my current sparc64 kernel I have this:

00000000004cef80 t do_split
00000000004cf2a0 t add_dirent_to_buf
00000000004cf5a7 A __crc_init_special_inode
00000000004cf640 t make_indexed_dir
00000000004cf900 t ext3_add_entry

So no symbols after add_dirent_to_buf will be shown in the profiling output of readprofile.

So we should grep them out, right? If so, here is a patch which implements that.

===== Makefile 1.511 vs edited =====

Makefile +1 -1
@@ -538,7 +538,7 @@
 	echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd
 endef
 
-do_system_map = $(NM) $(1) | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > $(2)
+do_system_map = $(NM) $(1) | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)\|\(__crc_\)' | sort > $(2)
 
 LDFLAGS_vmlinux += -T arch/$(ARCH)/kernel/vmlinux.lds.s
 
#1 lore raw
Quoted 18 lines · David S. Miller

Shouldn't we be grepping these things out of the System.map file?

For one thing, these can confuse readprofile. It's algorithm is to start at _stext, then stop when it sees a line in the System.map which is not text (mode is one of 'T' 't' 'W' or 'w')

It will exit early if there are some intermixed __crc_* things in there (since they are are mode 'A').

For example, in my current sparc64 kernel I have this:

00000000004cef80 t do_split
00000000004cf2a0 t add_dirent_to_buf
00000000004cf5a7 A __crc_init_special_inode
00000000004cf640 t make_indexed_dir
00000000004cf900 t ext3_add_entry

Quoted 5 lines

So no symbols after add_dirent_to_buf will be shown in the profiling output of readprofile.

So we should grep them out, right? If so, here is a patch which implements that.

I have a patch in this area pending, it moves System.map generation out of the top-level makefile. And btw simplifies the expression a bit.

iMy patches are only at linux-sam.bkbits.net/kbuild for now, will post patches later this week.

Would it be an option to skip all 'A' symbols?

Sam

#2 lore raw
Quoted 1 line · On Thu, 12 Aug 2004 07:01:36 +0200 Sam Ravnborg <[email protected]> wrote:

Would it be an option to skip all 'A' symbols?

I doubt it. Symbols defined via the linker script will end up as " A ". On sparc64 this happens for swapper_pmd_dir, empty_pg_dir, _etext, _edata, and _end for example.

#3 lore raw
Quoted 8 lines · David S. Miller
Quoted 1 line · On Thu, 12 Aug 2004 07:01:36 +0200 Sam Ravnborg <[email protected]> wrote:

Would it be an option to skip all 'A' symbols?

I doubt it. Symbols defined via the linker script will end up as " A ". On sparc64 this happens for swapper_pmd_dir, empty_pg_dir, _etext, _edata, and _end for example.

Did a:
nm vmlinux | grep ' A ' | grep -v '__crc_' | wc -l 32

So yep.

Modified your patch to match my tree - patched soon to appear at lkml.

Sam

In my tree I now have a script to generate System.map - that now looks like this:

#!/bin/sh -x
# Based on the vmlinux file create the System.map file # System.map is used by module-init tools and some debugging

# tools to retreive the actual addresses of symbols in the kernel.
#
# Before creating the System.map file as a sideeffect check for
# undefined symbols.
# At least one version of the ARM bin-utils did not error out on
# undefined symbols, so catch them here instead.

# Usage

# mksysmap vmlinux System.map

#####
# Check for undefined symbols.
# Undefined symbols with three leading underscores are ignored since

# they are used by the sparc BTFIXUP logic - and is assumed to be undefined.

if [ "$NM -u $1 | grep -v ' ___'" != "" ]; then

	echo "$1: error: undefined symbol(s) found:"
	$NM -u $1 | grep -v ' ___'
	exit 1

fi

#####
# Generate System.map (actual filename passed as second argument)

# $NM produces the following output:

# f0081e80 T alloc_vfsmnt
#   The second row specify the type of the symbol:
#   A = Absolute
#   B = Uninitialised data (.bss)
#   C = Comon symbol
#   D = Initialised data
#   G = Initialised data for small objects
#   I = Indirect reference to another symbol
#   N = Debugging symbol
#   R = Read only
#   S = Uninitialised data for small objects
#   T = Text code symbol
#   U = Undefined symbol
#   V = Weak symbol
#   W = Weak symbol
#   Corresponding small letters are local symbols

# For System.map filter away:

#   a - local absolute symbols
#   U - undefined global symbols
#   w - local weak symbols
# readprofile starts reading symbols when _stext is found, and
# continue until it finds a symbol which is not either of 'T', 't',
# 'W' or 'w'. __crc_ are 'A' and placed in the middle
# so we just ignore them to let readprofile continue to work.
# (At least sparc64 has __crc_ in the middle).

$NM -n $1 | grep '\( [aUw] \)\|\(__crc_\)' > $2

Quoted 5 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#4 lore raw
Quoted 2 lines · Sam Ravnborg

$NM -n $1 | grep '\( [aUw] \)\|\(__crc_\)' > $2

The missing -v ito grep was just to check if you were awake :-(

Sam

#5 lore raw
Quoted 5 lines · On Fri, 13 Aug 2004 20:10:42 +0200 Sam Ravnborg <[email protected]> wrote:
Quoted 2 lines · Sam Ravnborg

$NM -n $1 | grep '\( [aUw] \)\|\(__crc_\)' > $2

The missing -v ito grep was just to check if you were awake :-(

Final version looks good to me. :-)
Thanks Sam.