[PATCH] Robustify objdump -dr and -r

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Robustify objdump -dr and -r

Jakub Jelinek
Hi!

Both objdump -r and objdump -dr segfault when seeing unknown relocations
(noticed while mistakenly running system objdump on a -msecure-plt created
object on ppc32).
Ok to commit?

2005-06-06  Jakub Jelinek  <[hidden email]>

        * objdump.c (disassemble_bytes): Don't crash if q->howto == NULL.
        If q->howto->name == NULL, print q->howto->type as number instead.
        (dump_reloc_set): Likewise.

--- binutils/objdump.c.jj 2005-05-13 23:44:24.000000000 +0200
+++ binutils/objdump.c 2005-06-06 14:20:48.000000000 +0200
@@ -1570,7 +1570,12 @@ disassemble_bytes (struct disassemble_in
       objdump_print_value (section->vma - rel_offset + q->address,
    info, TRUE);
 
-      printf (": %s\t", q->howto->name);
+      if (q->howto == NULL)
+ printf (": *unknown*\t");
+      else if (q->howto->name)
+ printf (": %s\t", q->howto->name);
+      else
+ printf (": %d\t", q->howto->type);
 
       if (q->sym_ptr_ptr == NULL || *q->sym_ptr_ptr == NULL)
  printf ("*unknown*");
@@ -2465,23 +2470,20 @@ dump_reloc_set (bfd *abfd, asection *sec
   section_name = NULL;
  }
 
+      bfd_printf_vma (abfd, q->address);
+      if (q->howto == NULL)
+ printf (" *unknown*         ");
+      else if (q->howto->name)
+ printf (" %-16s  ", q->howto->name);
+      else
+ printf (" %-16d  ", q->howto->type);
       if (sym_name)
- {
-  bfd_printf_vma (abfd, q->address);
-  if (q->howto->name)
-    printf (" %-16s  ", q->howto->name);
-  else
-    printf (" %-16d  ", q->howto->type);
-  objdump_print_symname (abfd, NULL, *q->sym_ptr_ptr);
- }
+ objdump_print_symname (abfd, NULL, *q->sym_ptr_ptr);
       else
  {
   if (section_name == NULL)
     section_name = "*unknown*";
-  bfd_printf_vma (abfd, q->address);
-  printf (" %-16s  [%s]",
-  q->howto->name,
-  section_name);
+  printf ("[%s]", section_name);
  }
 
       if (q->addend)

        Jakub
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Robustify objdump -dr and -r

Alan Modra
On Mon, Jun 06, 2005 at 02:27:59PM +0200, Jakub Jelinek wrote:

> Hi!
>
> Both objdump -r and objdump -dr segfault when seeing unknown relocations
> (noticed while mistakenly running system objdump on a -msecure-plt created
> object on ppc32).
> Ok to commit?
>
> 2005-06-06  Jakub Jelinek  <[hidden email]>
>
> * objdump.c (disassemble_bytes): Don't crash if q->howto == NULL.
> If q->howto->name == NULL, print q->howto->type as number instead.
> (dump_reloc_set): Likewise.

OK.

--
Alan Modra
IBM OzLabs - Linux Technology Centre