FreeBSD/contrib/binutils/bfd/elf.c
/* Given a BFD symbol, return the index in the ELF symbol table, or -1
   on error.  */
Given a BFD symbol, return the index in the ELF symbol table, or -1
on error.
Given a BFD symbol return the index in the ELF symbol table or - 1 on error .
int
_bfd_elf_symbol_from_bfd_symbol (bfd *abfd, asymbol **asym_ptr_ptr)
{
  asymbol *asym_ptr = *asym_ptr_ptr;
  int idx;
  flagword flags = asym_ptr->flags;
  if (asym_ptr->udata.i == 0
      && (flags & BSF_SECTION_SYM)
      && asym_ptr->section)
    {
      asection *sec;
      int indx;
      sec = asym_ptr->section;
      if (sec->owner != abfd && sec->output_section != NULL)
	sec = sec->output_section;
      if (sec->owner == abfd
	  && (indx = sec->index) < elf_num_section_syms (abfd)
	  && elf_section_syms (abfd)[indx] != NULL)
	asym_ptr->udata.i = elf_section_syms (abfd)[indx]->udata.i;
    }
  idx = asym_ptr->udata.i;
  if (idx == 0)
    {
      (*_bfd_error_handler)
	(_("%B: symbol `%s' required but not present"),
	 abfd, bfd_asymbol_name (asym_ptr));
      bfd_set_error (bfd_error_no_symbols);
      return -1;
    }
#if DEBUG & 4
  {
    fprintf (stderr,
	     "elf_symbol_from_bfd_symbol 0x%.8lx, name = %s, sym num = %d, flags = 0x%.8lx%s\n",
	     (long) asym_ptr, asym_ptr->name, idx, flags,
	     elf_symbol_flags (flags));
    fflush (stderr);
  }
#endif
  return idx;
}
int _bfd_elf_symbol_from_bfd_symbol ( bfd * abfd , asymbol * * asym_ptr_ptr ) { asymbol * asym_ptr = * asym_ptr_ptr ; int idx ; flagword flags = asym_ptr -> flags ; if ( asym_ptr -> udata . i == 0 && ( flags & BSF_SECTION_SYM ) && asym_ptr -> section ) { asection * sec ; int indx ; sec = asym_ptr -> section ; if ( sec -> owner != abfd && sec -> output_section != NULL ) sec = sec -> output_section ; if ( sec -> owner == abfd && ( indx = sec -> index ) < elf_num_section_syms ( abfd ) && elf_section_syms ( abfd ) [ indx ] != NULL ) asym_ptr -> udata . i = elf_section_syms ( abfd ) [ indx ] -> udata . i ; } idx = asym_ptr -> udata . i ; if ( idx == 0 ) { ( * _bfd_error_handler ) ( _ ( " " ) , abfd , bfd_asymbol_name ( asym_ptr ) ) ; bfd_set_error ( bfd_error_no_symbols ) ; return -1 ; } #if DEBUG & 4 { fprintf ( stderr , " \n " , ( long ) asym_ptr , asym_ptr -> name , idx , flags , elf_symbol_flags ( flags ) ) ; fflush ( stderr ) ; } #endif return idx ; }
Given a BFD symbol, return the index in the ELF symbol table, or -1
on error.
Given a BFD symbol return the index in the ELF symbol table or - 1 on error .
/* When gas creates relocations against local labels, it creates its
     own symbol for the section, but does put the symbol into the
     symbol chain, so udata is 0.  When the linker is generating
     relocatable output, this section symbol may be for one of the
     input sections rather than the output section.  */ /* This case can occur when using --strip-symbol on a symbol
	 which is used in a relocation entry.  */