bfd/
[deliverable/binutils-gdb.git] / binutils / objdump.c
index 1e9d97058ba6c8401ed124d5d10781e59717e8fd..1b89fa96489d6d4e2b0c56f269d306baf815f13f 100644 (file)
@@ -1,6 +1,6 @@
 /* objdump.c -- dump information about an object file.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003
+   2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
@@ -153,6 +153,10 @@ static long sorted_symcount = 0;
 /* The dynamic symbol table.  */
 static asymbol **dynsyms;
 
+/* The synthetic symbol table.  */
+static asymbol *synthsyms;
+static long synthcount = 0;
+
 /* Number of symbols in `dynsyms'.  */
 static long dynsymcount = 0;
 
@@ -1775,6 +1779,7 @@ disassemble_data (bfd *abfd)
 {
   struct disassemble_info disasm_info;
   struct objdump_disasm_info aux;
+  long i;
 
   print_files = NULL;
   prev_functionname = NULL;
@@ -1782,10 +1787,18 @@ disassemble_data (bfd *abfd)
 
   /* We make a copy of syms to sort.  We don't want to sort syms
      because that will screw up the relocs.  */
-  sorted_syms = xmalloc (symcount * sizeof (asymbol *));
-  memcpy (sorted_syms, syms, symcount * sizeof (asymbol *));
+  sorted_symcount = symcount ? symcount : dynsymcount;
+  sorted_syms = xmalloc ((sorted_symcount + synthcount) * sizeof (asymbol *));
+  memcpy (sorted_syms, symcount ? syms : dynsyms,
+         sorted_symcount * sizeof (asymbol *));
 
-  sorted_symcount = remove_useless_symbols (sorted_syms, symcount);
+  sorted_symcount = remove_useless_symbols (sorted_syms, sorted_symcount);
+
+  for (i = 0; i < synthcount; ++i)
+    {
+      sorted_syms[sorted_symcount] = synthsyms + i;
+      ++sorted_symcount;
+    }
 
   /* Sort the symbols into section and symbol order.  */
   qsort (sorted_syms, sorted_symcount, sizeof (asymbol *), compare_symbols);
@@ -2545,8 +2558,14 @@ dump_bfd (bfd *abfd)
 
   if (dump_symtab || dump_reloc_info || disassemble || dump_debugging)
     syms = slurp_symtab (abfd);
-  if (dump_dynamic_symtab || dump_dynamic_reloc_info)
+  if (dump_dynamic_symtab || dump_dynamic_reloc_info
+      || (disassemble && bfd_get_dynamic_symtab_upper_bound (abfd) > 0))
     dynsyms = slurp_dynamic_symtab (abfd);
+  if (disassemble && dynsymcount > 0)
+    {
+      synthcount = bfd_get_synthetic_symtab (abfd, dynsyms, &synthsyms);
+      if (synthcount < 0) synthcount = 0;
+    }
 
   if (dump_symtab)
     dump_symbols (abfd, FALSE);
@@ -2591,6 +2610,16 @@ dump_bfd (bfd *abfd)
       free (dynsyms);
       dynsyms = NULL;
     }
+
+  if (synthsyms)
+    {
+      free (synthsyms);
+      synthsyms = NULL;
+    }
+
+  symcount = 0;
+  dynsymcount = 0;
+  synthcount = 0;
 }
 
 static void
This page took 0.026075 seconds and 4 git commands to generate.