⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objdump.c

📁 基于4个mips核的noc设计
💻 C
📖 第 1 页 / 共 5 页
字号:
	 nul or a digit, then we match.  I.e., we want either an exact	 match or a section followed by a number.  */      if (strncmp (stabsect_name, s->name, len) == 0	  && (s->name[len] == '\000'	      || isdigit ((unsigned char) s->name[len])))	{	  if (read_section_stabs (abfd, s->name, strsect_name))	    {	      print_section_stabs (abfd, s->name, strsect_name);	      free (stabs);	      free (strtab);	    }	}    }}static voiddump_bfd_header (abfd)     bfd *abfd;{  char *comma = "";  printf (_("architecture: %s, "),	  bfd_printable_arch_mach (bfd_get_arch (abfd),				   bfd_get_mach (abfd)));  printf (_("flags 0x%08x:\n"), abfd->flags);#define PF(x, y)    if (abfd->flags & x) {printf("%s%s", comma, y); comma=", ";}  PF (HAS_RELOC, "HAS_RELOC");  PF (EXEC_P, "EXEC_P");  PF (HAS_LINENO, "HAS_LINENO");  PF (HAS_DEBUG, "HAS_DEBUG");  PF (HAS_SYMS, "HAS_SYMS");  PF (HAS_LOCALS, "HAS_LOCALS");  PF (DYNAMIC, "DYNAMIC");  PF (WP_TEXT, "WP_TEXT");  PF (D_PAGED, "D_PAGED");  PF (BFD_IS_RELAXABLE, "BFD_IS_RELAXABLE");  printf (_("\nstart address 0x"));  printf_vma (abfd->start_address);  printf ("\n");}static voiddump_bfd_private_header (abfd)bfd *abfd;{  bfd_print_private_bfd_data (abfd, stdout);}/* Dump selected contents of ABFD */static voiddump_bfd (abfd)     bfd *abfd;{  /* If we are adjusting section VMA's, change them all now.  Changing     the BFD information is a hack.  However, we must do it, or     bfd_find_nearest_line will not do the right thing.  */  if (adjust_section_vma != 0)    {      asection *s;      for (s = abfd->sections; s != NULL; s = s->next)	{	  s->vma += adjust_section_vma;	  s->lma += adjust_section_vma;	}    }  printf (_("\n%s:     file format %s\n"), bfd_get_filename (abfd),	  abfd->xvec->name);  if (dump_ar_hdrs)    print_arelt_descr (stdout, abfd, true);  if (dump_file_header)    dump_bfd_header (abfd);  if (dump_private_headers)    dump_bfd_private_header (abfd);  putchar ('\n');  if (dump_section_headers)    dump_headers (abfd);  if (dump_symtab || dump_reloc_info || disassemble || dump_debugging)    {      syms = slurp_symtab (abfd);    }  if (dump_dynamic_symtab || dump_dynamic_reloc_info)    {      dynsyms = slurp_dynamic_symtab (abfd);    }  if (dump_symtab)    dump_symbols (abfd, false);  if (dump_dynamic_symtab)    dump_symbols (abfd, true);  if (dump_stab_section_info)    dump_stabs (abfd);  if (dump_reloc_info && ! disassemble)    dump_relocs (abfd);  if (dump_dynamic_reloc_info)    dump_dynamic_relocs (abfd);  if (dump_section_contents)    dump_data (abfd);  if (disassemble)    disassemble_data (abfd);  if (dump_debugging)    {      PTR dhandle;      dhandle = read_debugging_info (abfd, syms, symcount);      if (dhandle != NULL)	{	  if (! print_debugging_info (stdout, dhandle))	    {	      non_fatal (_("%s: printing debugging information failed"),			 bfd_get_filename (abfd));	      exit_status = 1;	    }	}    }  if (syms)    {      free (syms);      syms = NULL;    }  if (dynsyms)    {      free (dynsyms);      dynsyms = NULL;    }}static voiddisplay_bfd (abfd)     bfd *abfd;{  char **matching;  if (bfd_check_format_matches (abfd, bfd_object, &matching))    {      dump_bfd (abfd);      return;    }  if (bfd_get_error () == bfd_error_file_ambiguously_recognized)    {      nonfatal (bfd_get_filename (abfd));      list_matching_formats (matching);      free (matching);      return;    }  if (bfd_get_error () != bfd_error_file_not_recognized)    {      nonfatal (bfd_get_filename (abfd));      return;    }  if (bfd_check_format_matches (abfd, bfd_core, &matching))    {      dump_bfd (abfd);      return;    }  nonfatal (bfd_get_filename (abfd));  if (bfd_get_error () == bfd_error_file_ambiguously_recognized)    {      list_matching_formats (matching);      free (matching);    }}static voiddisplay_file (filename, target)     char *filename;     char *target;{  bfd *file, *arfile = (bfd *) NULL;  file = bfd_openr (filename, target);  if (file == NULL)    {      nonfatal (filename);      return;    }  if (bfd_check_format (file, bfd_archive) == true)    {      bfd *last_arfile = NULL;      printf (_("In archive %s:\n"), bfd_get_filename (file));      for (;;)	{	  bfd_set_error (bfd_error_no_error);	  arfile = bfd_openr_next_archived_file (file, arfile);	  if (arfile == NULL)	    {	      if (bfd_get_error () != bfd_error_no_more_archived_files)		nonfatal (bfd_get_filename (file));	      break;	    }	  display_bfd (arfile);	  if (last_arfile != NULL)	    bfd_close (last_arfile);	  last_arfile = arfile;	}      if (last_arfile != NULL)	bfd_close (last_arfile);    }  else    display_bfd (file);  bfd_close (file);}/* Actually display the various requested regions */static voiddump_data (abfd)     bfd *abfd;{  asection *section;  bfd_byte *data = 0;  bfd_size_type datasize = 0;  bfd_size_type addr_offset;  bfd_size_type start_offset, stop_offset;  unsigned int opb = bfd_octets_per_byte (abfd);  for (section = abfd->sections; section != NULL; section =       section->next)    {      int onaline = 16;      if (only == (char *) NULL ||	  strcmp (only, section->name) == 0)	{	  if (section->flags & SEC_HAS_CONTENTS)	    {	      printf (_("Contents of section %s:\n"), section->name);	      if (bfd_section_size (abfd, section) == 0)		continue;	      data = (bfd_byte *) xmalloc ((size_t) bfd_section_size (abfd, section));	      datasize = bfd_section_size (abfd, section);	      bfd_get_section_contents (abfd, section, (PTR) data, 0, bfd_section_size (abfd, section));	      if (start_address == (bfd_vma) -1		  || start_address < section->vma)		start_offset = 0;	      else		start_offset = start_address - section->vma;	      if (stop_address == (bfd_vma) -1)		stop_offset = bfd_section_size (abfd, section) / opb;	      else		{		  if (stop_address < section->vma)		    stop_offset = 0;		  else		    stop_offset = stop_address - section->vma;		  if (stop_offset > bfd_section_size (abfd, section) / opb)		    stop_offset = bfd_section_size (abfd, section) / opb;		}	      for (addr_offset = start_offset;                    addr_offset < stop_offset; addr_offset += onaline)		{		  bfd_size_type j;		  printf (" %04lx ", (unsigned long int)                           (addr_offset + section->vma));		  for (j = addr_offset * opb;                        j < addr_offset * opb + onaline; j++)		    {		      if (j < stop_offset * opb)			printf ("%02x", (unsigned) (data[j]));		      else			printf ("  ");		      if ((j & 3) == 3)			printf (" ");		    }		  printf (" ");		  for (j = addr_offset; j < addr_offset * opb + onaline; j++)		    {		      if (j >= stop_offset * opb)			printf (" ");		      else			printf ("%c", isprint (data[j]) ? data[j] : '.');		    }		  putchar ('\n');		}	      free (data);	    }	}    }}/* Should perhaps share code and display with nm? */static voiddump_symbols (abfd, dynamic)     bfd *abfd ATTRIBUTE_UNUSED;     boolean dynamic;{  asymbol **current;  long max;  long count;  if (dynamic)    {      current = dynsyms;      max = dynsymcount;      if (max == 0)	return;      printf ("DYNAMIC SYMBOL TABLE:\n");    }  else    {      current = syms;      max = symcount;      if (max == 0)	return;      printf ("SYMBOL TABLE:\n");    }  for (count = 0; count < max; count++)    {      if (*current)	{	  bfd *cur_bfd = bfd_asymbol_bfd (*current);	  if (cur_bfd != NULL)	    {	      const char *name;	      char *alloc;	      name = bfd_asymbol_name (*current);	      alloc = NULL;	      if (do_demangle && name != NULL && *name != '\0')		{		  const char *n;		  /* If we want to demangle the name, we demangle it                     here, and temporarily clobber it while calling                     bfd_print_symbol.  FIXME: This is a gross hack.  */		  n = name;		  if (bfd_get_symbol_leading_char (cur_bfd) == *n)		    ++n;		  alloc = cplus_demangle (n, DMGL_ANSI | DMGL_PARAMS);		  if (alloc != NULL)		    (*current)->name = alloc;		  else		    (*current)->name = n;		}	      bfd_print_symbol (cur_bfd, stdout, *current,				bfd_print_symbol_all);	      (*current)->name = name;	      if (alloc != NULL)		free (alloc);	      printf ("\n");	    }	}      current++;    }  printf ("\n");  printf ("\n");}static voiddump_relocs (abfd)     bfd *abfd;{  arelent **relpp;  long relcount;  asection *a;  for (a = abfd->sections; a != (asection *) NULL; a = a->next)    {      long relsize;      if (bfd_is_abs_section (a))	continue;      if (bfd_is_und_section (a))	continue;      if (bfd_is_com_section (a))	continue;      if (only)	{	  if (strcmp (only, a->name))	    continue;	}      else if ((a->flags & SEC_RELOC) == 0)	continue;      relsize = bfd_get_reloc_upper_bound (abfd, a);      if (relsize < 0)	bfd_fatal (bfd_get_filename (abfd));      printf ("RELOCATION RECORDS FOR [%s]:", a->name);      if (relsize == 0)	{	  printf (" (none)\n\n");	}      else	{	  relpp = (arelent **) xmalloc (relsize);	  relcount = bfd_canonicalize_reloc (abfd, a, relpp, syms);	  if (relcount < 0)	    bfd_fatal (bfd_get_filename (abfd));	  else if (relcount == 0)	    {	      printf (" (none)\n\n");	    }	  else	    {	      printf ("\n");	      dump_reloc_set (abfd, a, relpp, relcount);	      printf ("\n\n");	    }	  free (relpp);	}    }}static voiddump_dynamic_relocs (abfd)     bfd *abfd;{  long relsize;  arelent **relpp;  long relcount;  relsize = bfd_get_dynamic_reloc_upper_bound (abfd);  if (relsize < 0)    bfd_fatal (bfd_get_filename (abfd));  printf ("DYNAMIC RELOCATION RECORDS");  if (relsize == 0)    {      printf (" (none)\n\n");    }  else    {      relpp = (arelent **) xmalloc (relsize);      relcount = bfd_canonicalize_dynamic_reloc (abfd, relpp, dynsyms);      if (relcount < 0)	bfd_fatal (bfd_get_filename (abfd));      else if (relcount == 0)	{	  printf (" (none)\n\n");	}      else	{	  printf ("\n");	  dump_reloc_set (abfd, (asection *) NULL, relpp, relcount);	  printf ("\n\n");	}      free (relpp);    }}static voiddump_reloc_set (abfd, sec, relpp, relcount)     bfd *abfd;     asection *sec;     arelent **relpp;     long relcount;{  arelent **p;  char *last_filename, *last_functionname;  unsigned int last_line;  /* Get column headers lined up reasonably.  */  {    static int width;    if (width == 0)      {	char buf[30];	sprintf_vma (buf, (bfd_vma) -1);	width = strlen (buf) - 7;      }    printf ("OFFSET %*s TYPE %*s VALUE \n", width, "", 12, "");  }  last_filename = NULL;  last_functionname = NULL;  last_line = 0;  for (p = relpp; relcount && *p != (arelent *) NULL; p++, relcount--)    {      arelent *q = *p;      const char *filename, *functionname;      unsigned int line;      const char *sym_name;      const char *section_name;      if (start_address != (bfd_vma) -1	  && q->address < start_address)	continue;      if (sto

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -