Bug 2338 - objdump -d -l doesn't work correctly
Summary: objdump -d -l doesn't work correctly
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-14 17:32 UTC by H.J. Lu
Modified: 2006-03-30 03:06 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2006-02-14 17:32:29 UTC
"objdump -d -l -j .text" may give wrong function name when
__attribute__((section)) is used:

[hjl@gnu-13 objdump]$ cat x.c
static void bar ()
{
}
__attribute__((section(".init.text"), noinline))
static void foo ()
{
}
[hjl@gnu-13 objdump]$ make
gcc -g   -c -o x.o x.c
objdump -d -r -l -j .text x.o

x.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <bar>:
foo():
/export/home/hjl/bugs/binutils/objdump/x.c:2
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   c9                      leaveq
   5:   c3                      retq
[hjl@gnu-13 objdump]$
Comment 1 H.J. Lu 2006-02-14 19:30:30 UTC
A patch is posted at

http://sourceware.org/ml/binutils/2006-02/msg00169.html
Comment 2 Chuck Ebbert 2006-02-19 10:59:47 UTC
The posted patch almost works.  Instead of returning the wrong
line number info, it now returns no info much of the time. :(

BTW an easier test is to do 'objdump -d -S mm/vmscan.o' and see if the
source listing is OK.
Comment 3 H.J. Lu 2006-02-19 19:49:36 UTC
I think it may be a compiler bug. Please upload your mm/vmscan.o if
"objdump -d -S" doesn't work.
Comment 4 H.J. Lu 2006-02-19 20:16:53 UTC
The gcc bug is

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26364
Comment 5 H.J. Lu 2006-02-22 18:14:41 UTC
This patch

http://sourceware.org/ml/binutils/2006-02/msg00295.html

should work much better.
Comment 6 Ben Elliston 2006-03-30 03:06:41 UTC
Fixed with this patch (and verified):

2006-03-05  H.J. Lu  <hongjiu.lu@intel.com>
            Alan Modra  <amodra@bigpond.net.au>

        PR binutils/2338
        * dwarf2.c (loadable_section): New struct.
        (dwarf2_debug): Add loadable_section_count and
        loadable_sections.
        (new_line_sorts_after): New.
        (add_line_info): Use new_line_sorts_after to compare line
        addresses.
        (check_function_name): Removed.
        (unset_sections): New.
        (place_sections): New.
        (_bfd_dwarf2_find_nearest_line): Updated. Call place_sections
        and unset_sections on relocatable files.
        (_bfd_dwarf2_find_line): Likewise.