Import config.guess and config.sub.
[deliverable/binutils-gdb.git] / bfd / xcofflink.c
index b817426ae68205dd91841ae6f8cbe78782854cd6..a869d7d3d6d9838c44a7f85bf7c9e6122a4586c0 100644 (file)
@@ -482,12 +482,12 @@ _bfd_xcoff_bfd_link_hash_table_create (abfd)
   struct xcoff_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct xcoff_link_hash_table);
 
-  ret = (struct xcoff_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct xcoff_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct xcoff_link_hash_table *) NULL)
     return (struct bfd_link_hash_table *) NULL;
   if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc))
     {
-      bfd_release (abfd, ret);
+      free (ret);
       return (struct bfd_link_hash_table *) NULL;
     }
 
@@ -513,6 +513,18 @@ _bfd_xcoff_bfd_link_hash_table_create (abfd)
   return &ret->root;
 }
 
+/* Free a XCOFF link hash table.  */
+
+void
+_bfd_xcoff_bfd_link_hash_table_free (hash)
+     struct bfd_link_hash_table *hash;
+{
+  struct xcoff_link_hash_table *ret = (struct xcoff_link_hash_table *) hash;
+
+  _bfd_stringtab_free (ret->debug_strtab);
+  bfd_hash_table_free (&ret->root.table);
+  free (ret);
+}
 \f
 /* Read internal relocs for an XCOFF csect.  This is a wrapper around
    _bfd_coff_read_internal_relocs which tries to take advantage of any
@@ -588,11 +600,11 @@ _bfd_xcoff_bfd_link_add_symbols (abfd, info)
 
     case bfd_archive:
       /* If the archive has a map, do the usual search.  We then need
-         to check the archive for stripped dynamic objects, because
-         they will not appear in the archive map even though they
-         should, perhaps, be included.  If the archive has no map, we
-         just consider each object file in turn, since that apparently
-         is what the AIX native linker does.  */
+         to check the archive for dynamic objects, because they may not 
+        appear in the archive map even though they should, perhaps, be 
+        included.  If the archive has no map, we just consider each object 
+        file in turn, since that apparently is what the AIX native linker 
+        does.  */
       if (bfd_has_map (abfd))
        {
          if (! (_bfd_generic_link_add_archive_symbols
@@ -602,18 +614,18 @@ _bfd_xcoff_bfd_link_add_symbols (abfd, info)
 
       {
        bfd *member;
-
+       
        member = bfd_openr_next_archived_file (abfd, (bfd *) NULL);
        while (member != NULL)
          {
            if (bfd_check_format (member, bfd_object)
-               && (! bfd_has_map (abfd)
-                   || ((member->flags & DYNAMIC) != 0
-                       && (member->flags & HAS_SYMS) == 0)))
+               && (info->hash->creator == member->xvec)
+               && (! bfd_has_map (abfd) || (member->flags & DYNAMIC) != 0))
              {
                boolean needed;
-
-               if (! xcoff_link_check_archive_element (member, info, &needed))
+               
+               if (! xcoff_link_check_archive_element (member, info, 
+                                                       &needed))
                  return false;
                if (needed)
                  member->archive_pass = -1;
@@ -1074,21 +1086,19 @@ xcoff_link_add_symbols (abfd, info)
   /* We keep a list of the linker hash table entries that correspond
      to each external symbol.  */
   amt = symcount * sizeof (struct xcoff_link_hash_entry *);
-  sym_hash = (struct xcoff_link_hash_entry **) bfd_alloc (abfd, amt);
+  sym_hash = (struct xcoff_link_hash_entry **) bfd_zalloc (abfd, amt);
   if (sym_hash == NULL && symcount != 0)
     goto error_return;
   coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash;
-  memset (sym_hash, 0, (size_t) amt);
 
   /* Because of the weird stuff we are doing with XCOFF csects, we can
      not easily determine which section a symbol is in, so we store
      the information in the tdata for the input file.  */
   amt = symcount * sizeof (asection *);
-  csect_cache = (asection **) bfd_alloc (abfd, amt);
+  csect_cache = (asection **) bfd_zalloc (abfd, amt);
   if (csect_cache == NULL && symcount != 0)
     goto error_return;
   xcoff_data (abfd)->csects = csect_cache;
-  memset (csect_cache, 0, (size_t) amt);
 
   /* While splitting sections into csects, we need to assign the
      relocs correctly.  The relocs and the csects must both be in
@@ -1097,10 +1107,9 @@ xcoff_link_add_symbols (abfd, info)
      into reloc_info using the section target_index.  */
   amt = abfd->section_count + 1;
   amt *= sizeof (struct reloc_info_struct);
-  reloc_info = (struct reloc_info_struct *) bfd_malloc (amt);
+  reloc_info = (struct reloc_info_struct *) bfd_zmalloc (amt);
   if (reloc_info == NULL)
     goto error_return;
-  memset ((PTR) reloc_info, 0, (size_t) amt);
 
   /* Read in the relocs and line numbers for each section.  */
   linesz = bfd_coff_linesz (abfd);
@@ -1117,11 +1126,9 @@ xcoff_link_add_symbols (abfd, info)
                                        false, (struct internal_reloc *) NULL);
          amt = o->reloc_count;
          amt *= sizeof (asection *);
-         reloc_info[o->target_index].csects = (asection **) bfd_malloc (amt);
+         reloc_info[o->target_index].csects = (asection **) bfd_zmalloc (amt);
          if (reloc_info[o->target_index].csects == NULL)
            goto error_return;
-         memset (reloc_info[o->target_index].csects, 0, (size_t) amt);
-
        }
 
       if ((info->strip == strip_none || info->strip == strip_some)
@@ -1766,12 +1773,19 @@ xcoff_link_add_symbols (abfd, info)
          if (info->hash->creator == abfd->xvec)
            {
              if (! bfd_is_und_section (section))
-               *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info),
-                                                   name, true, copy, false);
+               {
+                 *sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info),
+                                                     name, true, copy, false);
+               }
              else
-               *sym_hash = ((struct xcoff_link_hash_entry *)
-                            bfd_wrapped_link_hash_lookup (abfd, info, name,
-                                                          true, copy, false));
+               {
+                 /* Make a copy of the symbol name to prevent problems with
+                    merging symbols.  */
+                 *sym_hash = ((struct xcoff_link_hash_entry *)
+                              bfd_wrapped_link_hash_lookup (abfd, info, name,
+                                                            true, true, 
+                                                            false));
+               }
              if (*sym_hash == NULL)
                goto error_return;
              if (((*sym_hash)->root.type == bfd_link_hash_defined
@@ -2109,7 +2123,7 @@ xcoff_link_add_dynamic_symbols (abfd, info)
 
   /* Remove the sections from this object, so that they do not get
      included in the link.  */
-  abfd->sections = NULL;
+  bfd_section_list_clear (abfd);
 
   bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr);
 
@@ -2864,7 +2878,7 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry,
     }
 
   /* __rtinit */
-  if (info->init_function || info->fini_function || rtld == true
+  if (info->init_function || info->fini_function || rtld) 
     {
       struct xcoff_link_hash_entry *hsym;
       struct internal_ldsym *ldsym;
@@ -3253,6 +3267,9 @@ xcoff_build_ldsyms (h, p)
   struct xcoff_loader_info *ldinfo = (struct xcoff_loader_info *) p;
   bfd_size_type amt;
 
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct xcoff_link_hash_entry *) h->root.u.i.link;
+
   /* __rtinit, this symbol has special handling. */
   if (h->flags & XCOFF_RTINIT)
       return true;
@@ -5374,6 +5391,13 @@ xcoff_write_global_symbol (h, inf)
   output_bfd = finfo->output_bfd;
   outsym = finfo->outsyms;
 
+  if (h->root.type == bfd_link_hash_warning)
+    {
+      h = (struct xcoff_link_hash_entry *) h->root.u.i.link;
+      if (h->root.type == bfd_link_hash_new)
+       return true;
+    }
+
   /* If this symbol was garbage collected, just skip it.  */
   if (xcoff_hash_table (finfo->info)->gc
       && (h->flags & XCOFF_MARK) == 0)
@@ -5863,7 +5887,10 @@ xcoff_write_global_symbol (h, inf)
       isym.n_value = (h->root.u.def.section->output_section->vma
                      + h->root.u.def.section->output_offset
                      + h->root.u.def.value);
-      isym.n_scnum = h->root.u.def.section->output_section->target_index;
+      if (bfd_is_abs_section (h->root.u.def.section->output_section))
+       isym.n_scnum = N_ABS;
+      else
+       isym.n_scnum = h->root.u.def.section->output_section->target_index;
       isym.n_sclass = C_HIDEXT;
       aux.x_csect.x_smtyp = XTY_SD;
 
This page took 0.026974 seconds and 4 git commands to generate.