1
/* BFD back-end definitions used by all FreeBSD targets.
2
Copyright 1990, 1991, 1992, 1996, 1997, 2000, 2001
3
Free Software Foundation, Inc.
5
This file is part of BFD, the Binary File Descriptor library.
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
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
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.
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
19
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
/* FreeBSD ZMAGIC files never have the header in the text. */
23
#define N_HEADER_IN_TEXT(x) 0
25
/* ZMAGIC files start at offset 0. Does not apply to QMAGIC files. */
26
#define TEXT_START_ADDR 0
28
#define N_GETMAGIC_NET(exec) \
29
((exec).a_info & 0xffff)
30
#define N_GETMID_NET(exec) \
31
(((exec).a_info >> 16) & 0x3ff)
32
#define N_GETFLAG_NET(ex) \
33
(((exec).a_info >> 26) & 0x3f)
35
#define N_MACHTYPE(exec) \
36
((enum machine_type) \
37
((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETMID_NET (exec) : \
38
((exec).a_info >> 16) & 0x3ff))
39
#define N_FLAGS(exec) \
40
((N_GETMAGIC_NET (exec) == ZMAGIC) ? N_GETFLAG_NET (exec) : \
41
((exec).a_info >> 26) & 0x3f)
43
#define N_SET_INFO(exec, magic, type, flags) \
44
((exec).a_info = ((magic) & 0xffff) \
45
| (((int)(type) & 0x3ff) << 16) \
46
| (((flags) & 0x3f) << 26))
47
#define N_SET_MACHTYPE(exec, machtype) \
49
((exec).a_info & 0xfb00ffff) | ((((int)(machtype))&0x3ff) << 16))
50
#define N_SET_FLAGS(exec, flags) \
52
((exec).a_info & 0x03ffffff) | ((flags & 0x03f) << 26))
59
/* On FreeBSD, the magic number is always in i386 (little-endian)
61
#define SWAP_MAGIC(ext) bfd_getl32 (ext)
63
#define MY_write_object_contents MY(write_object_contents)
64
static boolean MY(write_object_contents) PARAMS ((bfd *abfd));
66
#include "aout-target.h"
68
/* Write an object file.
69
Section contents have already been written. We write the
70
file header, symbols, and relocation. */
73
MY(write_object_contents) (abfd)
76
struct external_exec exec_bytes;
77
struct internal_exec *execp = exec_hdr (abfd);
79
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
81
/* Magic number, maestro, please! */
82
switch (bfd_get_arch(abfd)) {
84
if (strcmp (abfd->xvec->name, "a.out-m68k4k-netbsd") == 0)
85
N_SET_MACHTYPE(*execp, M_68K4K_NETBSD);
87
N_SET_MACHTYPE(*execp, M_68K_NETBSD);
90
N_SET_MACHTYPE(*execp, M_SPARC_NETBSD);
93
N_SET_MACHTYPE(*execp, M_386_NETBSD);
96
N_SET_MACHTYPE(*execp, M_532_NETBSD);
99
N_SET_MACHTYPE(*execp, M_UNKNOWN);
103
WRITE_HEADERS(abfd, execp);