debug_contents = (bfd_byte *) malloc (subdeb->_raw_size);
debug_contents = (bfd_byte *) bfd_malloc (subdeb->_raw_size);
bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry,				 file_align, maxstack, maxdata, gc,				 modtype, textro, special_sections)     bfd *output_bfd;     struct bfd_link_info *info;     const char *libpath;     const char *entry;     unsigned long file_align;     unsigned long maxstack;     unsigned long maxdata;     boolean gc;     int modtype;     boolean textro;     asection **special_sections;{  struct xcoff_link_hash_entry *hentry;  asection *lsec;  struct xcoff_loader_info ldinfo;  int i;  size_t impsize, impcount;  struct xcoff_import_file *fl;  struct internal_ldhdr *ldhdr;  bfd_size_type stoff;  register char *out;  asection *sec;  bfd *sub;  struct bfd_strtab_hash *debug_strtab;  bfd_byte *debug_contents = NULL;  if (! XCOFF_XVECP (output_bfd->xvec))    return true;  ldinfo.failed = false;  ldinfo.output_bfd = output_bfd;  ldinfo.info = info;  ldinfo.ldsym_count = 0;  ldinfo.string_size = 0;  ldinfo.strings = NULL;  ldinfo.string_alc = 0;  xcoff_data (output_bfd)->maxstack = maxstack;  xcoff_data (output_bfd)->maxdata = maxdata;  xcoff_data (output_bfd)->modtype = modtype;  xcoff_hash_table (info)->file_align = file_align;  xcoff_hash_table (info)->textro = textro;  hentry = xcoff_link_hash_lookup (xcoff_hash_table (info), entry,				   false, false, true);  if (hentry != NULL)    {      hentry->flags |= XCOFF_ENTRY;      if (hentry->root.type == bfd_link_hash_defined	  || hentry->root.type == bfd_link_hash_defweak)	xcoff_data (output_bfd)->entry_section =	  hentry->root.u.def.section->output_section;    }  /* Garbage collect unused sections.  */  if (info->relocateable      || ! gc      || hentry == NULL      || (hentry->root.type != bfd_link_hash_defined	  && hentry->root.type != bfd_link_hash_defweak))    {      gc = false;      xcoff_hash_table (info)->gc = false;      /* We still need to call xcoff_mark, in order to set ldrel_count         correctly.  */      for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)	{	  asection *o;	  for (o = sub->sections; o != NULL; o = o->next)	    {	      if ((o->flags & SEC_MARK) == 0)		{		  if (! xcoff_mark (info, o))		    goto error_return;		}	    }	}    }  else    {      if (! xcoff_mark (info, hentry->root.u.def.section))	goto error_return;      xcoff_sweep (info);      xcoff_hash_table (info)->gc = true;    }  /* Return special sections to the caller.  */  for (i = 0; i < 6; i++)    {      asection *sec;      sec = xcoff_hash_table (info)->special_sections[i];      if (sec != NULL	  && gc	  && (sec->flags & SEC_MARK) == 0)	sec = NULL;      special_sections[i] = sec;    }  if (info->input_bfds == NULL)    {      /* I'm not sure what to do in this bizarre case.  */      return true;    }  xcoff_link_hash_traverse (xcoff_hash_table (info), xcoff_build_ldsyms,			    (PTR) &ldinfo);  if (ldinfo.failed)    goto error_return;  /* Work out the size of the import file names.  Each import file ID     consists of three null terminated strings: the path, the file     name, and the archive member name.  The first entry in the list     of names is the path to use to find objects, which the linker has     passed in as the libpath argument.  For some reason, the path     entry in the other import file names appears to always be empty.  */  impsize = strlen (libpath) + 3;  impcount = 1;  for (fl = xcoff_hash_table (info)->imports; fl != NULL; fl = fl->next)    {      ++impcount;      impsize += (strlen (fl->path)		  + strlen (fl->file)		  + strlen (fl->member)		  + 3);    }  /* Set up the .loader section header.  */  ldhdr = &xcoff_hash_table (info)->ldhdr;  ldhdr->l_version = 1;  ldhdr->l_nsyms = ldinfo.ldsym_count;  ldhdr->l_nreloc = xcoff_hash_table (info)->ldrel_count;  ldhdr->l_istlen = impsize;  ldhdr->l_nimpid = impcount;  ldhdr->l_impoff = (LDHDRSZ		     + ldhdr->l_nsyms * LDSYMSZ		     + ldhdr->l_nreloc * LDRELSZ);  ldhdr->l_stlen = ldinfo.string_size;  stoff = ldhdr->l_impoff + impsize;  if (ldinfo.string_size == 0)    ldhdr->l_stoff = 0;  else    ldhdr->l_stoff = stoff;  /* We now know the final size of the .loader section.  Allocate     space for it.  */  lsec = xcoff_hash_table (info)->loader_section;  lsec->_raw_size = stoff + ldhdr->l_stlen;  lsec->contents = (bfd_byte *) bfd_zalloc (output_bfd, lsec->_raw_size);  if (lsec->contents == NULL)    {      bfd_set_error (bfd_error_no_memory);      goto error_return;    }  /* Set up the header.  */  xcoff_swap_ldhdr_out (output_bfd, ldhdr,			(struct external_ldhdr *) lsec->contents);  /* Set up the import file names.  */  out = (char *) lsec->contents + ldhdr->l_impoff;  strcpy (out, libpath);  out += strlen (libpath) + 1;  *out++ = '\0';  *out++ = '\0';  for (fl = xcoff_hash_table (info)->imports; fl != NULL; fl = fl->next)    {      register const char *s;      s = fl->path;      while ((*out++ = *s++) != '\0')	;      s = fl->file;      while ((*out++ = *s++) != '\0')	;      s = fl->member;      while ((*out++ = *s++) != '\0')	;    }  BFD_ASSERT ((bfd_size_type) ((bfd_byte *) out - lsec->contents) == stoff);  /* Set up the symbol string table.  */  if (ldinfo.string_size > 0)    {      memcpy (out, ldinfo.strings, ldinfo.string_size);      free (ldinfo.strings);      ldinfo.strings = NULL;    }  /* We can't set up the symbol table or the relocs yet, because we     don't yet know the final position of the various sections.  The     .loader symbols are written out when the corresponding normal     symbols are written out in xcoff_link_input_bfd or     xcoff_write_global_symbol.  The .loader relocs are written out     when the corresponding normal relocs are handled in     xcoff_link_input_bfd.  */  /* Allocate space for the magic sections.  */  sec = xcoff_hash_table (info)->linkage_section;  if (sec->_raw_size > 0)    {      sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);      if (sec->contents == NULL)	{	  bfd_set_error (bfd_error_no_memory);	  goto error_return;	}    }  sec = xcoff_hash_table (info)->toc_section;  if (sec->_raw_size > 0)    {      sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);      if (sec->contents == NULL)	{	  bfd_set_error (bfd_error_no_memory);	  goto error_return;	}    }  sec = xcoff_hash_table (info)->descriptor_section;  if (sec->_raw_size > 0)    {      sec->contents = (bfd_byte *) bfd_zalloc (output_bfd, sec->_raw_size);      if (sec->contents == NULL)	{	  bfd_set_error (bfd_error_no_memory);	  goto error_return;	}    }  /* Now that we've done garbage collection, figure out the contents     of the .debug section.  */  debug_strtab = xcoff_hash_table (info)->debug_strtab;  for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)    {      asection *subdeb;      bfd_size_type symcount;      unsigned long *debug_index;      asection **csectpp;      bfd_byte *esym, *esymend;      bfd_size_type symesz;      if (sub->xvec != info->hash->creator)	continue;      subdeb = bfd_get_section_by_name (sub, ".debug");      if (subdeb == NULL || subdeb->_raw_size == 0)	continue;      if (info->strip == strip_all	  || info->strip == strip_debugger	  || info->discard == discard_all)	{	  subdeb->_raw_size = 0;	  continue;	}      if (! _bfd_coff_get_external_symbols (sub))	goto error_return;      symcount = obj_raw_syment_count (sub);      debug_index = ((unsigned long *)		     bfd_zalloc (sub, symcount * sizeof (unsigned long)));      if (debug_index == NULL)	{	  bfd_set_error (bfd_error_no_memory);	  goto error_return;	}      xcoff_data (sub)->debug_indices = debug_index;      /* Grab the contents of the .debug section.  We use malloc and	 copy the neams into the debug stringtab, rather than	 bfd_alloc, because I expect that, when linking many files	 together, many of the strings will be the same.  Storing the	 strings in the hash table should save space in this case.  */      debug_contents = (bfd_byte *) malloc (subdeb->_raw_size);      if (debug_contents == NULL)	{	  bfd_set_error (bfd_error_no_memory);	  goto error_return;	}      if (! bfd_get_section_contents (sub, subdeb, (PTR) debug_contents,				      (file_ptr) 0, subdeb->_raw_size))	goto error_return;      csectpp = xcoff_data (sub)->csects;      symesz = bfd_coff_symesz (sub);      esym = (bfd_byte *) obj_coff_external_syms (sub);      esymend = esym + symcount * symesz;      while (esym < esymend)	{	  struct internal_syment sym;	  bfd_coff_swap_sym_in (sub, (PTR) esym, (PTR) &sym);	  *debug_index = (unsigned long) -1;	  if (sym._n._n_n._n_zeroes == 0	      && *csectpp != NULL	      && (! gc		  || ((*csectpp)->flags & SEC_MARK) != 0		  || *csectpp == bfd_abs_section_ptr)	      && bfd_coff_symname_in_debug (sub, &sym))	    {	      char *name;	      bfd_size_type indx;	      name = (char *) debug_contents + sym._n._n_n._n_offset;	      indx = _bfd_stringtab_add (debug_strtab, name, true, true);	      if (indx == (bfd_size_type) -1)		goto error_return;	      *debug_index = indx;	    }	  esym += (sym.n_numaux + 1) * symesz;	  csectpp += sym.n_numaux + 1;	  debug_index += sym.n_numaux + 1;	}      free (debug_contents);      debug_contents = NULL;      /* Clear the size of subdeb, so that it is not included directly	 in the output file.  */      subdeb->_raw_size = 0;      if (! info->keep_memory)	{	  if (! _bfd_coff_free_symbols (sub))	    goto error_return;	}    }  xcoff_hash_table (info)->debug_section->_raw_size =    _bfd_stringtab_size (debug_strtab);  return true; error_return:  if (ldinfo.strings != NULL)    free (ldinfo.strings);  if (debug_contents != NULL)    free (debug_contents);  return false;}