This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: objdump -S with C++ code
- From: Efraim Yawitz <efraim dot yawitz at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 21 Apr 2009 16:51:21 +0200
- Subject: Re: objdump -S with C++ code
- References: <716cf4cb0904200852vd76a7calff2aa10b3e050de0@mail.gmail.com> <49ECB030.4040506@gmail.com> <716cf4cb0904210043r5240d0b8tfb15d8557ebf1150@mail.gmail.com>
Since I didn't get any response yet about objdump -S, I decided to try
compiling a debug version of objdump and watching what was happening
in gdb, and I think I see what the problem is.
In the function skip_to_line(), which is where the printing of the
code takes place, there is a test:
while (p->line < line)
p->line gets incremented every time a line of code is printed out, and
the next time a line of code is hit, we test if the line we are on is
after all the code that was printed. This assumes that the functions
in the object file are in the same order that they were in in the
source file. Using nm -l -n, I can see that this seems to be true for
object files produced by gcc from .c files, but not for those produced
by g++ from .cpp files. I don't know what the order is, but it isn't
the order from the source file. Maybe there is some option for g++ to
change this, but I don't know.