aoutf1.h

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

H
859
字号
/* A.out "format 1" file handling code for BFD.   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000   Free Software Foundation, Inc.   Written by Cygnus Support.This file is part of BFD, the Binary File Descriptor library.This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */#include "bfd.h"#include "sysdep.h"#include "libbfd.h"#include "aout/sun4.h"#include "libaout.h"		/* BFD a.out internal data structures */#include "aout/aout64.h"#include "aout/stab_gnu.h"#include "aout/ar.h"/* This is needed to reject a NewsOS file, e.g. in   gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>   I needed to add M_UNKNOWN to recognize a 68000 object, so this will   probably no longer reject a NewsOS object.  <ian@cygnus.com>.  */#ifndef MACHTYPE_OK#define MACHTYPE_OK(mtype) \  (((mtype) == M_SPARC && bfd_lookup_arch (bfd_arch_sparc, 0) != NULL) \   || (((mtype) == M_UNKNOWN || (mtype) == M_68010 || (mtype) == M_68020) \       && bfd_lookup_arch (bfd_arch_m68k, 0) != NULL))#endif/*The file @code{aoutf1.h} contains the code for BFD'sa.out back end. Control over the generated back end is given by thesetwo preprocessor names:@table @code@item ARCH_SIZEThis value should be either 32 or 64, depending upon the size of anint in the target format. It changes the sizes of the structs whichperform the memory/disk mapping of structures.The 64 bit backend may only be used if the host compiler supports 64ints (eg long long with gcc), by defining the name @code{BFD_HOST_64_BIT} in @code{bfd.h}.With this name defined, @emph{all} bfd operations are performed with 64bitarithmetic, not just those to a 64bit target.@item TARGETNAMEThe name put into the target vector.@item@end table*//*SUPPRESS558*//*SUPPRESS529*/#if ARCH_SIZE == 64#define sunos_set_arch_mach sunos_64_set_arch_mach#define sunos_write_object_contents aout_64_sunos4_write_object_contents#else#define sunos_set_arch_mach sunos_32_set_arch_mach#define sunos_write_object_contents aout_32_sunos4_write_object_contents#endifstatic boolean sunos_merge_private_bfd_data PARAMS ((bfd *, bfd *));static void sunos_set_arch_mach PARAMS ((bfd *, int));static void choose_reloc_size PARAMS ((bfd *));static boolean sunos_write_object_contents PARAMS ((bfd *));static const bfd_target *sunos4_core_file_p PARAMS ((bfd *));static char *sunos4_core_file_failing_command PARAMS ((bfd *));static int sunos4_core_file_failing_signal PARAMS ((bfd *));static boolean sunos4_core_file_matches_executable_p PARAMS ((bfd *, bfd *));static boolean sunos4_set_sizes PARAMS ((bfd *));/* Merge backend data into the output file.   This is necessary on sparclet-aout where we want the resultant machine   number to be M_SPARCLET if any input file is M_SPARCLET.  */#define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_datastatic booleansunos_merge_private_bfd_data (ibfd, obfd)     bfd *ibfd, *obfd;{  if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour      || bfd_get_flavour (obfd) != bfd_target_aout_flavour)    return true;  if (bfd_get_arch (obfd) == bfd_arch_sparc)    {      if (bfd_get_mach (obfd) < bfd_get_mach (ibfd))	bfd_set_arch_mach (obfd, bfd_arch_sparc, bfd_get_mach (ibfd));    }  return true;}/* This is either sunos_32_set_arch_mach or sunos_64_set_arch_mach,   depending upon ARCH_SIZE.  */static voidsunos_set_arch_mach (abfd, machtype)     bfd *abfd;     int machtype;{  /* Determine the architecture and machine type of the object file.  */  enum bfd_architecture arch;  long machine;  switch (machtype)    {    case M_UNKNOWN:      /* Some Sun3s make magic numbers without cpu types in them, so	 we'll default to the 68000.  */      arch = bfd_arch_m68k;      machine = bfd_mach_m68000;      break;    case M_68010:    case M_HP200:      arch = bfd_arch_m68k;      machine = bfd_mach_m68010;      break;    case M_68020:    case M_HP300:      arch = bfd_arch_m68k;      machine = bfd_mach_m68020;      break;    case M_SPARC:      arch = bfd_arch_sparc;      machine = 0;      break;    case M_SPARCLET:      arch = bfd_arch_sparc;      machine = bfd_mach_sparc_sparclet;      break;    case M_SPARCLITE_LE:      arch = bfd_arch_sparc;      machine = bfd_mach_sparc_sparclite_le;      break;    case M_386:    case M_386_DYNIX:      arch = bfd_arch_i386;      machine = 0;      break;    case M_29K:      arch = bfd_arch_a29k;      machine = 0;      break;    case M_HPUX:      arch = bfd_arch_m68k;      machine = 0;      break;    default:      arch = bfd_arch_obscure;      machine = 0;      break;    }  bfd_set_arch_mach (abfd, arch, machine);}#define SET_ARCH_MACH(ABFD, EXEC) \  NAME(sunos,set_arch_mach) (ABFD, N_MACHTYPE (EXEC)); \  choose_reloc_size(ABFD);/* Determine the size of a relocation entry, based on the architecture */static voidchoose_reloc_size (abfd)     bfd *abfd;{  switch (bfd_get_arch (abfd))    {    case bfd_arch_sparc:    case bfd_arch_a29k:      obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE;      break;    default:      obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;      break;    }}/* Write an object file in SunOS format.  Section contents have   already been written.  We write the file header, symbols, and   relocation.  The real name of this function is either   aout_64_sunos4_write_object_contents or   aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE.  */static booleansunos_write_object_contents (abfd)     bfd *abfd;{  struct external_exec exec_bytes;  struct internal_exec *execp = exec_hdr (abfd);  /* Magic number, maestro, please!  */  switch (bfd_get_arch (abfd))    {    case bfd_arch_m68k:      switch (bfd_get_mach (abfd))	{	case bfd_mach_m68000:	  N_SET_MACHTYPE (*execp, M_UNKNOWN);	  break;	case bfd_mach_m68010:	  N_SET_MACHTYPE (*execp, M_68010);	  break;	default:	case bfd_mach_m68020:	  N_SET_MACHTYPE (*execp, M_68020);	  break;	}      break;    case bfd_arch_sparc:      switch (bfd_get_mach (abfd))	{	case bfd_mach_sparc_sparclet:	  N_SET_MACHTYPE (*execp, M_SPARCLET);	  break;	case bfd_mach_sparc_sparclite_le:	  N_SET_MACHTYPE (*execp, M_SPARCLITE_LE);	  break;	default:	  N_SET_MACHTYPE (*execp, M_SPARC);	  break;	}      break;    case bfd_arch_i386:      N_SET_MACHTYPE (*execp, M_386);      break;    case bfd_arch_a29k:      N_SET_MACHTYPE (*execp, M_29K);      break;    default:      N_SET_MACHTYPE (*execp, M_UNKNOWN);    }  choose_reloc_size (abfd);  N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);  N_SET_DYNAMIC (*execp, bfd_get_file_flags (abfd) & DYNAMIC);  WRITE_HEADERS (abfd, execp);  return true;}/* core files */#define CORE_MAGIC 0x080456#define CORE_NAMELEN 16/* The core structure is taken from the Sun documentation.  Unfortunately, they don't document the FPA structure, or at least I  can't find it easily.  Fortunately the core header contains its own  length.  So this shouldn't cause problems, except for c_ucode, which  so far we don't use but is easy to find with a little arithmetic.  *//* But the reg structure can be gotten from the SPARC processor handbook.  This really should be in a GNU include file though so that gdb can use  the same info.  */struct regs{  int r_psr;  int r_pc;  int r_npc;  int r_y;  int r_g1;  int r_g2;  int r_g3;  int r_g4;  int r_g5;  int r_g6;  int r_g7;  int r_o0;  int r_o1;  int r_o2;  int r_o3;  int r_o4;  int r_o5;  int r_o6;  int r_o7;};/* Taken from Sun documentation: *//* FIXME:  It's worse than we expect.  This struct contains TWO substructs  neither of whose size we know, WITH STUFF IN BETWEEN THEM!  We can't  even portably access the stuff in between!  */struct external_sparc_core  {    int c_magic;		/* Corefile magic number */    int c_len;			/* Sizeof (struct core) */#define	SPARC_CORE_LEN	432    int c_regs[19];		/* General purpose registers -- MACHDEP SIZE */    struct external_exec c_aouthdr;	/* A.out header */    int c_signo;		/* Killing signal, if any */    int c_tsize;		/* Text size (bytes) */    int c_dsize;		/* Data size (bytes) */    int c_ssize;		/* Stack size (bytes) */    char c_cmdname[CORE_NAMELEN + 1];	/* Command name */    double fp_stuff[1];		/* external FPU state (size unknown by us) */    /* The type "double" is critical here, for alignment.    SunOS declares a struct here, but the struct's alignment      is double since it contains doubles.  */    int c_ucode;		/* Exception no. from u_code */    /* (this member is not accessible by name since we don't    portably know the size of fp_stuff.) */  };/* Core files generated by the BCP (the part of Solaris which allows   it to run SunOS4 a.out files).  */struct external_solaris_bcp_core  {    int c_magic;		/* Corefile magic number */    int c_len;			/* Sizeof (struct core) */#define	SOLARIS_BCP_CORE_LEN	456    int c_regs[19];		/* General purpose registers -- MACHDEP SIZE */    int c_exdata_vp;		/* exdata structure */    int c_exdata_tsize;    int c_exdata_dsize;    int c_exdata_bsize;    int c_exdata_lsize;    int c_exdata_nshlibs;    short c_exdata_mach;    short c_exdata_mag;    int c_exdata_toffset;    int c_exdata_doffset;    int c_exdata_loffset;    int c_exdata_txtorg;    int c_exdata_datorg;    int c_exdata_entloc;    int c_signo;		/* Killing signal, if any */    int c_tsize;		/* Text size (bytes) */    int c_dsize;		/* Data size (bytes) */    int c_ssize;		/* Stack size (bytes) */    char c_cmdname[CORE_NAMELEN + 1];	/* Command name */    double fp_stuff[1];		/* external FPU state (size unknown by us) */    /* The type "double" is critical here, for alignment.    SunOS declares a struct here, but the struct's alignment      is double since it contains doubles.  */    int c_ucode;		/* Exception no. from u_code */    /* (this member is not accessible by name since we don't    portably know the size of fp_stuff.) */  };struct external_sun3_core  {    int c_magic;		/* Corefile magic number */    int c_len;			/* Sizeof (struct core) */#define	SUN3_CORE_LEN	826	/* As of SunOS 4.1.1 */    int c_regs[18];		/* General purpose registers -- MACHDEP SIZE */    struct external_exec c_aouthdr;	/* A.out header */    int c_signo;		/* Killing signal, if any */    int c_tsize;		/* Text size (bytes) */    int c_dsize;		/* Data size (bytes) */    int c_ssize;		/* Stack size (bytes) */    char c_cmdname[CORE_NAMELEN + 1];	/* Command name */    double fp_stuff[1];		/* external FPU state (size unknown by us) */    /* The type "double" is critical here, for alignment.    SunOS declares a struct here, but the struct's alignment      is double since it contains doubles.  */    int c_ucode;		/* Exception no. from u_code */    /* (this member is not accessible by name since we don't    portably know the size of fp_stuff.) */  };struct internal_sunos_core  {    int c_magic;		/* Corefile magic number */    int c_len;			/* Sizeof (struct core) */    long c_regs_pos;		/* file offset of General purpose registers */    int c_regs_size;		/* size of General purpose registers */    struct internal_exec c_aouthdr;	/* A.out header */    int c_signo;		/* Killing signal, if any */    int c_tsize;		/* Text size (bytes) */    int c_dsize;		/* Data size (bytes) */    bfd_vma c_data_addr;	/* Data start (address) */    int c_ssize;		/* Stack size (bytes) */    bfd_vma c_stacktop;		/* Stack top (address) */    char c_cmdname[CORE_NAMELEN + 1];	/* Command name */    long fp_stuff_pos;		/* file offset of external FPU state (regs) */    int fp_stuff_size;		/* Size of it */    int c_ucode;		/* Exception no. from u_code */  };static void swapcore_sun3  PARAMS ((bfd *, char *, struct internal_sunos_core *));static void swapcore_sparc  PARAMS ((bfd *, char *, struct internal_sunos_core *));static void swapcore_solaris_bcp  PARAMS ((bfd *, char *, struct internal_sunos_core *));/* byte-swap in the Sun-3 core structure */static voidswapcore_sun3 (abfd, ext, intcore)     bfd *abfd;     char *ext;     struct internal_sunos_core *intcore;{  struct external_sun3_core *extcore = (struct external_sun3_core *) ext;  intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);  intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);  intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);  intcore->c_regs_size = sizeof (extcore->c_regs);#if ARCH_SIZE == 64  aout_64_swap_exec_header_in

⌨️ 快捷键说明

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