home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / binutils-2.7-src.tgz / tar.out / fsf / binutils / bfd / freebsd.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  3KB  |  110 lines

  1. /* BFD back-end definitions used by all FreeBSD targets.
  2.    Copyright (C) 1990, 1991, 1992, 1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20.  
  21. /* FreeBSD ZMAGIC files never have the header in the text. */
  22. #define    N_HEADER_IN_TEXT(x)    0
  23.  
  24. /* ZMAGIC files start at offset 0.  Does not apply to QMAGIC files. */
  25. #define TEXT_START_ADDR        0
  26.  
  27. #define N_GETMAGIC_NET(exec) \
  28.     (ntohl ((exec).a_info) & 0xffff)
  29. #define N_GETMID_NET(exec) \
  30.     ((ntohl ((exec).a_info) >> 16) & 0x3ff)
  31. #define N_GETFLAG_NET(ex) \
  32.     ((ntohl ((exec).a_info) >> 26) & 0x3f)
  33.  
  34. #define N_MACHTYPE(exec) \
  35.     ((enum machine_type) \
  36.      ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETMID_NET (exec) : \
  37.       ((exec).a_info >> 16) & 0x3ff))
  38. #define N_FLAGS(exec) \
  39.     ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETFLAG_NET (exec) : \
  40.      ((exec).a_info >> 26) & 0x3f)
  41.  
  42. #define N_SET_INFO(exec, magic, type, flags) \
  43.     ((exec).a_info = ((magic) & 0xffff) \
  44.      | (((int)(type) & 0x3ff) << 16) \
  45.      | (((flags) & 0x3f) << 26))
  46. #define N_SET_MACHTYPE(exec, machtype) \
  47.     ((exec).a_info = \
  48.          ((exec).a_info & 0xfb00ffff) | ((((int)(machtype))&0x3ff) << 16))
  49. #define N_SET_FLAGS(exec, flags) \
  50.     ((exec).a_info = \
  51.      ((exec).a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
  52.  
  53. #include "bfd.h"
  54. #include "sysdep.h"
  55. #include "libbfd.h"
  56. #include "libaout.h"
  57.  
  58. /* On FreeBSD, the magic number is always in correct endian format */
  59. #define NO_SWAP_MAGIC
  60.  
  61.  
  62. #define MY_write_object_contents MY(write_object_contents)
  63. static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
  64.  
  65. #include "aout-target.h"
  66.  
  67. /* Write an object file.
  68.    Section contents have already been written.  We write the
  69.    file header, symbols, and relocation.  */
  70.  
  71. static boolean
  72. MY(write_object_contents) (abfd)
  73.      bfd *abfd;
  74. {
  75.   struct external_exec exec_bytes;
  76.   struct internal_exec *execp = exec_hdr (abfd);
  77.  
  78. #if CHOOSE_RELOC_SIZE
  79.   CHOOSE_RELOC_SIZE(abfd);
  80. #else
  81.   obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
  82. #endif
  83.  
  84.   /* Magic number, maestro, please!  */
  85.   switch (bfd_get_arch(abfd)) {
  86.   case bfd_arch_m68k:
  87.     if (strcmp (abfd->xvec->name, "a.out-m68k4k-netbsd") == 0)
  88.       N_SET_MACHTYPE(*execp, M_68K4K_NETBSD);
  89.     else
  90.       N_SET_MACHTYPE(*execp, M_68K_NETBSD);
  91.     break;
  92.   case bfd_arch_sparc:
  93.     N_SET_MACHTYPE(*execp, M_SPARC_NETBSD);
  94.     break;
  95.   case bfd_arch_i386:
  96.     N_SET_MACHTYPE(*execp, M_386_NETBSD);
  97.     break;
  98.   case bfd_arch_ns32k:
  99.     N_SET_MACHTYPE(*execp, M_532_NETBSD);
  100.     break;
  101.   default:
  102.     N_SET_MACHTYPE(*execp, M_UNKNOWN);
  103.     break;
  104.   }
  105.  
  106.   WRITE_HEADERS(abfd, execp);
  107.  
  108.   return true;
  109. }
  110.