Back to index

cell-binutils  2.17cvs20070401
freebsd.h
Go to the documentation of this file.
00001 /* BFD back-end definitions used by all FreeBSD targets.
00002    Copyright 1990, 1991, 1992, 1996, 1997, 2000, 2001, 2002, 2005
00003    Free Software Foundation, Inc.
00004 
00005    This file is part of BFD, the Binary File Descriptor library.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
00020    USA.  */
00021 
00022 /* FreeBSD ZMAGIC files never have the header in the text. */
00023 #define       N_HEADER_IN_TEXT(x)  0
00024 
00025 /* ZMAGIC files start at offset 0.  Does not apply to QMAGIC files. */
00026 #define TEXT_START_ADDR            0
00027 
00028 #define N_GETMAGIC_NET(exec) \
00029        ((exec).a_info & 0xffff)
00030 #define N_GETMID_NET(exec) \
00031        (((exec).a_info >> 16) & 0x3ff)
00032 #define N_GETFLAG_NET(ex) \
00033        (((exec).a_info >> 26) & 0x3f)
00034 
00035 #define N_MACHTYPE(exec) \
00036        ((enum machine_type) \
00037         ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETMID_NET (exec) : \
00038          ((exec).a_info >> 16) & 0x3ff))
00039 #define N_FLAGS(exec) \
00040        ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETFLAG_NET (exec) : \
00041         ((exec).a_info >> 26) & 0x3f)
00042 
00043 #define N_SET_INFO(exec, magic, type, flags) \
00044        ((exec).a_info = ((magic) & 0xffff) \
00045         | (((int)(type) & 0x3ff) << 16) \
00046         | (((flags) & 0x3f) << 26))
00047 #define N_SET_MACHTYPE(exec, machtype) \
00048        ((exec).a_info = \
00049          ((exec).a_info & 0xfb00ffff) | ((((int) (machtype)) & 0x3ff) << 16))
00050 #define N_SET_FLAGS(exec, flags) \
00051        ((exec).a_info = \
00052         ((exec).a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
00053 
00054 #include "bfd.h"
00055 #include "sysdep.h"
00056 #include "libbfd.h"
00057 #include "libaout.h"
00058 
00059 /* On FreeBSD, the magic number is always in i386 (little-endian)
00060    format.  I think.  */
00061 #define SWAP_MAGIC(ext) bfd_getl32 (ext)
00062 
00063 #define MY_write_object_contents MY (write_object_contents)
00064 static bfd_boolean MY (write_object_contents) (bfd *);
00065 
00066 #include "aout-target.h"
00067 
00068 /* Write an object file.
00069    Section contents have already been written.  We write the
00070    file header, symbols, and relocation.  */
00071 
00072 static bfd_boolean
00073 MY (write_object_contents) (bfd *abfd)
00074 {
00075   struct external_exec exec_bytes;
00076   struct internal_exec *execp = exec_hdr (abfd);
00077 
00078   obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
00079 
00080   /* Magic number, maestro, please!  */
00081   switch (bfd_get_arch(abfd))
00082     {
00083     case bfd_arch_m68k:
00084       if (strcmp (abfd->xvec->name, "a.out-m68k4k-netbsd") == 0)
00085        N_SET_MACHTYPE (*execp, M_68K4K_NETBSD);
00086       else
00087        N_SET_MACHTYPE (*execp, M_68K_NETBSD);
00088       break;
00089     case bfd_arch_sparc:
00090       N_SET_MACHTYPE (*execp, M_SPARC_NETBSD);
00091       break;
00092     case bfd_arch_i386:
00093       N_SET_MACHTYPE (*execp, M_386_NETBSD);
00094       break;
00095     case bfd_arch_ns32k:
00096       N_SET_MACHTYPE (*execp, M_532_NETBSD);
00097       break;
00098     default:
00099       N_SET_MACHTYPE (*execp, M_UNKNOWN);
00100       break;
00101     }
00102 
00103   WRITE_HEADERS(abfd, execp);
00104 
00105   return TRUE;
00106 }