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

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for i386 a.out binaries under LynxOS.
    2    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996
     2   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2001, 2002, 2003
    33   Free Software Foundation, Inc.
    44
     
    1919Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    2020
    21 #define BYTES_IN_WORD 4
    2221#define N_SHARED_LIB(x) 0
    2322
     
    2726#define DEFAULT_ARCH bfd_arch_i386
    2827
    29 #define MY(OP) CAT(i386lynx_aout_,OP)
     28/* Do not "beautify" the CONCAT* macro args.  Traditional C will not
     29   remove whitespace added here, and thus will fail to concatenate
     30   the tokens.  */
     31#define MY(OP) CONCAT2 (i386lynx_aout_,OP)
    3032#define TARGETNAME "a.out-i386-lynx"
    3133
     
    5153        NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes);           \
    5254                                                                              \
    53         if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false;       \
    54         if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)          \
    55             != EXEC_BYTES_SIZE)                                               \
    56           return false;                                                       \
     55        if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0                      \
     56            || bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \
     57                          abfd) != EXEC_BYTES_SIZE)                           \
     58          return FALSE;                                                       \
    5759        /* Now write out reloc info, followed by syms and strings */          \
    5860                                                                              \
    5961        if (bfd_get_symcount (abfd) != 0)                                     \
    6062            {                                                                 \
    61               if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET)     \
     63              if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET)    \
    6264                  != 0)                                                       \
    63                 return false;                                                 \
     65                return FALSE;                                                 \
    6466                                                                              \
    65               if (! NAME(aout,write_syms)(abfd)) return false;                \
     67              if (! NAME(aout,write_syms) (abfd)) return FALSE;               \
    6668                                                                              \
    67               if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET)    \
     69              if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET)   \
    6870                  != 0)                                                       \
    69                 return false;                                                 \
     71                return FALSE;                                                 \
    7072                                                                              \
    7173              if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd)))   \
    72                 return false;                                                 \
    73               if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET)    \
     74                return FALSE;                                                 \
     75              if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET)   \
    7476                  != 0)                                                       \
    7577                return 0;                                                     \
    7678                                                                              \
    77               if (!NAME(lynx,squirt_out_relocs)(abfd, obj_datasec (abfd)))    \
    78                 return false;                                                 \
     79              if (!NAME(lynx,squirt_out_relocs) (abfd, obj_datasec (abfd)))   \
     80                return FALSE;                                                 \
    7981            }                                                                 \
    8082      }
     
    8486#include "aout/aout64.h"
    8587
     88void NAME (lynx,swap_std_reloc_out)
     89  PARAMS ((bfd *, arelent *, struct reloc_std_external *));
     90void NAME (lynx,swap_ext_reloc_out)
     91  PARAMS ((bfd *, arelent *, struct reloc_ext_external *));
     92void NAME (lynx,swap_ext_reloc_in)
     93  PARAMS ((bfd *, struct reloc_ext_external *, arelent *, asymbol **,
     94           bfd_size_type));
     95void NAME (lynx,swap_std_reloc_in)
     96  PARAMS ((bfd *, struct reloc_std_external *, arelent *, asymbol **,
     97           bfd_size_type));
     98bfd_boolean NAME (lynx,slurp_reloc_table)
     99  PARAMS ((bfd *, sec_ptr, asymbol **));
     100bfd_boolean NAME (lynx,squirt_out_relocs)
     101  PARAMS ((bfd *, asection *));
     102long NAME (lynx,canonicalize_reloc)
     103  PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
     104
    86105#ifdef LYNX_CORE
    87106
    88107char *lynx_core_file_failing_command ();
    89108int lynx_core_file_failing_signal ();
    90 boolean lynx_core_file_matches_executable_p ();
     109bfd_boolean lynx_core_file_matches_executable_p ();
    91110const bfd_target *lynx_core_file_p ();
    92111
     
    142161     from the abs section, or as a symbol which has an abs value.
    143162     check for that here
    144      */
     163  */
    145164
    146165
     
    152171        {
    153172          /* Whoops, looked like an abs symbol, but is really an offset
    154            from the abs section */
     173             from the abs section */
    155174          r_index = 0;
    156175          r_extern = 0;
     
    360379  struct aoutdata *su = &(abfd->tdata.aout_data->a);
    361380
    362   cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
     381  cache_ptr->address = H_GET_32 (abfd, bytes->r_address);
    363382
    364383  r_index = bytes->r_index[1];
     
    379398/* Reloc hackery */
    380399
    381 boolean
     400bfd_boolean
    382401NAME(lynx,slurp_reloc_table) (abfd, asect, symbols)
    383402     bfd *abfd;
     
    385404     asymbol **symbols;
    386405{
    387   unsigned int count;
     406  bfd_size_type count;
    388407  bfd_size_type reloc_size;
    389408  PTR relocs;
     
    392411
    393412  if (asect->relocation)
    394     return true;
     413    return TRUE;
    395414
    396415  if (asect->flags & SEC_CONSTRUCTOR)
    397     return true;
     416    return TRUE;
    398417
    399418  if (asect == obj_datasec (abfd))
     
    410429
    411430  bfd_set_error (bfd_error_invalid_operation);
    412   return false;
     431  return FALSE;
    413432
    414433doit:
    415434  if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
    416     return false;
     435    return FALSE;
    417436  each_size = obj_reloc_entry_size (abfd);
    418437
     
    420439
    421440
    422   reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
     441  reloc_cache = (arelent *) bfd_zmalloc (count * sizeof (arelent));
    423442  if (!reloc_cache && count != 0)
    424     return false;
    425   memset (reloc_cache, 0, count * sizeof (arelent));
     443    return FALSE;
    426444
    427445  relocs = (PTR) bfd_alloc (abfd, reloc_size);
     
    429447    {
    430448      free (reloc_cache);
    431       return false;
    432     }
    433 
    434   if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
     449      return FALSE;
     450    }
     451
     452  if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)
    435453    {
    436454      bfd_release (abfd, relocs);
    437455      free (reloc_cache);
    438       return false;
     456      return FALSE;
    439457    }
    440458
     
    448466        {
    449467          NAME(lynx,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols,
    450                                         bfd_get_symcount (abfd));
     468                                        (bfd_size_type) bfd_get_symcount (abfd));
    451469        }
    452470    }
     
    460478        {
    461479          NAME(lynx,swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
    462                                         bfd_get_symcount (abfd));
     480                                        (bfd_size_type) bfd_get_symcount (abfd));
    463481        }
    464482
     
    468486  asect->relocation = reloc_cache;
    469487  asect->reloc_count = count;
    470   return true;
     488  return TRUE;
    471489}
    472490
     
    475493/* Write out a relocation section into an object file.  */
    476494
    477 boolean
     495bfd_boolean
    478496NAME(lynx,squirt_out_relocs) (abfd, section)
    479497     bfd *abfd;
     
    485503
    486504  unsigned int count = section->reloc_count;
    487   size_t natsize;
     505  bfd_size_type natsize;
    488506
    489507  if (count == 0)
    490     return true;
     508    return TRUE;
    491509
    492510  each_size = obj_reloc_entry_size (abfd);
    493   natsize = each_size * count;
     511  natsize = count;
     512  natsize *= each_size;
    494513  native = (unsigned char *) bfd_zalloc (abfd, natsize);
    495514  if (!native)
    496     return false;
     515    return FALSE;
    497516
    498517  generic = section->orelocation;
     
    513532    }
    514533
    515   if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
     534  if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
    516535    {
    517536      bfd_release (abfd, native);
    518       return false;
     537      return FALSE;
    519538    }
    520539  bfd_release (abfd, native);
    521540
    522   return true;
     541  return TRUE;
    523542}
    524543
Note: See TracChangeset for help on using the changeset viewer.