public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* dwarf2 and objdump -S --adjust-vma
@ 2001-05-24 12:24 Karsten Keil
  2001-05-28  3:05 ` Nick Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Karsten Keil @ 2001-05-24 12:24 UTC (permalink / raw)
  To: binutils

Hi,

while debuging some x86-64 kernel problem I found a bug in
dwarf and objdump -S --adjust-vma handling.
It's not x86-64 related, following simple testcase shows the bug even on
i386:

Famous c code :-) hello.c:
main() {
printf("hello world\n");
}

cc -gdwarf-2 -c -o hello.o hello.c

objdump -S --adjust-vma 0x0 hello.o works as expected:

hello.o:     file format elf32-i386

Disassembly of section .text:

00000000 <main>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 08                sub    $0x8,%esp
main() {
printf("hello world\n");
   6:   83 c4 f4                add    $0xfffffff4,%esp
   9:   68 00 00 00 00          push   $0x0
   e:   e8 fc ff ff ff          call   f <main+0xf>
  13:   83 c4 10                add    $0x10,%esp
}
  16:   89 ec                   mov    %ebp,%esp
  18:   5d                      pop    %ebp
  19:   c3                      ret
  1a:   8d b6 00 00 00 00       lea    0x0(%esi),%esi

But
objdump -S --adjust-vma 0x10 hello.o
shows the bug:

hello.o:     file format elf32-i386

Disassembly of section .text:

00000010 <main>:
main() {
printf("hello world\n");
  10:   55                      push   %ebp
  11:   89 e5                   mov    %esp,%ebp
  13:   83 ec 08                sub    $0x8,%esp
}
  16:   83 c4 f4                add    $0xfffffff4,%esp
  19:   68 00 00 00 00          push   $0x0
  1e:   e8 fc ff ff ff          call   1f <main+0xf>
  23:   83 c4 10                add    $0x10,%esp
  26:   89 ec                   mov    %ebp,%esp
  28:   5d                      pop    %ebp
  29:   c3                      ret
  2a:   8d b6 00 00 00 00       lea    0x0(%esi),%esi


The source code inserts are shifted with --adjust-vma offset and are gone
away if offset are big.

Tested with binutils CVS two days ago.

-- 
Karsten Keil
SuSE Labs
ISDN development

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dwarf2 and objdump -S --adjust-vma
  2001-05-24 12:24 dwarf2 and objdump -S --adjust-vma Karsten Keil
@ 2001-05-28  3:05 ` Nick Clifton
  2001-05-28  4:55   ` Karsten Keil
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2001-05-28  3:05 UTC (permalink / raw)
  To: Karsten Keil; +Cc: binutils

Hi Karsten,

> while debuging some x86-64 kernel problem I found a bug in
> dwarf and objdump -S --adjust-vma handling.

Thanks for submitting this bug report.  I have applied the patch below
to fix this problem.

Cheers
        Nick

2001-05-28  Nick Clifton  <nickc@cambridge.redhat.com>

	* objdump.c (disassemble_bytes): Remove section VMA adjustment
	when computing the address of the line to show.

Index: objdump.c
===================================================================
RCS file: /cvs/cvsfiles/devo/binutils/objdump.c,v
retrieving revision 1.224
diff -p -r1.224 objdump.c
*** objdump.c	2001/03/15 04:23:19	1.224
--- objdump.c	2001/05/28 10:05:05
*************** disassemble_bytes (info, disassemble_fn,
*** 1328,1334 ****
  	  done_dot = false;
  
  	  if (with_line_numbers || with_source_code)
! 	    show_line (aux->abfd, section, addr_offset);
  
  	  if (! prefix_addresses)
  	    {
--- 1328,1337 ----
  	  done_dot = false;
  
  	  if (with_line_numbers || with_source_code)
! 	    /* The line number tables will refer to unadjusted
! 	       section VMAs, so we must undo any VMA modifications
! 	       when calling show_line.  */
! 	    show_line (aux->abfd, section, addr_offset - adjust_section_vma);
  
  	  if (! prefix_addresses)
  	    {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dwarf2 and objdump -S --adjust-vma
  2001-05-28  3:05 ` Nick Clifton
@ 2001-05-28  4:55   ` Karsten Keil
  0 siblings, 0 replies; 3+ messages in thread
From: Karsten Keil @ 2001-05-28  4:55 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Hi Nick,

On Mon, May 28, 2001 at 12:04:31PM +0100, Nick Clifton wrote:
> Hi Karsten,
> 
> > while debuging some x86-64 kernel problem I found a bug in
> > dwarf and objdump -S --adjust-vma handling.
> 
> Thanks for submitting this bug report.  I have applied the patch below
> to fix this problem.
> 
> Cheers
>         Nick
> 
> 2001-05-28  Nick Clifton  <nickc@cambridge.redhat.com>
> 
> 	* objdump.c (disassemble_bytes): Remove section VMA adjustment
> 	when computing the address of the line to show.
> 

It seems to be the right solution, but:

I'm afraid that this break the stabs (and maybe other) cases, seems here is
a workaround on a other place.

While looking at the problem by myself, I found that the 
_bfd_stab_section_find_nearest_line correct the offset by itself.

Since I don't know enought about dwarf, stabs bfd, I didn't find 
a solution which don't break things.

-- 
Karsten Keil
SuSE Labs
ISDN development

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-05-28  4:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-24 12:24 dwarf2 and objdump -S --adjust-vma Karsten Keil
2001-05-28  3:05 ` Nick Clifton
2001-05-28  4:55   ` Karsten Keil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).