Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/aoutf1.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* A.out "format 1" file handling code for BFD.
    2    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000
     2   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
     3   2001, 2002
    34   Free Software Foundation, Inc.
    45   Written by Cygnus Support.
     
    7576#endif
    7677
    77 static boolean sunos_merge_private_bfd_data PARAMS ((bfd *, bfd *));
    78 static void sunos_set_arch_mach PARAMS ((bfd *, int));
    79 static void choose_reloc_size PARAMS ((bfd *));
    80 static boolean sunos_write_object_contents PARAMS ((bfd *));
    81 static const bfd_target *sunos4_core_file_p PARAMS ((bfd *));
    82 static char *sunos4_core_file_failing_command PARAMS ((bfd *));
    83 static int sunos4_core_file_failing_signal PARAMS ((bfd *));
    84 static boolean sunos4_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
    85 static boolean sunos4_set_sizes PARAMS ((bfd *));
     78static bfd_boolean sunos_merge_private_bfd_data
     79  PARAMS ((bfd *, bfd *));
     80static void sunos_set_arch_mach
     81  PARAMS ((bfd *, enum machine_type));
     82static void choose_reloc_size
     83  PARAMS ((bfd *));
     84static bfd_boolean sunos_write_object_contents
     85  PARAMS ((bfd *));
     86static const bfd_target *sunos4_core_file_p
     87  PARAMS ((bfd *));
     88static char *sunos4_core_file_failing_command
     89  PARAMS ((bfd *));
     90static int sunos4_core_file_failing_signal
     91  PARAMS ((bfd *));
     92static bfd_boolean sunos4_core_file_matches_executable_p
     93  PARAMS ((bfd *, bfd *));
     94static bfd_boolean sunos4_set_sizes
     95  PARAMS ((bfd *));
    8696
    8797/* Merge backend data into the output file.
     
    91101#define MY_bfd_merge_private_bfd_data sunos_merge_private_bfd_data
    92102
    93 static boolean
     103static bfd_boolean
    94104sunos_merge_private_bfd_data (ibfd, obfd)
    95105     bfd *ibfd, *obfd;
     
    97107  if (bfd_get_flavour (ibfd) != bfd_target_aout_flavour
    98108      || bfd_get_flavour (obfd) != bfd_target_aout_flavour)
    99     return true;
     109    return TRUE;
    100110
    101111  if (bfd_get_arch (obfd) == bfd_arch_sparc)
     
    105115    }
    106116
    107   return true;
     117  return TRUE;
    108118}
    109119
     
    114124sunos_set_arch_mach (abfd, machtype)
    115125     bfd *abfd;
    116      int machtype;
     126     enum machine_type machtype;
    117127{
    118128  /* Determine the architecture and machine type of the object file.  */
    119129  enum bfd_architecture arch;
    120   long machine;
     130  unsigned long machine;
    121131  switch (machtype)
    122132    {
     
    207217   aout_32_sunos4_write_object_contents, depending upon ARCH_SIZE.  */
    208218
    209 static boolean
     219static bfd_boolean
    210220sunos_write_object_contents (abfd)
    211221     bfd *abfd;
     
    260270  N_SET_FLAGS (*execp, aout_backend_info (abfd)->exec_hdr_flags);
    261271
    262   N_SET_DYNAMIC (*execp, bfd_get_file_flags (abfd) & DYNAMIC);
     272  N_SET_DYNAMIC (*execp, (long)(bfd_get_file_flags (abfd) & DYNAMIC));
    263273
    264274  WRITE_HEADERS (abfd, execp);
    265275
    266   return true;
     276  return TRUE;
    267277}
    268278
     
    424434  struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
    425435
    426   intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
    427   intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
     436  intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
     437  intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
    428438  intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
    429439  intcore->c_regs_size = sizeof (extcore->c_regs);
     
    434444#endif
    435445    (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
    436   intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
    437   intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
    438   intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
     446  intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
     447  intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
     448  intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
    439449  intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
    440   intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
     450  intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
    441451  memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
    442452  intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff);
     
    445455    (file_ptr) (((struct external_sun3_core *) 0)->fp_stuff);
    446456  /* Ucode is the last thing in the struct -- just before the end */
    447   intcore->c_ucode =
    448     bfd_h_get_32 (abfd,
    449     intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
     457  intcore->c_ucode = H_GET_32 (abfd,
     458                               (intcore->c_len
     459                                - sizeof (extcore->c_ucode)
     460                                + (unsigned char *) extcore));
    450461  intcore->c_stacktop = 0x0E000000;     /* By experimentation */
    451462}
     
    460471  struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
    461472
    462   intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
    463   intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
     473  intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
     474  intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
    464475  intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
    465476  intcore->c_regs_size = sizeof (extcore->c_regs);
     
    470481#endif
    471482    (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
    472   intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
    473   intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
    474   intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
     483  intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
     484  intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
     485  intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
    475486  intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
    476   intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
     487  intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
    477488  memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
    478489  intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff);
     
    481492    (file_ptr) (((struct external_sparc_core *) 0)->fp_stuff);
    482493  /* Ucode is the last thing in the struct -- just before the end */
    483   intcore->c_ucode =
    484     bfd_h_get_32 (abfd,
    485     intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
     494  intcore->c_ucode = H_GET_32 (abfd,
     495                               (intcore->c_len
     496                                - sizeof (extcore->c_ucode)
     497                                + (unsigned char *) extcore));
    486498
    487499  /* Supposedly the user stack grows downward from the bottom of kernel memory.
     
    501513#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
    502514  {
    503     bfd_vma sp = bfd_h_get_32
    504     (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
     515    bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
    505516    if (sp < SPARC_USRSTACK_SPARC10)
    506517      intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
     
    520531    (struct external_solaris_bcp_core *) ext;
    521532
    522   intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
    523   intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
     533  intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
     534  intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
    524535  intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs);
    525536  intcore->c_regs_size = sizeof (extcore->c_regs);
     
    536547     start address.  */
    537548  memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
    538   intcore->c_data_addr =
    539     bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg);
    540   intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
    541   intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
    542   intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
    543   intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
     549  intcore->c_data_addr = H_GET_32 (abfd, &extcore->c_exdata_datorg);
     550  intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
     551  intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
     552  intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
     553  intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
    544554  memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
    545555  intcore->fp_stuff_pos =
     
    549559    (file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
    550560  /* Ucode is the last thing in the struct -- just before the end */
    551   intcore->c_ucode =
    552     bfd_h_get_32 (abfd,
    553     intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
     561  intcore->c_ucode = H_GET_32 (abfd,
     562                               (intcore->c_len
     563                                - sizeof (extcore->c_ucode)
     564                                + (unsigned char *) extcore));
    554565
    555566  /* Supposedly the user stack grows downward from the bottom of kernel memory.
     
    569580#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
    570581  {
    571     bfd_vma sp = bfd_h_get_32
    572     (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
     582    bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
    573583    if (sp < SPARC_USRSTACK_SPARC10)
    574584      intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
     
    600610{
    601611  unsigned char longbuf[4];     /* Raw bytes of various header fields */
    602   bfd_size_type core_size;
     612  bfd_size_type core_size, amt;
    603613  unsigned long core_mag;
    604614  struct internal_sunos_core *core;
     
    609619      struct internal_sunos_core internal_sunos_core;
    610620      char external_core[1];
    611     }
    612    *mergem;
    613 
    614   if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
    615       sizeof (longbuf))
     621    } *mergem;
     622
     623  if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
     624      != sizeof (longbuf))
    616625    return 0;
    617   core_mag = bfd_h_get_32 (abfd, longbuf);
     626  core_mag = H_GET_32 (abfd, longbuf);
    618627
    619628  if (core_mag != CORE_MAGIC)
     
    621630
    622631  /* SunOS core headers can vary in length; second word is size; */
    623   if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
    624       sizeof (longbuf))
     632  if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
     633      != sizeof (longbuf))
    625634    return 0;
    626   core_size = bfd_h_get_32 (abfd, longbuf);
     635  core_size = H_GET_32 (abfd, longbuf);
    627636  /* Sanity check */
    628637  if (core_size > 20000)
    629638    return 0;
    630639
    631   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
     640  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
    632641    return 0;
    633642
    634   mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem));
     643  amt = core_size + sizeof (struct mergem);
     644  mergem = (struct mergem *) bfd_zalloc (abfd, amt);
    635645  if (mergem == NULL)
    636646    return 0;
     
    638648  extcore = mergem->external_core;
    639649
    640   if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size)
     650  if ((bfd_bread ((PTR) extcore, core_size, abfd)) != core_size)
    641651    {
     652    loser:
    642653      bfd_release (abfd, (char *) mergem);
     654      abfd->tdata.any = NULL;
     655      bfd_section_list_clear (abfd);
    643656      return 0;
    644657    }
     
    661674    default:
    662675      bfd_set_error (bfd_error_system_call);    /* FIXME */
    663       bfd_release (abfd, (char *) mergem);
    664       return 0;
     676      goto loser;
    665677    }
    666678
     
    668680  abfd->tdata.sun_core_data->hdr = core;
    669681
    670   /* create the sections.  This is raunchy, but bfd_close wants to reclaim
    671      them */
    672   core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
     682  /* Create the sections.  */
     683  core_stacksec (abfd) = bfd_make_section_anyway (abfd, ".stack");
    673684  if (core_stacksec (abfd) == NULL)
    674     {
    675     loser:
    676       bfd_release (abfd, (char *) mergem);
    677       return 0;
    678     }
    679   core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
     685    /* bfd_release frees everything allocated after it's arg.  */
     686    goto loser;
     687
     688  core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data");
    680689  if (core_datasec (abfd) == NULL)
    681     {
    682     loser1:
    683       bfd_release (abfd, core_stacksec (abfd));
    684       goto loser;
    685     }
    686   core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
     690    goto loser;
     691
     692  core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg");
    687693  if (core_regsec (abfd) == NULL)
    688     {
    689     loser2:
    690       bfd_release (abfd, core_datasec (abfd));
    691       goto loser1;
    692     }
    693   core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
     694    goto loser;
     695
     696  core_reg2sec (abfd) = bfd_make_section_anyway (abfd, ".reg2");
    694697  if (core_reg2sec (abfd) == NULL)
    695     {
    696       bfd_release (abfd, core_regsec (abfd));
    697       goto loser2;
    698     }
    699 
    700   core_stacksec (abfd)->name = ".stack";
    701   core_datasec (abfd)->name = ".data";
    702   core_regsec (abfd)->name = ".reg";
    703   core_reg2sec (abfd)->name = ".reg2";
     698    goto loser;
    704699
    705700  core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
     
    730725  core_reg2sec (abfd)->alignment_power = 2;
    731726
    732   abfd->sections = core_stacksec (abfd);
    733   core_stacksec (abfd)->next = core_datasec (abfd);
    734   core_datasec (abfd)->next = core_regsec (abfd);
    735   core_regsec (abfd)->next = core_reg2sec (abfd);
    736 
    737   abfd->section_count = 4;
    738 
    739727  return abfd->xvec;
    740728}
     
    754742}
    755743
    756 static boolean
     744static bfd_boolean
    757745sunos4_core_file_matches_executable_p (core_bfd, exec_bfd)
    758746     bfd *core_bfd;
     
    762750    {
    763751      bfd_set_error (bfd_error_system_call);
    764       return false;
     752      return FALSE;
    765753    }
    766754
    767755  /* Solaris core files do not include an aouthdr.  */
    768756  if ((core_hdr (core_bfd)->hdr)->c_len == SOLARIS_BCP_CORE_LEN)
    769     return true;
     757    return TRUE;
    770758
    771759  return (memcmp ((char *) &((core_hdr (core_bfd)->hdr)->c_aouthdr),
    772760                  (char *) exec_hdr (exec_bfd),
    773                   sizeof (struct internal_exec)) == 0) ? true : false;
     761                  sizeof (struct internal_exec)) == 0);
    774762}
    775763
    776764#define MY_set_sizes sunos4_set_sizes
    777 static boolean
     765static bfd_boolean
    778766sunos4_set_sizes (abfd)
    779767     bfd *abfd;
     
    782770    {
    783771    default:
    784       return false;
     772      return FALSE;
    785773    case bfd_arch_sparc:
    786774      adata (abfd).page_size = 0x2000;
    787775      adata (abfd).segment_size = 0x2000;
    788776      adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
    789       return true;
     777      return TRUE;
    790778    case bfd_arch_m68k:
    791779      adata (abfd).page_size = 0x2000;
    792780      adata (abfd).segment_size = 0x20000;
    793781      adata (abfd).exec_bytes_size = EXEC_BYTES_SIZE;
    794       return true;
     782      return TRUE;
    795783    }
    796784}
     
    824812#endif
    825813
    826 static CONST struct aout_backend_data sunos4_aout_backend =
     814static const struct aout_backend_data sunos4_aout_backend =
    827815{
    828816  0,                            /* zmagic files are not contiguous */
Note: See TracChangeset for help on using the changeset viewer.