* trad-core.c, bfd.c, ../include/bfd.h: Various fixes for PMAX
[deliverable/binutils-gdb.git] / bfd / aout-target.h
1 /* Define a target vector for a variant of a.out.
2 Copyright (C) 1990-1991 Free Software Foundation, Inc.
3
4 This file is part of BFD, the Binary File Descriptor library.
5
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
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
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.
15
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
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 /* Set parameters about this a.out file that are machine-dependent.
21 This routine is called from some_aout_object_p just before it returns. */
22 static bfd_target *
23 DEFUN(MY(callback),(abfd),
24 bfd *abfd)
25 {
26 struct internal_exec *execp = exec_hdr (abfd);
27
28 /* Calculate the file positions of the parts of a newly read aout header */
29 obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp);
30
31 /* The virtual memory addresses of the sections */
32 obj_textsec (abfd)->vma = N_TXTADDR(*execp);
33 obj_datasec (abfd)->vma = N_DATADDR(*execp);
34 obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
35
36 /* The file offsets of the sections */
37 obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
38 obj_datasec (abfd)->filepos = N_DATOFF (*execp);
39
40 /* The file offsets of the relocation info */
41 obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
42 obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
43
44 /* The file offsets of the string table and symbol table. */
45 obj_sym_filepos (abfd) = N_SYMOFF (*execp);
46 obj_str_filepos (abfd) = N_STROFF (*execp);
47
48 /* Determine the architecture and machine type of the object file.
49 */
50 #ifdef SET_ARCH_MACH
51 SET_ARCH_MACH(abfd, *execp);
52 #else
53 bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0);
54 #endif
55
56 adata(abfd).page_size = PAGE_SIZE;
57 #ifdef SEGMENT_SIZE
58 adata(abfd).segment_size = SEGMENT_SIZE;
59 #else
60 adata(abfd).segment_size = PAGE_SIZE;
61 #endif
62 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
63
64 return abfd->xvec;
65 }
66
67 #ifndef MY_object_p
68 /* Finish up the reading of an a.out file header */
69
70 static bfd_target *
71 DEFUN(MY(object_p),(abfd),
72 bfd *abfd)
73 {
74 struct external_exec exec_bytes; /* Raw exec header from file */
75 struct internal_exec exec; /* Cleaned-up exec header */
76 bfd_target *target;
77
78 if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
79 != EXEC_BYTES_SIZE) {
80 bfd_error = wrong_format;
81 return 0;
82 }
83
84 exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
85
86 if (N_BADMAG (exec)) return 0;
87
88 NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
89 target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
90
91 #ifdef ENTRY_CAN_BE_ZERO
92 /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
93 * means that it isn't obvious if EXEC_P should be set.
94 * All of the following must be true for an executable:
95 * There must be no relocations, the bfd can be neither an
96 * archive nor an archive element, and the file must be executable. */
97
98 if (exec.a_trsize + exec.a_drsize == 0
99 && bfd_get_format(abfd) == bfd_object && abfd->my_archive == NULL)
100 {
101 struct stat buf;
102 #ifndef S_IXUSR
103 #define S_IXUSR 0100 /* Execute by owner. */
104 #endif
105 if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
106 abfd->flags |= EXEC_P;
107 }
108 #endif /* ENTRY_CAN_BE_ZERO */
109
110 return target;
111 }
112 #define MY_object_p MY(object_p)
113 #endif
114
115
116 #ifndef MY_mkobject
117 static boolean
118 DEFUN(MY(mkobject),(abfd),
119 bfd *abfd)
120 {
121 if (NAME(aout,mkobject)(abfd) == false)
122 return false;
123 adata(abfd).page_size = PAGE_SIZE;
124 #ifdef SEGMENT_SIZE
125 adata(abfd).segment_size = SEGMENT_SIZE;
126 #else
127 adata(abfd).segment_size = PAGE_SIZE;
128 #endif
129 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
130 return true;
131 }
132 #define MY_mkobject MY(mkobject)
133 #endif
134
135 /* Write an object file.
136 Section contents have already been written. We write the
137 file header, symbols, and relocation. */
138
139 #ifndef MY_write_object_contents
140 static boolean
141 DEFUN(MY(write_object_contents),(abfd),
142 bfd *abfd)
143 {
144 bfd_size_type data_pad = 0;
145 struct external_exec exec_bytes;
146 struct internal_exec *execp = exec_hdr (abfd);
147
148 WRITE_HEADERS(abfd, execp);
149 return true;
150 }
151 #define MY_write_object_contents MY(write_object_contents)
152 #endif
153
154 /* We assume BFD generic archive files. */
155 #ifndef MY_openr_next_archived_file
156 #define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
157 #endif
158 #ifndef MY_generic_stat_arch_elt
159 #define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
160 #endif
161 #ifndef MY_slurp_armap
162 #define MY_slurp_armap bfd_slurp_bsd_armap
163 #endif
164 #ifndef MY_slurp_extended_name_table
165 #define MY_slurp_extended_name_table bfd_true
166 #endif
167 #ifndef MY_write_armap
168 #define MY_write_armap bsd_write_armap
169 #endif
170 #ifndef MY_truncate_arname
171 #define MY_truncate_arname bfd_bsd_truncate_arname
172 #endif
173
174 /* No core file defined here -- configure in trad-core.c separately. */
175 #ifndef MY_core_file_failing_command
176 #define MY_core_file_failing_command _bfd_dummy_core_file_failing_command
177 #endif
178 #ifndef MY_core_file_failing_signal
179 #define MY_core_file_failing_signal _bfd_dummy_core_file_failing_signal
180 #endif
181 #ifndef MY_core_file_matches_executable_p
182 #define MY_core_file_matches_executable_p \
183 _bfd_dummy_core_file_matches_executable_p
184 #endif
185 #ifndef MY_core_file_p
186 #define MY_core_file_p _bfd_dummy_target
187 #endif
188
189 #ifndef MY_bfd_debug_info_start
190 #define MY_bfd_debug_info_start bfd_void
191 #endif
192 #ifndef MY_bfd_debug_info_end
193 #define MY_bfd_debug_info_end bfd_void
194 #endif
195 #ifndef MY_bfd_debug_info_accumulate
196 #define MY_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
197 #endif
198
199 #ifndef MY_core_file_failing_command
200 #define MY_core_file_failing_command NAME(aout,core_file_failing_command)
201 #endif
202 #ifndef MY_core_file_failing_signal
203 #define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
204 #endif
205 #ifndef MY_core_file_matches_executable_p
206 #define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
207 #endif
208 #ifndef MY_slurp_armap
209 #define MY_slurp_armap NAME(aout,slurp_armap)
210 #endif
211 #ifndef MY_slurp_extended_name_table
212 #define MY_slurp_extended_name_table NAME(aout,slurp_extended_name_table)
213 #endif
214 #ifndef MY_truncate_arname
215 #define MY_truncate_arname NAME(aout,truncate_arname)
216 #endif
217 #ifndef MY_write_armap
218 #define MY_write_armap NAME(aout,write_armap)
219 #endif
220 #ifndef MY_close_and_cleanup
221 #define MY_close_and_cleanup NAME(aout,close_and_cleanup)
222 #endif
223 #ifndef MY_set_section_contents
224 #define MY_set_section_contents NAME(aout,set_section_contents)
225 #endif
226 #ifndef MY_get_section_contents
227 #define MY_get_section_contents NAME(aout,get_section_contents)
228 #endif
229 #ifndef MY_new_section_hook
230 #define MY_new_section_hook NAME(aout,new_section_hook)
231 #endif
232 #ifndef MY_get_symtab_upper_bound
233 #define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
234 #endif
235 #ifndef MY_get_symtab
236 #define MY_get_symtab NAME(aout,get_symtab)
237 #endif
238 #ifndef MY_get_reloc_upper_bound
239 #define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
240 #endif
241 #ifndef MY_canonicalize_reloc
242 #define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
243 #endif
244 #ifndef MY_make_empty_symbol
245 #define MY_make_empty_symbol NAME(aout,make_empty_symbol)
246 #endif
247 #ifndef MY_print_symbol
248 #define MY_print_symbol NAME(aout,print_symbol)
249 #endif
250 #ifndef MY_get_lineno
251 #define MY_get_lineno NAME(aout,get_lineno)
252 #endif
253 #ifndef MY_set_arch_mach
254 #define MY_set_arch_mach NAME(aout,set_arch_mach)
255 #endif
256 #ifndef MY_openr_next_archived_file
257 #define MY_openr_next_archived_file NAME(aout,openr_next_archived_file)
258 #endif
259 #ifndef MY_find_nearest_line
260 #define MY_find_nearest_line NAME(aout,find_nearest_line)
261 #endif
262 #ifndef MY_generic_stat_arch_elt
263 #define MY_generic_stat_arch_elt NAME(aout,generic_stat_arch_elt)
264 #endif
265 #ifndef MY_sizeof_headers
266 #define MY_sizeof_headers NAME(aout,sizeof_headers)
267 #endif
268 #ifndef MY_bfd_debug_info_start
269 #define MY_bfd_debug_info_start NAME(aout,bfd_debug_info_start)
270 #endif
271 #ifndef MY_bfd_debug_info_end
272 #define MY_bfd_debug_info_end NAME(aout,bfd_debug_info_end)
273 #endif
274 #ifndef MY_bfd_debug_info_accumulat
275 #define MY_bfd_debug_info_accumulat NAME(aout,bfd_debug_info_accumulat)
276 #endif
277
278 bfd_target MY(vec) =
279 {
280 TARGETNAME, /* name */
281 bfd_target_aout_flavour,
282 true, /* target byte order */
283 true, /* target headers byte order */
284 (HAS_RELOC | EXEC_P | /* object flags */
285 HAS_LINENO | HAS_DEBUG |
286 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
287 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
288 ' ', /* ar_pad_char */
289 16, /* ar_max_namelen */
290 1, /* minimum alignment */
291 #ifdef TARGET_IS_BIG_ENDIAN_P
292 _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
293 _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
294 #else
295 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
296 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */
297 #endif
298 {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
299 bfd_generic_archive_p, MY_core_file_p},
300 {bfd_false, MY_mkobject, /* bfd_set_format */
301 _bfd_generic_mkarchive, bfd_false},
302 {bfd_false, MY_write_object_contents, /* bfd_write_contents */
303 _bfd_write_archive_contents, bfd_false},
304
305 MY_core_file_failing_command,
306 MY_core_file_failing_signal,
307 MY_core_file_matches_executable_p,
308 MY_slurp_armap,
309 MY_slurp_extended_name_table,
310 MY_truncate_arname,
311 MY_write_armap,
312 MY_close_and_cleanup,
313 MY_set_section_contents,
314 MY_get_section_contents,
315 MY_new_section_hook,
316 MY_get_symtab_upper_bound,
317 MY_get_symtab,
318 MY_get_reloc_upper_bound,
319 MY_canonicalize_reloc,
320 MY_make_empty_symbol,
321 MY_print_symbol,
322 MY_get_lineno,
323 MY_set_arch_mach,
324 MY_openr_next_archived_file,
325 MY_find_nearest_line,
326 MY_generic_stat_arch_elt,
327 MY_sizeof_headers,
328 MY_bfd_debug_info_start,
329 MY_bfd_debug_info_end,
330 MY_bfd_debug_info_accumulate,
331 bfd_generic_get_relocated_section_contents
332 };
This page took 0.036926 seconds and 4 git commands to generate.