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/i386os9k.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for os9000 i386 binaries.
    2    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999
     2   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001, 2002
    33   Free Software Foundation, Inc.
    44   Written by Cygnus Support.
     
    2828#include "os9k.h"
    2929
    30 static const bfd_target *os9k_callback PARAMS ((bfd *));
     30static const bfd_target * os9k_callback
     31  PARAMS ((bfd *));
     32static const bfd_target * os9k_object_p
     33  PARAMS ((bfd *));
     34static int os9k_sizeof_headers
     35  PARAMS ((bfd *, bfd_boolean));
     36bfd_boolean os9k_swap_exec_header_in
     37  PARAMS ((bfd *, mh_com *, struct internal_exec *));
    3138
    3239/* Swaps the information in an executable header taken from a raw byte
    3340   stream memory image, into the internal exec_header structure.  */
    34 boolean
     41bfd_boolean
    3542os9k_swap_exec_header_in (abfd, raw_bytes, execp)
    3643     bfd *abfd;
     
    4249
    4350  /* Now fill in fields in the execp, from the bytes in the raw data.  */
    44   execp->a_info = bfd_h_get_16 (abfd, bytes->m_sync);
     51  execp->a_info = H_GET_16 (abfd, bytes->m_sync);
    4552  execp->a_syms = 0;
    46   execp->a_entry = bfd_h_get_32 (abfd, bytes->m_exec);
     53  execp->a_entry = H_GET_32 (abfd, bytes->m_exec);
    4754  execp->a_talign = 2;
    4855  execp->a_dalign = 2;
    4956  execp->a_balign = 2;
    5057
    51   dload = bfd_h_get_32 (abfd, bytes->m_idata);
     58  dload = H_GET_32 (abfd, bytes->m_idata);
    5259  execp->a_data = dload + 8;
    5360
    5461  if (bfd_seek (abfd, (file_ptr) dload, SEEK_SET) != 0
    55       || (bfd_read (&dmemstart, sizeof (dmemstart), 1, abfd)
     62      || (bfd_bread (&dmemstart, (bfd_size_type) sizeof (dmemstart), abfd)
    5663          != sizeof (dmemstart))
    57       || (bfd_read (&dmemsize, sizeof (dmemsize), 1, abfd)
     64      || (bfd_bread (&dmemsize, (bfd_size_type) sizeof (dmemsize), abfd)
    5865          != sizeof (dmemsize)))
    59     return false;
     66    return FALSE;
    6067
    6168  execp->a_tload = 0;
    62   execp->a_dload = bfd_h_get_32 (abfd, (unsigned char *) &dmemstart);
     69  execp->a_dload = H_GET_32 (abfd, (unsigned char *) &dmemstart);
    6370  execp->a_text = dload - execp->a_tload;
    64   execp->a_data = bfd_h_get_32 (abfd, (unsigned char *) &dmemsize);
    65   execp->a_bss = bfd_h_get_32 (abfd, bytes->m_data) - execp->a_data;
     71  execp->a_data = H_GET_32 (abfd, (unsigned char *) &dmemsize);
     72  execp->a_bss = H_GET_32 (abfd, bytes->m_data) - execp->a_data;
    6673
    6774  execp->a_trsize = 0;
    6875  execp->a_drsize = 0;
    6976
    70   return true;
     77  return TRUE;
    7178}
    7279
     
    7582   supplied buffer ready for writing to disk.  */
    7683
    77 PROTO (void, os9k_swap_exec_header_out,
    78          (bfd * abfd,
    79           struct internal_exec * execp,
    80           struct mh_com * raw_bytes));
     84void os9k_swap_exec_header_out
     85  PARAMS ((bfd *, struct internal_exec *, struct mh_com *));
     86
    8187void
    8288os9k_swap_exec_header_out (abfd, execp, raw_bytes)
     
    8894
    8995  /* Now fill in fields in the raw data, from the fields in the exec struct. */
    90   bfd_h_put_32 (abfd, execp->a_info, bytes->e_info);
    91   bfd_h_put_32 (abfd, execp->a_text, bytes->e_text);
    92   bfd_h_put_32 (abfd, execp->a_data, bytes->e_data);
    93   bfd_h_put_32 (abfd, execp->a_bss, bytes->e_bss);
    94   bfd_h_put_32 (abfd, execp->a_syms, bytes->e_syms);
    95   bfd_h_put_32 (abfd, execp->a_entry, bytes->e_entry);
    96   bfd_h_put_32 (abfd, execp->a_trsize, bytes->e_trsize);
    97   bfd_h_put_32 (abfd, execp->a_drsize, bytes->e_drsize);
    98   bfd_h_put_32 (abfd, execp->a_tload, bytes->e_tload);
    99   bfd_h_put_32 (abfd, execp->a_dload, bytes->e_dload);
     96  H_PUT_32 (abfd, execp->a_info, bytes->e_info);
     97  H_PUT_32 (abfd, execp->a_text, bytes->e_text);
     98  H_PUT_32 (abfd, execp->a_data, bytes->e_data);
     99  H_PUT_32 (abfd, execp->a_bss, bytes->e_bss);
     100  H_PUT_32 (abfd, execp->a_syms, bytes->e_syms);
     101  H_PUT_32 (abfd, execp->a_entry, bytes->e_entry);
     102  H_PUT_32 (abfd, execp->a_trsize, bytes->e_trsize);
     103  H_PUT_32 (abfd, execp->a_drsize, bytes->e_drsize);
     104  H_PUT_32 (abfd, execp->a_tload, bytes->e_tload);
     105  H_PUT_32 (abfd, execp->a_dload, bytes->e_dload);
    100106  bytes->e_talign[0] = execp->a_talign;
    101107  bytes->e_dalign[0] = execp->a_dalign;
     
    113119  mh_com exec_bytes;
    114120
    115   if (bfd_read ((PTR) & exec_bytes, MHCOM_BYTES_SIZE, 1, abfd)
     121  if (bfd_bread ((PTR) &exec_bytes, (bfd_size_type) MHCOM_BYTES_SIZE, abfd)
    116122      != MHCOM_BYTES_SIZE)
    117123    {
     
    121127    }
    122128
    123   anexec.a_info = bfd_h_get_16 (abfd, exec_bytes.m_sync);
     129  anexec.a_info = H_GET_16 (abfd, exec_bytes.m_sync);
    124130  if (N_BADMAG (anexec))
    125131    {
     
    148154  unsigned long bss_start;
    149155
    150   /* Architecture and machine type */
     156  /* Architecture and machine type. */
    151157  bfd_set_arch_mach (abfd, bfd_arch_i386, 0);
    152158
     
    155161  obj_sym_filepos (abfd) = 0;
    156162
    157   /* The alignments of the sections */
     163  /* The alignments of the sections. */
    158164  obj_textsec (abfd)->alignment_power = execp->a_talign;
    159165  obj_datasec (abfd)->alignment_power = execp->a_dalign;
     
    164170  obj_datasec (abfd)->vma = execp->a_dload;
    165171
    166   /* And reload the sizes, since the aout module zaps them */
     172  /* And reload the sizes, since the aout module zaps them. */
    167173  obj_textsec (abfd)->_raw_size = execp->a_text;
    168174
    169   bss_start = execp->a_dload + execp->a_data;   /* BSS = end of data section */
     175  bss_start = execp->a_dload + execp->a_data;   /* BSS = end of data section. */
    170176  obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign);
    171177
    172   /* The file positions of the sections */
     178  /* The file positions of the sections. */
    173179  obj_textsec (abfd)->filepos = execp->a_entry;
    174180  obj_datasec (abfd)->filepos = execp->a_dload;
     
    176182  /* The file positions of the relocation info ***
    177183  obj_textsec (abfd)->rel_filepos = N_TROFF(*execp);
    178   obj_datasec (abfd)->rel_filepos =  N_DROFF(*execp);
    179   */
    180 
    181   adata (abfd).page_size = 1;   /* Not applicable. */
    182   adata (abfd).segment_size = 1;/* Not applicable. */
     184  obj_datasec (abfd)->rel_filepos =  N_DROFF(*execp);  */
     185
     186  adata (abfd).page_size = 1;   /* Not applicable.  */
     187  adata (abfd).segment_size = 1;/* Not applicable.  */
    183188  adata (abfd).exec_bytes_size = MHCOM_BYTES_SIZE;
    184189
     
    193198};
    194199
    195 static boolean
     200static bfd_boolean
    196201os9k_mkobject (abfd)
    197202     bfd *abfd;
    198203{
    199204  struct bout_data_struct *rawptr;
    200 
    201   rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
     205  bfd_size_type amt = sizeof (struct bout_data_struct);
     206
     207  rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, amt);
    202208  if (rawptr == NULL)
    203     return false;
     209    return FALSE;
    204210
    205211  abfd->tdata.bout_data = rawptr;
     
    210216  obj_bsssec (abfd) = (asection *) NULL;
    211217
    212   return true;
    213 }
    214 
    215 static boolean
     218  return TRUE;
     219}
     220
     221static bfd_boolean
    216222os9k_write_object_contents (abfd)
    217223     bfd *abfd;
     
    220226
    221227  if (! aout_32_make_sections (abfd))
    222     return false;
     228    return FALSE;
    223229
    224230  exec_hdr (abfd)->a_info = BMAGIC;
     
    244250
    245251  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
    246       || (bfd_write ((PTR) & swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
    247           != EXEC_BYTES_SIZE))
    248     return false;
    249 
    250   /* Now write out reloc info, followed by syms and strings */
     252      || bfd_bwrite ((PTR) & swapped_hdr, (bfd_size_type) EXEC_BYTES_SIZE,
     253                    abfd) != EXEC_BYTES_SIZE)
     254    return FALSE;
     255
     256  /* Now write out reloc info, followed by syms and strings. */
    251257  if (bfd_get_symcount (abfd) != 0)
    252258    {
    253259      if (bfd_seek (abfd, (file_ptr) (N_SYMOFF (*exec_hdr (abfd))), SEEK_SET)
    254260          != 0)
    255         return false;
     261        return FALSE;
    256262
    257263      if (!aout_32_write_syms (abfd))
    258         return false;
     264        return FALSE;
    259265
    260266      if (bfd_seek (abfd, (file_ptr) (N_TROFF (*exec_hdr (abfd))), SEEK_SET)
    261267          != 0)
    262         return false;
     268        return FALSE;
    263269
    264270      if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd)))
    265         return false;
     271        return FALSE;
    266272      if (bfd_seek (abfd, (file_ptr) (N_DROFF (*exec_hdr (abfd))), SEEK_SET)
    267273          != 0)
    268         return false;
     274        return FALSE;
    269275
    270276      if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd)))
    271         return false;
    272     }
    273   return true;
    274 }
    275 
    276 
    277 static boolean
     277        return FALSE;
     278    }
     279  return TRUE;
     280}
     281
     282
     283static bfd_boolean
    278284os9k_set_section_contents (abfd, section, location, offset, count)
    279285     bfd *abfd;
     
    284290{
    285291
    286   if (abfd->output_has_begun == false)
     292  if (! abfd->output_has_begun)
    287293    {                           /* set by bfd.c handler */
    288294      if (! aout_32_make_sections (abfd))
    289         return false;
     295        return FALSE;
    290296
    291297      obj_textsec (abfd)->filepos = sizeof (struct internal_exec);
     
    294300
    295301    }
    296   /* regardless, once we know what we're doing, we might as well get going */
     302  /* Regardless, once we know what we're doing, we might as well get going. */
    297303  if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
    298     return false;
     304    return FALSE;
    299305
    300306  if (count != 0)
    301     {
    302       return (bfd_write ((PTR) location, 1, count, abfd) == count) ? true : false;
    303     }
    304   return true;
     307    return bfd_bwrite ((PTR) location, (bfd_size_type) count, abfd) == count;
     308
     309  return TRUE;
    305310}
    306311#endif  /* 0 */
     
    309314os9k_sizeof_headers (ignore_abfd, ignore)
    310315     bfd *ignore_abfd ATTRIBUTE_UNUSED;
    311      boolean ignore ATTRIBUTE_UNUSED;
     316     bfd_boolean ignore ATTRIBUTE_UNUSED;
    312317{
    313318  return sizeof (struct internal_exec);
     
    315320
    316321
    317 /***********************************************************************/
     322
    318323
    319324#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
     
    330335#define os9k_bfd_relax_section bfd_generic_relax_section
    331336#define os9k_bfd_gc_sections bfd_generic_gc_sections
     337#define os9k_bfd_merge_sections bfd_generic_merge_sections
     338#define os9k_bfd_discard_group bfd_generic_discard_group
    332339#define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
     340#define os9k_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
    333341#define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols
     342#define os9k_bfd_link_just_syms _bfd_generic_link_just_syms
    334343#define os9k_bfd_final_link _bfd_generic_final_link
    335344#define os9k_bfd_link_split_section  _bfd_generic_link_split_section
    336345
    337346const bfd_target i386os9k_vec =
    338 {
    339   "i386os9k",                   /* name */
    340   bfd_target_os9k_flavour,
    341   BFD_ENDIAN_LITTLE,            /* data byte order is little */
    342   BFD_ENDIAN_LITTLE,            /* hdr byte order is little */
    343   (HAS_RELOC | EXEC_P | WP_TEXT),       /* object flags */
    344   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD),    /* section flags */
    345   0,                            /* symbol leading char */
    346   ' ',                          /* ar_pad_char */
    347   16,                           /* ar_max_namelen */
    348 
    349   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
    350   bfd_getl32, bfd_getl_signed_32, bfd_putl32,
    351   bfd_getl16, bfd_getl_signed_16, bfd_putl16,   /* data */
    352   bfd_getl64, bfd_getl_signed_64, bfd_putl64,
    353   bfd_getl32, bfd_getl_signed_32, bfd_putl32,
    354   bfd_getl16, bfd_getl_signed_16, bfd_putl16,   /* hdrs */
    355   {_bfd_dummy_target, os9k_object_p,    /* bfd_check_format */
    356    bfd_generic_archive_p, _bfd_dummy_target},
    357   {bfd_false, bfd_false,        /* bfd_set_format */
    358    _bfd_generic_mkarchive, bfd_false},
    359   {bfd_false, bfd_false,        /* bfd_write_contents */
    360    _bfd_write_archive_contents, bfd_false},
    361 
    362      BFD_JUMP_TABLE_GENERIC (aout_32),
    363      BFD_JUMP_TABLE_COPY (_bfd_generic),
    364      BFD_JUMP_TABLE_CORE (_bfd_nocore),
    365      BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
    366      BFD_JUMP_TABLE_SYMBOLS (aout_32),
    367      BFD_JUMP_TABLE_RELOCS (aout_32),
    368      BFD_JUMP_TABLE_WRITE (aout_32),
    369      BFD_JUMP_TABLE_LINK (os9k),
    370      BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
    371 
    372   NULL,
    373  
    374   (PTR) 0,
    375 };
     347  {
     348    "i386os9k",                 /* name */
     349    bfd_target_os9k_flavour,
     350    BFD_ENDIAN_LITTLE,          /* data byte order is little */
     351    BFD_ENDIAN_LITTLE,          /* hdr byte order is little */
     352    (HAS_RELOC | EXEC_P | WP_TEXT),     /* object flags */
     353    (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD),  /* section flags */
     354    0,                          /* symbol leading char */
     355    ' ',                                /* ar_pad_char */
     356    16,                         /* ar_max_namelen */
     357
     358    bfd_getl64, bfd_getl_signed_64, bfd_putl64,
     359    bfd_getl32, bfd_getl_signed_32, bfd_putl32,
     360    bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
     361    bfd_getl64, bfd_getl_signed_64, bfd_putl64,
     362    bfd_getl32, bfd_getl_signed_32, bfd_putl32,
     363    bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
     364    {_bfd_dummy_target, os9k_object_p,  /* bfd_check_format */
     365     bfd_generic_archive_p, _bfd_dummy_target},
     366    {bfd_false, bfd_false,      /* bfd_set_format */
     367     _bfd_generic_mkarchive, bfd_false},
     368    {bfd_false, bfd_false,      /* bfd_write_contents */
     369     _bfd_write_archive_contents, bfd_false},
     370
     371    BFD_JUMP_TABLE_GENERIC (aout_32),
     372    BFD_JUMP_TABLE_COPY (_bfd_generic),
     373    BFD_JUMP_TABLE_CORE (_bfd_nocore),
     374    BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
     375    BFD_JUMP_TABLE_SYMBOLS (aout_32),
     376    BFD_JUMP_TABLE_RELOCS (aout_32),
     377    BFD_JUMP_TABLE_WRITE (aout_32),
     378    BFD_JUMP_TABLE_LINK (os9k),
     379    BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
     380
     381    NULL,
     382
     383    (PTR) 0,
     384  };
Note: See TracChangeset for help on using the changeset viewer.