For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > March 2006 > help with nm tool









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author help with nm tool
jeniffer

2006-03-22, 4:01 am

Problem 1:
I am trying nm with object files and i get gcc2_compiled. in the
third column in many files
its like :
nm -r objfile :
..
..
..
00000000 t gcc2_compiled.
...
..
(although thr is no gcc2_compiled. func in the source file)

i also get entries like :

00000080 t .label.0.00002.00000.00001

with these exceptions i am getting all the undefined and defined
functions when i grep T or t or U


Problem 2:
although functions are say A ,B ,C , in the nm ouput with -r option
(and in other options also) i get an _ before the function name ..as in
_A,_B,_C .Why this comes with some C files ?And how do i differentiate
if a func is of the form _A in the source C file versus A in the source
file?

Icarus Sparry

2006-03-22, 4:01 am

On Tue, 21 Mar 2006 21:00:49 -0800, jeniffer wrote:

> Problem 1:
> I am trying nm with object files and i get gcc2_compiled. in the
> third column in many files
> its like :
> nm -r objfile :
> .
> .
> .
> 00000000 t gcc2_compiled.
> ..
> .
> (although thr is no gcc2_compiled. func in the source file)


The wonders of the GNU compilers, they add extra things for you.
This particular one is to tell gdb that the code was compiled with
a version 2 version of gcc. Later versions of gcc do this differently.

> i also get entries like :
>
> 00000080 t .label.0.00002.00000.00001
>
> with these exceptions i am getting all the undefined and defined
> functions when i grep T or t or U
>
>
> Problem 2:
> although functions are say A ,B ,C , in the nm ouput with -r option
> (and in other options also) i get an _ before the function name ..as in
> _A,_B,_C .Why this comes with some C files ?And how do i differentiate
> if a func is of the form _A in the source C file versus A in the source
> file?


This is a common practice with C compilers, you need to have some global
symbols and do not want them to conflict with anything user written. An
easy way to do this is to prepend a character to all user written symbols,
and don't do this for the things you care about. You should find that if you
name your function "_A", then it will come out as "__A". This is not
the only way of doing this, it would help if you told us what version of
gcc you were using, and for what processor.

jeniffer

2006-03-22, 4:01 am

I am using gcc version 3.4.2 ...how to find out for what processor?

jeniffer

2006-03-22, 4:01 am

should i just remove _ if it appears as the first symbol in the nm
output in order to get the correct function names??

Icarus Sparry

2006-03-22, 4:01 am

On Tue, 21 Mar 2006 22:16:11 -0800, jeniffer wrote:

> should i just remove _ if it appears as the first symbol in the nm
> output in order to get the correct function names??


You should probably ignore any symbols which do not start with '_', and
for those which do remove the first '_'.

In your other posting you ask how you can tell for which processor you are
compiling, the "best" answer may be to run "gcc --target-options", but a
simpler athing is to ask what kind of machine are you running on, e.g. a
sun, a pc, a mac...

Please include context when following up a post. Please read
<http://cfaj.freeshell.org/google> for guidelines on how to post
from Google Groups.


Bill Marcum

2006-03-22, 7:03 pm

["Followup-To:" header set to comp.unix.shell.]
On 21 Mar 2006 21:52:10 -0800, jeniffer
<zenith.of.perfection@gmail.com> wrote:
> I am using gcc version 3.4.2 ...how to find out for what processor?
>

If you don't know it's probably some sort of x86.

gcc -dumpmachine


--
To give happiness is to deserve happiness.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com