aoutx.h

来自「基于4个mips核的noc设计」· C头文件 代码 · 共 2,130 行 · 第 1/5 页

H
2,130
字号
      && bfd_make_section (abfd, ".bss") == (asection *) NULL)    return false;  return true;}/*FUNCTION	aout_@var{size}_some_aout_object_pSYNOPSIS	const bfd_target *aout_@var{size}_some_aout_object_p	 (bfd *abfd,	  const bfd_target *(*callback_to_real_object_p) ());DESCRIPTION	Some a.out variant thinks that the file open in @var{abfd}	checking is an a.out file.  Do some more checking, and set up	for access if it really is.  Call back to the calling	environment's "finish up" function just before returning, to	handle any last-minute setup.*/const bfd_target *NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)     bfd *abfd;     struct internal_exec *execp;     const bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));{  struct aout_data_struct *rawptr, *oldrawptr;  const bfd_target *result;  rawptr = (struct aout_data_struct  *) bfd_zalloc (abfd, sizeof (struct aout_data_struct ));  if (rawptr == NULL)    return 0;  oldrawptr = abfd->tdata.aout_data;  abfd->tdata.aout_data = rawptr;  /* Copy the contents of the old tdata struct.     In particular, we want the subformat, since for hpux it was set in     hp300hpux.c:swap_exec_header_in and will be used in     hp300hpux.c:callback.  */  if (oldrawptr != NULL)    *abfd->tdata.aout_data = *oldrawptr;  abfd->tdata.aout_data->a.hdr = &rawptr->e;  *(abfd->tdata.aout_data->a.hdr) = *execp;	/* Copy in the internal_exec struct */  execp = abfd->tdata.aout_data->a.hdr;  /* Set the file flags */  abfd->flags = BFD_NO_FLAGS;  if (execp->a_drsize || execp->a_trsize)    abfd->flags |= HAS_RELOC;  /* Setting of EXEC_P has been deferred to the bottom of this function */  if (execp->a_syms)    abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;  if (N_DYNAMIC(*execp))    abfd->flags |= DYNAMIC;  if (N_MAGIC (*execp) == ZMAGIC)    {      abfd->flags |= D_PAGED | WP_TEXT;      adata (abfd).magic = z_magic;    }  else if (N_MAGIC (*execp) == QMAGIC)    {      abfd->flags |= D_PAGED | WP_TEXT;      adata (abfd).magic = z_magic;      adata (abfd).subformat = q_magic_format;    }  else if (N_MAGIC (*execp) == NMAGIC)    {      abfd->flags |= WP_TEXT;      adata (abfd).magic = n_magic;    }  else if (N_MAGIC (*execp) == OMAGIC	   || N_MAGIC (*execp) == BMAGIC)    adata (abfd).magic = o_magic;  else    {      /* Should have been checked with N_BADMAG before this routine	 was called.  */      abort ();    }  bfd_get_start_address (abfd) = execp->a_entry;  obj_aout_symbols (abfd) = (aout_symbol_type *)NULL;  bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct external_nlist);  /* The default relocation entry size is that of traditional V7 Unix.  */  obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;  /* The default symbol entry size is that of traditional Unix.  */  obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE;#ifdef USE_MMAP  bfd_init_window (&obj_aout_sym_window (abfd));  bfd_init_window (&obj_aout_string_window (abfd));#endif  obj_aout_external_syms (abfd) = NULL;  obj_aout_external_strings (abfd) = NULL;  obj_aout_sym_hashes (abfd) = NULL;  if (! NAME(aout,make_sections) (abfd))    return NULL;  obj_datasec (abfd)->_raw_size = execp->a_data;  obj_bsssec (abfd)->_raw_size = execp->a_bss;  obj_textsec (abfd)->flags =    (execp->a_trsize != 0     ? (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_RELOC)     : (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS));  obj_datasec (abfd)->flags =    (execp->a_drsize != 0     ? (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS | SEC_RELOC)     : (SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS));  obj_bsssec (abfd)->flags = SEC_ALLOC;#ifdef THIS_IS_ONLY_DOCUMENTATION  /* The common code can't fill in these things because they depend     on either the start address of the text segment, the rounding     up of virtual addresses between segments, or the starting file     position of the text segment -- all of which varies among different     versions of a.out.  */  /* Call back to the format-dependent code to fill in the rest of the     fields and do any further cleanup.  Things that should be filled     in by the callback:  */  struct exec *execp = exec_hdr (abfd);  obj_textsec (abfd)->size = N_TXTSIZE(*execp);  obj_textsec (abfd)->raw_size = N_TXTSIZE(*execp);  /* data and bss are already filled in since they're so standard */  /* The virtual memory addresses of the sections */  obj_textsec (abfd)->vma = N_TXTADDR(*execp);  obj_datasec (abfd)->vma = N_DATADDR(*execp);  obj_bsssec  (abfd)->vma = N_BSSADDR(*execp);  /* The file offsets of the sections */  obj_textsec (abfd)->filepos = N_TXTOFF(*execp);  obj_datasec (abfd)->filepos = N_DATOFF(*execp);  /* The file offsets of the relocation info */  obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);  obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);  /* The file offsets of the string table and symbol table.  */  obj_str_filepos (abfd) = N_STROFF (*execp);  obj_sym_filepos (abfd) = N_SYMOFF (*execp);  /* Determine the architecture and machine type of the object file.  */  switch (N_MACHTYPE (*exec_hdr (abfd))) {  default:    abfd->obj_arch = bfd_arch_obscure;    break;  }  adata(abfd)->page_size = TARGET_PAGE_SIZE;  adata(abfd)->segment_size = SEGMENT_SIZE;  adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE;  return abfd->xvec;  /* The architecture is encoded in various ways in various a.out variants,     or is not encoded at all in some of them.  The relocation size depends     on the architecture and the a.out variant.  Finally, the return value     is the bfd_target vector in use.  If an error occurs, return zero and     set bfd_error to the appropriate error code.     Formats such as b.out, which have additional fields in the a.out     header, should cope with them in this callback as well.  */#endif				/* DOCUMENTATION */  result = (*callback_to_real_object_p) (abfd);  /* Now that the segment addresses have been worked out, take a better     guess at whether the file is executable.  If the entry point     is within the text segment, assume it is.  (This makes files     executable even if their entry point address is 0, as long as     their text starts at zero.).     This test had to be changed to deal with systems where the text segment     runs at a different location than the default.  The problem is that the     entry address can appear to be outside the text segment, thus causing an     erroneous conclusion that the file isn't executable.     To fix this, we now accept any non-zero entry point as an indication of     executability.  This will work most of the time, since only the linker     sets the entry point, and that is likely to be non-zero for most systems.  */  if (execp->a_entry != 0      || (execp->a_entry >= obj_textsec(abfd)->vma	  && execp->a_entry < obj_textsec(abfd)->vma + obj_textsec(abfd)->_raw_size))    abfd->flags |= EXEC_P;#ifdef STAT_FOR_EXEC  else    {      struct stat stat_buf;      /* The original heuristic doesn't work in some important cases.        The a.out file has no information about the text start        address.  For files (like kernels) linked to non-standard        addresses (ld -Ttext nnn) the entry point may not be between        the default text start (obj_textsec(abfd)->vma) and        (obj_textsec(abfd)->vma) + text size.  This is not just a mach        issue.  Many kernels are loaded at non standard addresses.  */      if (abfd->iostream != NULL	  && (abfd->flags & BFD_IN_MEMORY) == 0	  && (fstat(fileno((FILE *) (abfd->iostream)), &stat_buf) == 0)	  && ((stat_buf.st_mode & 0111) != 0))	abfd->flags |= EXEC_P;    }#endif /* STAT_FOR_EXEC */  if (result)    {#if 0 /* These should be set correctly anyways.  */      abfd->sections = obj_textsec (abfd);      obj_textsec (abfd)->next = obj_datasec (abfd);      obj_datasec (abfd)->next = obj_bsssec (abfd);#endif    }  else    {      free (rawptr);      abfd->tdata.aout_data = oldrawptr;    }  return result;}/*FUNCTION	aout_@var{size}_mkobjectSYNOPSIS	boolean aout_@var{size}_mkobject, (bfd *abfd);DESCRIPTION	Initialize BFD @var{abfd} for use with a.out files.*/booleanNAME(aout,mkobject) (abfd)     bfd *abfd;{  struct aout_data_struct  *rawptr;  bfd_set_error (bfd_error_system_call);  /* Use an intermediate variable for clarity */  rawptr = (struct aout_data_struct *)bfd_zalloc (abfd, sizeof (struct aout_data_struct ));  if (rawptr == NULL)    return false;  abfd->tdata.aout_data = rawptr;  exec_hdr (abfd) = &(rawptr->e);  obj_textsec (abfd) = (asection *)NULL;  obj_datasec (abfd) = (asection *)NULL;  obj_bsssec (abfd) = (asection *)NULL;  return true;}/*FUNCTION	aout_@var{size}_machine_typeSYNOPSIS	enum machine_type  aout_@var{size}_machine_type	 (enum bfd_architecture arch,	  unsigned long machine));DESCRIPTION	Keep track of machine architecture and machine type for	a.out's. Return the <<machine_type>> for a particular	architecture and machine, or <<M_UNKNOWN>> if that exact architecture	and machine can't be represented in a.out format.	If the architecture is understood, machine type 0 (default)	is always understood.*/enum machine_typeNAME(aout,machine_type) (arch, machine, unknown)     enum bfd_architecture arch;     unsigned long machine;     boolean *unknown;{  enum machine_type arch_flags;  arch_flags = M_UNKNOWN;  *unknown = true;  switch (arch) {  case bfd_arch_sparc:    if (machine == 0	|| machine == bfd_mach_sparc	|| machine == bfd_mach_sparc_sparclite	|| machine == bfd_mach_sparc_sparclite_le	|| machine == bfd_mach_sparc_v9)      arch_flags = M_SPARC;    else if (machine == bfd_mach_sparc_sparclet)      arch_flags = M_SPARCLET;    break;  case bfd_arch_m68k:    switch (machine) {    case 0:		  arch_flags = M_68010; break;    case bfd_mach_m68000: arch_flags = M_UNKNOWN; *unknown = false; break;    case bfd_mach_m68010: arch_flags = M_68010; break;    case bfd_mach_m68020: arch_flags = M_68020; break;    default:		  arch_flags = M_UNKNOWN; break;    }    break;  case bfd_arch_i386:    if (machine == 0)	arch_flags = M_386;    break;  case bfd_arch_a29k:    if (machine == 0)	arch_flags = M_29K;    break;  case bfd_arch_arm:    if (machine == 0)	arch_flags = M_ARM;    break;  case bfd_arch_mips:    switch (machine) {    case 0:    case bfd_mach_mips3000:    case bfd_mach_mips3900:      arch_flags = M_MIPS1;      break;    case bfd_mach_mips6000:      arch_flags = M_MIPS2;      break;    case bfd_mach_mips4000:    case bfd_mach_mips4010:    case bfd_mach_mips4100:    case bfd_mach_mips4300:    case bfd_mach_mips4400:    case bfd_mach_mips4600:    case bfd_mach_mips4650:    case bfd_mach_mips8000:    case bfd_mach_mips10000:    case bfd_mach_mips12000:    case bfd_mach_mips16:    case bfd_mach_mips32:    case bfd_mach_mips32_4k:    case bfd_mach_mips5:    case bfd_mach_mips64:    case bfd_mach_mips_sb1:      /* FIXME: These should be MIPS3, MIPS4, MIPS16, MIPS32, etc.  */      arch_flags = M_MIPS2;      break;    default:      arch_flags = M_UNKNOWN;      break;    }    break;  case bfd_arch_ns32k:    switch (machine) {    case 0:    		arch_flags = M_NS32532; break;    case 32032:		arch_flags = M_NS32032; break;    case 32532:		arch_flags = M_NS32532; break;    default:		arch_flags = M_UNKNOWN; break;    }    break;  case bfd_arch_vax:    *unknown = false;    break;  case bfd_arch_cris:    if (machine == 0 || machine == 255)	arch_flags = M_CRIS;    break;  default:    arch_flags = M_UNKNOWN;  }  if (arch_flags != M_UNKNOWN)    *unknown = false;  return arch_flags;}/*FUNCTION	aout_@var{size}_set_arch_machSYNOPSIS	boolean aout_@var{size}_set_arch_mach,	 (bfd *,	  enum bfd_architecture arch,	  unsigned long machine));DESCRIPTION	Set the architecture and the machine of the BFD @var{abfd} to the	values @var{arch} and @var{machine}.  Verify that @var{abfd}'s format	can support the architecture required.*/booleanNAME(aout,set_arch_mach) (abfd, arch, machine)     bfd *abfd;     enum bfd_architecture arch;     unsigned long machine;{  if (! bfd_default_set_arch_mach (abfd, arch, machine))    return false;  if (arch != bfd_arch_unknown)    {      boolean unknown;      NAME(aout,machine_type) (arch, machine, &unknown);      if (unknown)

⌨️ 快捷键说明

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