bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objdump segfaults on some .o files (OpenBSD sparc64)


From: Nick Clifton
Subject: Re: objdump segfaults on some .o files (OpenBSD sparc64)
Date: 29 Jan 2003 12:52:13 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1

Hi Henric,

> I compiled binutils-2.13.2.1 on OpenBSD with this gcc (from the tip
> of the gcc-3_2-branch):
> 
> ~/src/build/binutils>egcc --version
> egcc (GCC) 3.2.2 20030128 (prerelease)
 
> The resulting objdump *does* segfault.

So when the 2.13.2.1 sources are built using gcc 3.2.2 20030128, the
resulting objdump binary crashes, but when the same sources are built
using the gcc supplied with FreeBSD 5.0, the resulting objdump does
not crash.  Is this correct ?

In which case, this implies a compiler bug, not a binutils bug.

(For what its worth, I just compiled a sparc64 targeted toolchain
under Red Hat 8.0 and the resulting objdump did not crash when I fed
it your busop.o file).

Anyway, I have no real objection to your patch, and it does appear to
fix up a possibly illegal memory read, so I will apply it, slightly
extended as shown below.

Cheers
        Nick

2003-01-29  Henric Jungheim <address@hidden>

        * sparc-dis.c (print_insn_sparc): When examining values added in to
        rs1, make sure that there are previous instructions.

Index: opcodes/sparc-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/sparc-dis.c,v
retrieving revision 1.7
diff -c -3 -p -w -r1.7 sparc-dis.c
*** opcodes/sparc-dis.c 8 Jun 2002 07:29:27 -0000       1.7
--- opcodes/sparc-dis.c 29 Jan 2003 12:48:30 -0000
*************** print_insn_sparc (memaddr, info)
*** 682,707 ****
              unsigned long prev_insn;
              int errcode;
  
              errcode =
                (*info->read_memory_func)
                  (memaddr - 4, buffer, sizeof (buffer), info);
              prev_insn = getword (buffer);
  
              if (errcode == 0)
                {
                  /* If it is a delayed branch, we need to look at the
                     instruction before the delayed branch.  This handles
!                    sequences such as
  
                     sethi %o1, %hi(_foo), %o1
                     call _printf
!                    or %o1, %lo(_foo), %o1
!                    */
  
                  if (is_delayed_branch (prev_insn))
                    {
                      errcode = (*info->read_memory_func)
                        (memaddr - 8, buffer, sizeof (buffer), info);
                      prev_insn = getword (buffer);
                    }
                }
--- 685,717 ----
              unsigned long prev_insn;
              int errcode;
  
+             if (memaddr >= 4)
                errcode =
                  (*info->read_memory_func)
                  (memaddr - 4, buffer, sizeof (buffer), info);
+             else
+               errcode = 1;
+ 
              prev_insn = getword (buffer);
  
              if (errcode == 0)
                {
                  /* If it is a delayed branch, we need to look at the
                     instruction before the delayed branch.  This handles
!                    sequences such as:
  
                     sethi %o1, %hi(_foo), %o1
                     call _printf
!                    or %o1, %lo(_foo), %o1  */
  
                  if (is_delayed_branch (prev_insn))
                    {
+                     if (memaddr >= 8)
                        errcode = (*info->read_memory_func)
                          (memaddr - 8, buffer, sizeof (buffer), info);
+                     else
+                       errcode = 1;
+ 
                      prev_insn = getword (buffer);
                    }
                }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]