Posts Tagged ‘symbols’

Identifying Symbols

Posted: June 24, 2008 in Tools
Tags: , , ,

These symbols are as esoteric to me as they might be for many of you. But
it’s just an image to decorate the context below!

The Symbol I am going to talk about is related to Symbols of objects. This
is a very less documented topic, so just digging about it in any search engine
didn’t help much.

I remember I had asked about it to Ramkrsna and Ashok couple of months
back who have a good knowledge about Linux System as a whole. They
helped me in some way which had given me some basic idea about it until
I found an article to read about compiling Linux kernel.

So in short, a symbol can be a variable name or function name. You an
simple try using “nm” command in an Unix system to list the symbol of any
object file.

So when you try running a simple C file it generally creates an object file called
a.out in the same directory.

If you want to name the file something else you can just try executing this

cc -o file.o file.c

The above line will create an object file with the name file.o. So to list the symbol
of these files just execute the command below:

nm file.o

It will give some output like this:
08049618 W data_start
08048360 t frame_dummy
08048384 T main
0804961c d p.5756
U printf@@GLIBC_2.0
U scanf@@GLIBC_2.0

Where the 1st column gives the address of the symbol, 2nd column gives the
type of the symbol and the 3rd tells the name of the symbol. In the last two lines
you can note that “printf” and “scanf” are being extracted from GLIBC and these
are Undefined symbols.

Kernel generally refers to a symbol by it’s address. So the kernel symbol table is
nothing but a mapping of symbol names with their addresses.