FreeBSD/contrib/binutils/bfd/elflink.c
/* Assign dynsym indices.  In a shared library we generate a section
   symbol for each output section, which come first.  Next come symbols
   which have been forced to local binding.  Then all of the back-end
   allocated local dynamic syms, followed by the rest of the global
   symbols.  */
Assign dynsym indices.  In a shared library we generate a section
symbol for each output section, which come first.  Next come symbols
which have been forced to local binding.  Then all of the back-end
allocated local dynamic syms, followed by the rest of the global
symbols.
Assign dynsym indices . In a shared library we generate a section symbol for each output section which come first . Next come symbols which have been forced to local binding . Then all of the back - end allocated local dynamic syms followed by the rest of the global symbols .
static unsigned long
_bfd_elf_link_renumber_dynsyms (bfd *output_bfd,
				struct bfd_link_info *info,
				unsigned long *section_sym_count)
{
  unsigned long dynsymcount = 0;
  if (info->shared || elf_hash_table (info)->is_relocatable_executable)
    {
      const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
      asection *p;
      for (p = output_bfd->sections; p ; p = p->next)
	if ((p->flags & SEC_EXCLUDE) == 0
	    && (p->flags & SEC_ALLOC) != 0
	    && !(*bed->elf_backend_omit_section_dynsym) (output_bfd, info, p))
	  elf_section_data (p)->dynindx = ++dynsymcount;
	else
	  elf_section_data (p)->dynindx = 0;
    }
  *section_sym_count = dynsymcount;
  elf_link_hash_traverse (elf_hash_table (info),
			  elf_link_renumber_local_hash_table_dynsyms,
			  &dynsymcount);
  if (elf_hash_table (info)->dynlocal)
    {
      struct elf_link_local_dynamic_entry *p;
      for (p = elf_hash_table (info)->dynlocal; p ; p = p->next)
	p->dynindx = ++dynsymcount;
    }
  elf_link_hash_traverse (elf_hash_table (info),
			  elf_link_renumber_hash_table_dynsyms,
			  &dynsymcount);
  if (dynsymcount != 0)
    ++dynsymcount;
  elf_hash_table (info)->dynsymcount = dynsymcount;
  return dynsymcount;
}
static unsigned long _bfd_elf_link_renumber_dynsyms ( bfd * output_bfd , struct bfd_link_info * info , unsigned long * section_sym_count ) { unsigned long dynsymcount = 0 ; if ( info -> shared || elf_hash_table ( info ) -> is_relocatable_executable ) { const struct elf_backend_data * bed = get_elf_backend_data ( output_bfd ) ; asection * p ; for ( p = output_bfd -> sections ; p ; p = p -> next ) if ( ( p -> flags & SEC_EXCLUDE ) == 0 && ( p -> flags & SEC_ALLOC ) != 0 && ! ( * bed -> elf_backend_omit_section_dynsym ) ( output_bfd , info , p ) ) elf_section_data ( p ) -> dynindx = ++ dynsymcount ; else elf_section_data ( p ) -> dynindx = 0 ; } * section_sym_count = dynsymcount ; elf_link_hash_traverse ( elf_hash_table ( info ) , elf_link_renumber_local_hash_table_dynsyms , & dynsymcount ) ; if ( elf_hash_table ( info ) -> dynlocal ) { struct elf_link_local_dynamic_entry * p ; for ( p = elf_hash_table ( info ) -> dynlocal ; p ; p = p -> next ) p -> dynindx = ++ dynsymcount ; } elf_link_hash_traverse ( elf_hash_table ( info ) , elf_link_renumber_hash_table_dynsyms , & dynsymcount ) ; if ( dynsymcount != 0 ) ++ dynsymcount ; elf_hash_table ( info ) -> dynsymcount = dynsymcount ; return dynsymcount ; }
Assign dynsym indices.
Assign dynsym indices .
/* There is an unused NULL entry at the head of the table which
     we must account for in our count.  Unless there weren't any
     symbols, which means we'll have no table at all.  */