]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - bfd/i386aout.c
* Makefile.in: Rename XDEPFILES.
[thirdparty/binutils-gdb.git] / bfd / i386aout.c
1 /* BFD back-end for i386 a.out binaries.
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 #define PAGE_SIZE 4096
21 #define SEGMENT_SIZE PAGE_SIZE
22 #define TEXT_START_ADDR 0x8000
23 #define ARCH 32
24 #define BYTES_IN_WORD 4
25
26 #include <ansidecl.h>
27 #include <sysdep.h>
28 #include "bfd.h"
29 #include "libbfd.h"
30 #include "aout64.h"
31
32 /**From: bothner@cs.wisc.edu***********************************************/
33 #undef N_TXTOFF
34 #define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? PAGE_SIZE : EXEC_BYTES_SIZE)
35 /**************************************************************************/
36
37 #include "stab.gnu.h"
38 #include "ar.h"
39 #include "libaout.h" /* BFD a.out internal data structures */
40
41 bfd_target *aout386_callback ();
42
43 bfd_target *
44 DEFUN(aout386_object_p,(abfd),
45 bfd *abfd)
46 {
47 struct external_exec exec_bytes;
48 struct internal_exec exec;
49
50 if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
51 != EXEC_BYTES_SIZE) {
52 bfd_error = wrong_format;
53 return 0;
54 }
55
56 exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
57
58 if (N_BADMAG (exec)) return 0;
59
60 NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
61 return aout_32_some_aout_object_p (abfd, &exec, aout386_callback);
62 }
63
64 /* Finish up the reading of the file header */
65 bfd_target *
66 DEFUN(aout386_callback,(abfd),
67 bfd *abfd)
68 {
69 struct internal_exec *execp = exec_hdr (abfd);
70
71 WORK_OUT_FILE_POSITIONS(abfd, execp) ;
72
73 /* Determine the architecture and machine type of the object file. */
74 bfd_default_set_arch_mach(abfd, bfd_arch_i386, 0);
75
76 return abfd->xvec;
77 }
78
79 /* Write an object file.
80 Section contents have already been written. We write the
81 file header, symbols, and relocation. */
82
83 boolean
84 DEFUN(aout386_write_object_contents,(abfd),
85 bfd *abfd)
86 {
87 bfd_size_type data_pad = 0;
88 struct external_exec exec_bytes;
89 struct internal_exec *execp = exec_hdr (abfd);
90
91 WRITE_HEADERS(abfd, execp);
92 return true;
93 }
94 \f
95 /* Transfer vector */
96
97 /* We use BSD archive files. */
98 #define aout386_openr_next_archived_file bfd_generic_openr_next_archived_file
99 #define aout386_generic_stat_arch_elt bfd_generic_stat_arch_elt
100 #define aout386_slurp_armap bfd_slurp_bsd_armap
101 #define aout386_slurp_extended_name_table bfd_true
102 #define aout386_write_armap bsd_write_armap
103 #define aout386_truncate_arname bfd_bsd_truncate_arname
104
105 /* We don't support core files here. */
106 #define aout386_core_file_failing_command _bfd_dummy_core_file_failing_command
107 #define aout386_core_file_failing_signal _bfd_dummy_core_file_failing_signal
108 #define aout386_core_file_matches_executable_p \
109 _bfd_dummy_core_file_matches_executable_p
110 #define aout386_core_file_p _bfd_dummy_target
111
112 #define aout386_bfd_debug_info_start bfd_void
113 #define aout386_bfd_debug_info_end bfd_void
114 #define aout386_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
115
116 #define aout386_mkobject aout_32_mkobject
117 #define aout386_close_and_cleanup aout_32_close_and_cleanup
118 #define aout386_set_section_contents aout_32_set_section_contents
119 #define aout386_get_section_contents aout_32_get_section_contents
120 #define aout386_new_section_hook aout_32_new_section_hook
121 #define aout386_get_symtab_upper_bound aout_32_get_symtab_upper_bound
122 #define aout386_get_symtab aout_32_get_symtab
123 #define aout386_get_reloc_upper_bound aout_32_get_reloc_upper_bound
124 #define aout386_canonicalize_reloc aout_32_canonicalize_reloc
125 #define aout386_make_empty_symbol aout_32_make_empty_symbol
126 #define aout386_print_symbol aout_32_print_symbol
127 #define aout386_get_lineno aout_32_get_lineno
128 #define aout386_set_arch_mach aout_32_set_arch_mach
129 #define aout386_find_nearest_line aout_32_find_nearest_line
130 #define aout386_sizeof_headers aout_32_sizeof_headers
131
132 bfd_target i386aout_vec = /* Intel 386 running a.out, embedded. */
133 {
134 "a.out-i386", /* name */
135 bfd_target_aout_flavour,
136 false, /* target byte order */
137 false, /* target headers byte order */
138 (HAS_RELOC | EXEC_P | /* object flags */
139 HAS_LINENO | HAS_DEBUG |
140 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
141 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
142 ' ', /* ar_pad_char */
143 16, /* ar_max_namelen */
144 1, /* minimum alignment */
145 /* data swap routines */
146 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16,
147 /* header swap routines */
148 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16,
149
150 {_bfd_dummy_target, aout386_object_p, /* bfd_check_format */
151 bfd_generic_archive_p, aout386_core_file_p},
152 {bfd_false, aout386_mkobject, /* bfd_set_format */
153 _bfd_generic_mkarchive, bfd_false},
154 {bfd_false, aout386_write_object_contents, /* bfd_write_contents */
155 _bfd_write_archive_contents, bfd_false},
156
157 JUMP_TABLE(aout386)
158 };