FreeBSD/contrib/binutils/bfd/elf.c
/* Display ELF-specific fields of a symbol.  */
Display ELF-specific fields of a symbol.
Display ELF - specific fields of a symbol .
void
bfd_elf_print_symbol (bfd *abfd,
		      void *filep,
		      asymbol *symbol,
		      bfd_print_symbol_type how)
{
  FILE *file = filep;
  switch (how)
    {
    case bfd_print_symbol_name:
      fprintf (file, "%s", symbol->name);
      break;
    case bfd_print_symbol_more:
      fprintf (file, "elf ");
      bfd_fprintf_vma (abfd, file, symbol->value);
      fprintf (file, " %lx", (long) symbol->flags);
      break;
    case bfd_print_symbol_all:
      {
	const char *section_name;
	const char *name = NULL;
	const struct elf_backend_data *bed;
	unsigned char st_other;
	bfd_vma val;
	section_name = symbol->section ? symbol->section->name : "(*none*)";
	bed = get_elf_backend_data (abfd);
	if (bed->elf_backend_print_symbol_all)
	  name = (*bed->elf_backend_print_symbol_all) (abfd, filep, symbol);
	if (name == NULL)
	  {
	    name = symbol->name;
	    bfd_print_symbol_vandf (abfd, file, symbol);
	  }
	fprintf (file, " %s\t", section_name);
	if (bfd_is_com_section (symbol->section))
	  val = ((elf_symbol_type *) symbol)->internal_elf_sym.st_value;
	else
	  val = ((elf_symbol_type *) symbol)->internal_elf_sym.st_size;
	bfd_fprintf_vma (abfd, file, val);
	if (elf_tdata (abfd)->dynversym_section != 0
	    && (elf_tdata (abfd)->dynverdef_section != 0
		|| elf_tdata (abfd)->dynverref_section != 0))
	  {
	    unsigned int vernum;
	    const char *version_string;
	    vernum = ((elf_symbol_type *) symbol)->version & VERSYM_VERSION;
	    if (vernum == 0)
	      version_string = "";
	    else if (vernum == 1)
	      version_string = "Base";
	    else if (vernum <= elf_tdata (abfd)->cverdefs)
	      version_string =
		elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
	    else
	      {
		Elf_Internal_Verneed *t;
		version_string = "";
		for (t = elf_tdata (abfd)->verref;
		     t != NULL;
		     t = t->vn_nextref)
		  {
		    Elf_Internal_Vernaux *a;
		    for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr)
		      {
			if (a->vna_other == vernum)
			  {
			    version_string = a->vna_nodename;
			    break;
			  }
		      }
		  }
	      }
	    if ((((elf_symbol_type *) symbol)->version & VERSYM_HIDDEN) == 0)
	      fprintf (file, "  %-11s", version_string);
	    else
	      {
		int i;
		fprintf (file, " (%s)", version_string);
		for (i = 10 - strlen (version_string); i > 0; --i)
		  putc (' ', file);
	      }
	  }
	st_other = ((elf_symbol_type *) symbol)->internal_elf_sym.st_other;
	switch (st_other)
	  {
	  case 0: break;
	  case STV_INTERNAL:  fprintf (file, " .internal");  break;
	  case STV_HIDDEN:    fprintf (file, " .hidden");    break;
	  case STV_PROTECTED: fprintf (file, " .protected"); break;
	  default:
	    fprintf (file, " 0x%02x", (unsigned int) st_other);
	  }
	fprintf (file, " %s", name);
      }
      break;
    }
}
void bfd_elf_print_symbol ( bfd * abfd , void * filep , asymbol * symbol , bfd_print_symbol_type how ) { FILE * file = filep ; switch ( how ) { case bfd_print_symbol_name : fprintf ( file , " " , symbol -> name ) ; break ; case bfd_print_symbol_more : fprintf ( file , " " ) ; bfd_fprintf_vma ( abfd , file , symbol -> value ) ; fprintf ( file , " " , ( long ) symbol -> flags ) ; break ; case bfd_print_symbol_all : { const char * section_name ; const char * name = NULL ; const struct elf_backend_data * bed ; unsigned char st_other ; bfd_vma val ; section_name = symbol -> section ? symbol -> section -> name : " " ; bed = get_elf_backend_data ( abfd ) ; if ( bed -> elf_backend_print_symbol_all ) name = ( * bed -> elf_backend_print_symbol_all ) ( abfd , filep , symbol ) ; if ( name == NULL ) { name = symbol -> name ; bfd_print_symbol_vandf ( abfd , file , symbol ) ; } fprintf ( file , " \t " , section_name ) ; if ( bfd_is_com_section ( symbol -> section ) ) val = ( ( elf_symbol_type * ) symbol ) -> internal_elf_sym . st_value ; else val = ( ( elf_symbol_type * ) symbol ) -> internal_elf_sym . st_size ; bfd_fprintf_vma ( abfd , file , val ) ; if ( elf_tdata ( abfd ) -> dynversym_section != 0 && ( elf_tdata ( abfd ) -> dynverdef_section != 0 || elf_tdata ( abfd ) -> dynverref_section != 0 ) ) { unsigned int vernum ; const char * version_string ; vernum = ( ( elf_symbol_type * ) symbol ) -> version & VERSYM_VERSION ; if ( vernum == 0 ) version_string = " " ; else if ( vernum == 1 ) version_string = " " ; else if ( vernum <= elf_tdata ( abfd ) -> cverdefs ) version_string = elf_tdata ( abfd ) -> verdef [ vernum - 1 ] . vd_nodename ; else { Elf_Internal_Verneed * t ; version_string = " " ; for ( t = elf_tdata ( abfd ) -> verref ; t != NULL ; t = t -> vn_nextref ) { Elf_Internal_Vernaux * a ; for ( a = t -> vn_auxptr ; a != NULL ; a = a -> vna_nextptr ) { if ( a -> vna_other == vernum ) { version_string = a -> vna_nodename ; break ; } } } } if ( ( ( ( elf_symbol_type * ) symbol ) -> version & VERSYM_HIDDEN ) == 0 ) fprintf ( file , " " , version_string ) ; else { int i ; fprintf ( file , " " , version_string ) ; for ( i = 10 - strlen ( version_string ) ; i > 0 ; -- i ) putc ( ' ' , file ) ; } } st_other = ( ( elf_symbol_type * ) symbol ) -> internal_elf_sym . st_other ; switch ( st_other ) { case 0 : break ; case STV_INTERNAL : fprintf ( file , " " ) ; break ; case STV_HIDDEN : fprintf ( file , " " ) ; break ; case STV_PROTECTED : fprintf ( file , " " ) ; break ; default : fprintf ( file , " " , ( unsigned int ) st_other ) ; } fprintf ( file , " " , name ) ; } break ; } }
Display ELF-specific fields of a symbol.
Display ELF - specific fields of a symbol .
/* Print the "other" value for a symbol.  For common symbols,
	   we've already printed the size; now print the alignment.
	   For other symbols, we have no specified alignment, and
	   we've printed the address; now print the size.  */ /* If we have version information, print it.  */ /* If the st_other field is not zero, print it.  */ /* Some other non-defined flags are also present, so print
	       everything hex.  */