]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* BFD back-end definitions used by all FreeBSD targets. |
6f2750fe | 2 | Copyright (C) 1990-2016 Free Software Foundation, Inc. |
252b5132 | 3 | |
116c20d2 | 4 | This file is part of BFD, the Binary File Descriptor library. |
252b5132 | 5 | |
116c20d2 NC |
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 | |
cd123cb7 | 8 | the Free Software Foundation; either version 3 of the License, or |
116c20d2 | 9 | (at your option) any later version. |
252b5132 | 10 | |
116c20d2 NC |
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. | |
252b5132 | 15 | |
116c20d2 NC |
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 | |
cd123cb7 NC |
18 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
19 | MA 02110-1301, USA. */ | |
20 | ||
252b5132 RH |
21 | |
22 | /* FreeBSD ZMAGIC files never have the header in the text. */ | |
23 | #define N_HEADER_IN_TEXT(x) 0 | |
24 | ||
25 | /* ZMAGIC files start at offset 0. Does not apply to QMAGIC files. */ | |
26 | #define TEXT_START_ADDR 0 | |
27 | ||
bbb1afc8 AM |
28 | #define N_GETMAGIC_NET(execp) \ |
29 | ((execp)->a_info & 0xffff) | |
30 | #define N_GETMID_NET(execp) \ | |
31 | (((execp)->a_info >> 16) & 0x3ff) | |
32 | #define N_GETFLAG_NET(exexp) \ | |
33 | (((execp)->a_info >> 26) & 0x3f) | |
34 | ||
35 | #define N_MACHTYPE(execp) \ | |
252b5132 | 36 | ((enum machine_type) \ |
bbb1afc8 AM |
37 | ((N_GETMAGIC_NET (execp) == ZMAGIC) ? N_GETMID_NET (execp) : \ |
38 | ((execp)->a_info >> 16) & 0x3ff)) | |
39 | #define N_FLAGS(execp) \ | |
40 | ((N_GETMAGIC_NET (execp) == ZMAGIC) ? N_GETFLAG_NET (execp) : \ | |
41 | ((execp)->a_info >> 26) & 0x3f) | |
42 | ||
43 | #define N_SET_INFO(execp, magic, type, flags) \ | |
44 | ((execp)->a_info = ((magic) & 0xffff) \ | |
252b5132 RH |
45 | | (((int)(type) & 0x3ff) << 16) \ |
46 | | (((flags) & 0x3f) << 26)) | |
bbb1afc8 AM |
47 | #define N_SET_MACHTYPE(execp, machtype) \ |
48 | ((execp)->a_info = \ | |
49 | ((execp)->a_info & 0xfb00ffff) | ((((int) (machtype)) & 0x3ff) << 16)) | |
50 | #define N_SET_FLAGS(execp, flags) \ | |
51 | ((execp)->a_info = \ | |
52 | ((execp)->a_info & 0x03ffffff) | ((flags & 0x03f) << 26)) | |
252b5132 | 53 | |
252b5132 | 54 | #include "sysdep.h" |
3db64b00 | 55 | #include "bfd.h" |
252b5132 RH |
56 | #include "libbfd.h" |
57 | #include "libaout.h" | |
58 | ||
59 | /* On FreeBSD, the magic number is always in i386 (little-endian) | |
60 | format. I think. */ | |
61 | #define SWAP_MAGIC(ext) bfd_getl32 (ext) | |
62 | ||
116c20d2 NC |
63 | #define MY_write_object_contents MY (write_object_contents) |
64 | static bfd_boolean MY (write_object_contents) (bfd *); | |
252b5132 RH |
65 | |
66 | #include "aout-target.h" | |
67 | ||
68 | /* Write an object file. | |
69 | Section contents have already been written. We write the | |
70 | file header, symbols, and relocation. */ | |
71 | ||
b34976b6 | 72 | static bfd_boolean |
116c20d2 | 73 | MY (write_object_contents) (bfd *abfd) |
252b5132 RH |
74 | { |
75 | struct external_exec exec_bytes; | |
76 | struct internal_exec *execp = exec_hdr (abfd); | |
77 | ||
252b5132 | 78 | obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; |
252b5132 RH |
79 | |
80 | /* Magic number, maestro, please! */ | |
116c20d2 NC |
81 | switch (bfd_get_arch(abfd)) |
82 | { | |
83 | case bfd_arch_m68k: | |
84 | if (strcmp (abfd->xvec->name, "a.out-m68k4k-netbsd") == 0) | |
bbb1afc8 | 85 | N_SET_MACHTYPE (execp, M_68K4K_NETBSD); |
116c20d2 | 86 | else |
bbb1afc8 | 87 | N_SET_MACHTYPE (execp, M_68K_NETBSD); |
116c20d2 NC |
88 | break; |
89 | case bfd_arch_sparc: | |
bbb1afc8 | 90 | N_SET_MACHTYPE (execp, M_SPARC_NETBSD); |
116c20d2 NC |
91 | break; |
92 | case bfd_arch_i386: | |
bbb1afc8 | 93 | N_SET_MACHTYPE (execp, M_386_NETBSD); |
116c20d2 NC |
94 | break; |
95 | case bfd_arch_ns32k: | |
bbb1afc8 | 96 | N_SET_MACHTYPE (execp, M_532_NETBSD); |
116c20d2 NC |
97 | break; |
98 | default: | |
bbb1afc8 | 99 | N_SET_MACHTYPE (execp, M_UNKNOWN); |
116c20d2 NC |
100 | break; |
101 | } | |
252b5132 | 102 | |
bbb1afc8 | 103 | WRITE_HEADERS (abfd, execp); |
252b5132 | 104 | |
b34976b6 | 105 | return TRUE; |
252b5132 | 106 | } |