]>
Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | /* BFD back-end definitions used by all NetBSD targets. |
2 | Copyright (C) 1990, 91, 92, 94, 95, 96, 97, 1998 | |
3 | Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of BFD, the Binary File Descriptor library. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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, | |
20 | USA. */ | |
21 | ||
22 | /* Check for our machine type (part of magic number). */ | |
23 | #ifndef MACHTYPE_OK | |
24 | #define MACHTYPE_OK(m) ((m) == DEFAULT_MID || (m) == M_UNKNOWN) | |
25 | #endif | |
26 | ||
27 | /* This is the normal load address for executables. */ | |
28 | #define TEXT_START_ADDR TARGET_PAGE_SIZE | |
29 | ||
30 | /* NetBSD ZMAGIC has its header in the text segment. */ | |
31 | #define N_HEADER_IN_TEXT(x) 1 | |
32 | ||
33 | /* Determine if this is a shared library using the flags. */ | |
34 | #define N_SHARED_LIB(x) (N_DYNAMIC(x)) | |
35 | ||
36 | /* We have 6 bits of flags and 10 bits of machine ID. */ | |
37 | #define N_MACHTYPE(exec) \ | |
38 | ((enum machine_type)(((exec).a_info >> 16) & 0x03ff)) | |
39 | #define N_FLAGS(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) << 24)) | |
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 NetBSD, the magic number is always in ntohl's "network" (big-endian) | |
59 | format. */ | |
60 | #define SWAP_MAGIC(ext) bfd_getb32 (ext) | |
61 | ||
62 | /* On NetBSD, the entry point may be taken to be the start of the text | |
63 | section. */ | |
64 | #define MY_entry_is_text_address 1 | |
65 | ||
66 | #define MY_write_object_contents MY(write_object_contents) | |
67 | static boolean MY(write_object_contents) PARAMS ((bfd *abfd)); | |
68 | #define MY_text_includes_header 1 | |
69 | ||
70 | #include "aout-target.h" | |
71 | ||
72 | /* Write an object file. | |
73 | Section contents have already been written. We write the | |
74 | file header, symbols, and relocation. */ | |
75 | ||
76 | static boolean | |
77 | MY(write_object_contents) (abfd) | |
78 | bfd *abfd; | |
79 | { | |
80 | struct external_exec exec_bytes; | |
81 | struct internal_exec *execp = exec_hdr (abfd); | |
82 | ||
83 | /* We must make certain that the magic number has been set. This | |
84 | will normally have been done by set_section_contents, but only if | |
85 | there actually are some section contents. */ | |
86 | if (! abfd->output_has_begun) | |
87 | { | |
88 | bfd_size_type text_size; | |
89 | file_ptr text_end; | |
90 | ||
91 | NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); | |
92 | } | |
93 | ||
94 | #if CHOOSE_RELOC_SIZE | |
95 | CHOOSE_RELOC_SIZE(abfd); | |
96 | #else | |
97 | obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; | |
98 | #endif | |
99 | ||
100 | /* Magic number, maestro, please! */ | |
101 | switch (bfd_get_arch(abfd)) { | |
102 | case DEFAULT_ARCH: | |
103 | N_SET_MACHTYPE(*execp, DEFAULT_MID); | |
104 | break; | |
105 | default: | |
106 | N_SET_MACHTYPE(*execp, M_UNKNOWN); | |
107 | break; | |
108 | } | |
109 | ||
110 | /* The NetBSD magic number is always big-endian */ | |
111 | #ifndef TARGET_IS_BIG_ENDIAN_P | |
112 | /* XXX aren't there any macro to change byteorder of a word independent of | |
113 | the host's or target's endianesses? */ | |
114 | execp->a_info | |
115 | = (execp->a_info & 0xff) << 24 | (execp->a_info & 0xff00) << 8 | |
116 | | (execp->a_info & 0xff0000) >> 8 | (execp->a_info & 0xff000000) >> 24; | |
117 | #endif | |
118 | ||
119 | WRITE_HEADERS(abfd, execp); | |
120 | ||
121 | return true; | |
122 | } |