FreeBSD/contrib/binutils/bfd/elflink.c
/* Add a symbol to the output symbol table.  */
Add a symbol to the output symbol table.
Add a symbol to the output symbol table .
static bfd_boolean
elf_link_output_sym (struct elf_final_link_info *finfo,
		     const char *name,
		     Elf_Internal_Sym *elfsym,
		     asection *input_sec,
		     struct elf_link_hash_entry *h)
{
  bfd_byte *dest;
  Elf_External_Sym_Shndx *destshndx;
  bfd_boolean (*output_symbol_hook)
    (struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection *,
     struct elf_link_hash_entry *);
  const struct elf_backend_data *bed;
  bed = get_elf_backend_data (finfo->output_bfd);
  output_symbol_hook = bed->elf_backend_link_output_symbol_hook;
  if (output_symbol_hook != NULL)
    {
      if (! (*output_symbol_hook) (finfo->info, name, elfsym, input_sec, h))
	return FALSE;
    }
  if (name == NULL || *name == '\0')
    elfsym->st_name = 0;
  else if (input_sec->flags & SEC_EXCLUDE)
    elfsym->st_name = 0;
  else
    {
      elfsym->st_name = (unsigned long) _bfd_stringtab_add (finfo->symstrtab,
							    name, TRUE, FALSE);
      if (elfsym->st_name == (unsigned long) -1)
	return FALSE;
    }
  if (finfo->symbuf_count >= finfo->symbuf_size)
    {
      if (! elf_link_flush_output_syms (finfo, bed))
	return FALSE;
    }
  dest = finfo->symbuf + finfo->symbuf_count * bed->s->sizeof_sym;
  destshndx = finfo->symshndxbuf;
  if (destshndx != NULL)
    {
      if (bfd_get_symcount (finfo->output_bfd) >= finfo->shndxbuf_size)
	{
	  bfd_size_type amt;
	  amt = finfo->shndxbuf_size * sizeof (Elf_External_Sym_Shndx);
	  finfo->symshndxbuf = destshndx = bfd_realloc (destshndx, amt * 2);
	  if (destshndx == NULL)
	    return FALSE;
	  memset ((char *) destshndx + amt, 0, amt);
	  finfo->shndxbuf_size *= 2;
	}
      destshndx += bfd_get_symcount (finfo->output_bfd);
    }
  bed->s->swap_symbol_out (finfo->output_bfd, elfsym, dest, destshndx);
  finfo->symbuf_count += 1;
  bfd_get_symcount (finfo->output_bfd) += 1;
  return TRUE;
}
static bfd_boolean elf_link_output_sym ( struct elf_final_link_info * finfo , const char * name , Elf_Internal_Sym * elfsym , asection * input_sec , struct elf_link_hash_entry * h ) { bfd_byte * dest ; Elf_External_Sym_Shndx * destshndx ; bfd_boolean ( * output_symbol_hook ) ( struct bfd_link_info * , const char * , Elf_Internal_Sym * , asection * , struct elf_link_hash_entry * ) ; const struct elf_backend_data * bed ; bed = get_elf_backend_data ( finfo -> output_bfd ) ; output_symbol_hook = bed -> elf_backend_link_output_symbol_hook ; if ( output_symbol_hook != NULL ) { if ( ! ( * output_symbol_hook ) ( finfo -> info , name , elfsym , input_sec , h ) ) return FALSE ; } if ( name == NULL || * name == ' \0 ' ) elfsym -> st_name = 0 ; else if ( input_sec -> flags & SEC_EXCLUDE ) elfsym -> st_name = 0 ; else { elfsym -> st_name = ( unsigned long ) _bfd_stringtab_add ( finfo -> symstrtab , name , TRUE , FALSE ) ; if ( elfsym -> st_name == ( unsigned long ) -1 ) return FALSE ; } if ( finfo -> symbuf_count >= finfo -> symbuf_size ) { if ( ! elf_link_flush_output_syms ( finfo , bed ) ) return FALSE ; } dest = finfo -> symbuf + finfo -> symbuf_count * bed -> s -> sizeof_sym ; destshndx = finfo -> symshndxbuf ; if ( destshndx != NULL ) { if ( bfd_get_symcount ( finfo -> output_bfd ) >= finfo -> shndxbuf_size ) { bfd_size_type amt ; amt = finfo -> shndxbuf_size * sizeof ( Elf_External_Sym_Shndx ) ; finfo -> symshndxbuf = destshndx = bfd_realloc ( destshndx , amt * 2 ) ; if ( destshndx == NULL ) return FALSE ; memset ( ( char * ) destshndx + amt , 0 , amt ) ; finfo -> shndxbuf_size *= 2 ; } destshndx += bfd_get_symcount ( finfo -> output_bfd ) ; } bed -> s -> swap_symbol_out ( finfo -> output_bfd , elfsym , dest , destshndx ) ; finfo -> symbuf_count += 1 ; bfd_get_symcount ( finfo -> output_bfd ) += 1 ; return TRUE ; }
Add a symbol to the output symbol table.
Add a symbol to the output symbol table .