home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / gdb-4.14-src.lha / gdb-4.14 / bfd / netbsd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-28  |  2.8 KB  |  99 lines

  1. /* BFD back-end definitions used by all NetBSD targets.
  2.    Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
  3.  
  4. This file is part of BFD, the Binary File Descriptor library.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. /* NetBSD fits its header into the start of its text segment */
  22. #define    N_HEADER_IN_TEXT(x)    1
  23. #define TEXT_START_ADDR        PAGE_SIZE
  24.  
  25. #define N_MACHTYPE(exec) \
  26.     ((enum machine_type)(((exec).a_info >> 16) & 0x03ff))
  27. #define N_FLAGS(exec) \
  28.     (((exec).a_info >> 26) & 0x3f)
  29.  
  30. #define N_SET_INFO(exec, magic, type, flags) \
  31.     ((exec).a_info = ((magic) & 0xffff) \
  32.      | (((int)(type) & 0x3ff) << 16) \
  33.      | (((flags) & 0x3f) << 24))
  34. #define N_SET_MACHTYPE(exec, machtype) \
  35.     ((exec).a_info = \
  36.          ((exec).a_info & 0xfb00ffff) | ((((int)(machtype))&0x3ff) << 16))
  37. #define N_SET_FLAGS(exec, flags) \
  38.     ((exec).a_info = \
  39.      ((exec).a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
  40.  
  41. #include "bfd.h"
  42. #include "sysdep.h"
  43. #include "libbfd.h"
  44. #include "libaout.h"
  45.  
  46. /* On NetBSD, the magic number is always in ntohl's "network" (big-endian)
  47.    format.  */
  48. #define SWAP_MAGIC(ext) bfd_getb32 (ext)
  49.  
  50.  
  51. #define MY_write_object_contents MY(write_object_contents)
  52. static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
  53.  
  54. #include "aout-target.h"
  55.  
  56. /* Write an object file.
  57.    Section contents have already been written.  We write the
  58.    file header, symbols, and relocation.  */
  59.  
  60. static boolean
  61. MY(write_object_contents) (abfd)
  62.      bfd *abfd;
  63. {
  64.   struct external_exec exec_bytes;
  65.   struct internal_exec *execp = exec_hdr (abfd);
  66.  
  67. #if CHOOSE_RELOC_SIZE
  68.   CHOOSE_RELOC_SIZE(abfd);
  69. #else
  70.   obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
  71. #endif
  72.  
  73.   /* Magic number, maestro, please!  */
  74.   switch (bfd_get_arch(abfd)) {
  75.   case bfd_arch_m68k:
  76.     N_SET_MACHTYPE(*execp, M_68K_NETBSD);
  77.     break;
  78.   case bfd_arch_sparc:
  79.     N_SET_MACHTYPE(*execp, M_SPARC_NETBSD);
  80.     break;
  81.   case bfd_arch_i386:
  82.     N_SET_MACHTYPE(*execp, M_386_NETBSD);
  83.     break;
  84.   case bfd_arch_ns32k:
  85.     N_SET_MACHTYPE(*execp, M_532_NETBSD);
  86.     break;
  87.   default:
  88.     N_SET_MACHTYPE(*execp, M_UNKNOWN);
  89.     break;
  90.   }
  91.  
  92.   /* The NetBSD magic number is always big-endian */
  93.   execp->a_info = bfd_getb32((bfd_byte *) &(execp->a_info));
  94.  
  95.   WRITE_HEADERS(abfd, execp);
  96.  
  97.   return true;
  98. }
  99.