2009-08-23 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / bfd / ecofflink.c
index 8a8e146394b025f6b586e8ef1043a56c3506f8cc..072c97a6497d0fbc7f2614d6a7765a68021273b3 100644 (file)
@@ -1,13 +1,13 @@
 /* Routines to link ECOFF debugging information.
-   Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2004
-   Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
+   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "objalloc.h"
@@ -501,8 +502,8 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
   ainfo = (struct accumulate *) bfd_malloc (amt);
   if (!ainfo)
     return NULL;
-  if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
-                              1021))
+  if (!bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
+                             sizeof (struct string_hash_entry), 1021))
     return NULL;
 
   ainfo->line = NULL;
@@ -528,7 +529,8 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
 
   if (! info->relocatable)
     {
-      if (! bfd_hash_table_init (&ainfo->str_hash.table, string_hash_newfunc))
+      if (!bfd_hash_table_init (&ainfo->str_hash.table, string_hash_newfunc,
+                               sizeof (struct string_hash_entry)))
        return NULL;
 
       /* The first entry in the string table is the empty string.  */
@@ -716,7 +718,8 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
          lookup = (char *) bfd_malloc ((bfd_size_type) strlen (name) + 20);
          if (lookup == NULL)
            return FALSE;
-         sprintf (lookup, "%s %lx %lx", name, fdr.csym, fdr.caux);
+         sprintf (lookup, "%s %lx %lx", name, (unsigned long) fdr.csym,
+                  (unsigned long) fdr.caux);
 
          fh = string_hash_lookup (&ainfo->fdr_hash, lookup, TRUE, TRUE);
          free (lookup);
@@ -781,7 +784,6 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
        fdr_ptr += fdr_add, i++)
     {
       FDR fdr;
-      bfd_vma fdr_adr;
       bfd_byte *sym_out;
       bfd_byte *lraw_src;
       bfd_byte *lraw_end;
@@ -798,8 +800,6 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
       else
        (*input_swap->swap_fdr_in) (input_bfd, (PTR) fdr_ptr, &fdr);
 
-      fdr_adr = fdr.adr;
-
       /* FIXME: It is conceivable that this FDR points to the .init or
         .fini section, in which case this will not do the right
         thing.  */
@@ -1338,10 +1338,14 @@ bfd_ecoff_debug_one_external (abfd, debug, swap, name, esym)
                - (char *) debug->external_ext)
       < (symhdr->iextMax + 1) * external_ext_size)
     {
-      if (! ecoff_add_bytes ((char **) &debug->external_ext,
-                            (char **) &debug->external_ext_end,
+      char *external_ext = debug->external_ext;
+      char *external_ext_end = debug->external_ext_end;
+      if (! ecoff_add_bytes ((char **) &external_ext,
+                            (char **) &external_ext_end,
                             (symhdr->iextMax + 1) * (size_t) external_ext_size))
        return FALSE;
+      debug->external_ext = external_ext;
+      debug->external_ext_end = external_ext_end;
     }
 
   esym->asym.iss = symhdr->issExtMax;
@@ -1839,24 +1843,9 @@ mk_fdrtab (abfd, debug_info, debug_swap, line_info)
             addresses do not equal the FDR vma, but they (the PDR address)
             are still vma's and not offsets.  Cf. comments in
             'lookup_line'.  */
-#if 0
-           bfd_size_type external_pdr_size;
-           char *pdr_ptr;
-           PDR pdr;
-           
-           external_pdr_size = debug_swap->external_pdr_size;
-           
-           pdr_ptr = ((char *) debug_info->external_pdr
-                     + fdr_ptr->ipdFirst * external_pdr_size);
-           (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
-         /* The address of the first PDR is the offset of that
-            procedure relative to the beginning of file FDR.  */
-           tab->base_addr = fdr_ptr->adr - pdr.adr;
-#else
          /* The address of the first PDR is the offset of that
             procedure relative to the beginning of file FDR.  */
          tab->base_addr = fdr_ptr->adr; 
-#endif
        }
       else
        {
@@ -2115,11 +2104,6 @@ lookup_line (abfd, debug_info, debug_swap, line_info)
          considerably, which is undesirable.  */
       external_pdr_size = debug_swap->external_pdr_size;
 
-#if 0 /* eraxxon: PDR addresses (pdr.adr) are not relative to FDRs!
-        Leave 'offset' alone.  */
-      /* Make offset relative to object file's start-address.  */
-      offset -= tab[i].base_addr;
-#endif
       /* eraxxon: The Horrible Hack: Because of the problems above, set 'i'
         to 0 so we look through all FDRs.
 
This page took 0.025235 seconds and 4 git commands to generate.