* elflink.c (is_reloc_section): New function. Returns true if the
[deliverable/binutils-gdb.git] / bfd / freebsd.h
CommitLineData
252b5132 1/* BFD back-end definitions used by all FreeBSD targets.
3db64b00 2 Copyright 1990, 1991, 1992, 1996, 1997, 2000, 2001, 2002, 2005, 2007
7898deda 3 Free Software Foundation, Inc.
252b5132 4
116c20d2 5 This file is part of BFD, the Binary File Descriptor library.
252b5132 6
116c20d2
NC
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
cd123cb7 9 the Free Software Foundation; either version 3 of the License, or
116c20d2 10 (at your option) any later version.
252b5132 11
116c20d2
NC
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
252b5132 16
116c20d2
NC
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
cd123cb7
NC
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
21
252b5132
RH
22
23/* FreeBSD ZMAGIC files never have the header in the text. */
24#define N_HEADER_IN_TEXT(x) 0
25
26/* ZMAGIC files start at offset 0. Does not apply to QMAGIC files. */
27#define TEXT_START_ADDR 0
28
29#define N_GETMAGIC_NET(exec) \
30 ((exec).a_info & 0xffff)
31#define N_GETMID_NET(exec) \
32 (((exec).a_info >> 16) & 0x3ff)
33#define N_GETFLAG_NET(ex) \
34 (((exec).a_info >> 26) & 0x3f)
35
36#define N_MACHTYPE(exec) \
37 ((enum machine_type) \
38 ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETMID_NET (exec) : \
39 ((exec).a_info >> 16) & 0x3ff))
40#define N_FLAGS(exec) \
41 ((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETFLAG_NET (exec) : \
42 ((exec).a_info >> 26) & 0x3f)
43
44#define N_SET_INFO(exec, magic, type, flags) \
45 ((exec).a_info = ((magic) & 0xffff) \
46 | (((int)(type) & 0x3ff) << 16) \
47 | (((flags) & 0x3f) << 26))
48#define N_SET_MACHTYPE(exec, machtype) \
49 ((exec).a_info = \
116c20d2 50 ((exec).a_info & 0xfb00ffff) | ((((int) (machtype)) & 0x3ff) << 16))
252b5132
RH
51#define N_SET_FLAGS(exec, flags) \
52 ((exec).a_info = \
53 ((exec).a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
54
252b5132 55#include "sysdep.h"
3db64b00 56#include "bfd.h"
252b5132
RH
57#include "libbfd.h"
58#include "libaout.h"
59
60/* On FreeBSD, the magic number is always in i386 (little-endian)
61 format. I think. */
62#define SWAP_MAGIC(ext) bfd_getl32 (ext)
63
116c20d2
NC
64#define MY_write_object_contents MY (write_object_contents)
65static bfd_boolean MY (write_object_contents) (bfd *);
252b5132
RH
66
67#include "aout-target.h"
68
69/* Write an object file.
70 Section contents have already been written. We write the
71 file header, symbols, and relocation. */
72
b34976b6 73static bfd_boolean
116c20d2 74MY (write_object_contents) (bfd *abfd)
252b5132
RH
75{
76 struct external_exec exec_bytes;
77 struct internal_exec *execp = exec_hdr (abfd);
78
252b5132 79 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
252b5132
RH
80
81 /* Magic number, maestro, please! */
116c20d2
NC
82 switch (bfd_get_arch(abfd))
83 {
84 case bfd_arch_m68k:
85 if (strcmp (abfd->xvec->name, "a.out-m68k4k-netbsd") == 0)
86 N_SET_MACHTYPE (*execp, M_68K4K_NETBSD);
87 else
88 N_SET_MACHTYPE (*execp, M_68K_NETBSD);
89 break;
90 case bfd_arch_sparc:
91 N_SET_MACHTYPE (*execp, M_SPARC_NETBSD);
92 break;
93 case bfd_arch_i386:
94 N_SET_MACHTYPE (*execp, M_386_NETBSD);
95 break;
96 case bfd_arch_ns32k:
97 N_SET_MACHTYPE (*execp, M_532_NETBSD);
98 break;
99 default:
100 N_SET_MACHTYPE (*execp, M_UNKNOWN);
101 break;
102 }
252b5132
RH
103
104 WRITE_HEADERS(abfd, execp);
105
b34976b6 106 return TRUE;
252b5132 107}
This page took 0.464267 seconds and 4 git commands to generate.