Thu May 21 18:00:09 1992 Michael Tiemann (tiemann@rtl.cygnus.com)
[deliverable/binutils-gdb.git] / bfd / i386aout.c
CommitLineData
6a469027
JG
1/* BFD back-end for i386 a.out binaries.
2 Copyright (C) 1990, 1991 Free Software Foundation, Inc.
3
4This file is part of BFD, the Binary File Descriptor library.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, 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
6a469027 26#include "bfd.h"
600d4864 27#include "sysdep.h"
6a469027
JG
28#include "libbfd.h"
29#include "aout64.h"
6a469027
JG
30#include "stab.gnu.h"
31#include "ar.h"
32#include "libaout.h" /* BFD a.out internal data structures */
33
34bfd_target *aout386_callback ();
35
36bfd_target *
37DEFUN(aout386_object_p,(abfd),
38 bfd *abfd)
39{
40 struct external_exec exec_bytes;
41 struct internal_exec exec;
42
43 if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
44 != EXEC_BYTES_SIZE) {
45 bfd_error = wrong_format;
46 return 0;
47 }
48
49 exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
50
51 if (N_BADMAG (exec)) return 0;
52
53 NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
54 return aout_32_some_aout_object_p (abfd, &exec, aout386_callback);
55}
56
57/* Finish up the reading of the file header */
58bfd_target *
59DEFUN(aout386_callback,(abfd),
60 bfd *abfd)
61{
62 struct internal_exec *execp = exec_hdr (abfd);
63
64 WORK_OUT_FILE_POSITIONS(abfd, execp) ;
65
66 /* Determine the architecture and machine type of the object file. */
67 bfd_default_set_arch_mach(abfd, bfd_arch_i386, 0);
68
69 return abfd->xvec;
70}
71
72/* Write an object file.
73 Section contents have already been written. We write the
74 file header, symbols, and relocation. */
75
76boolean
77DEFUN(aout386_write_object_contents,(abfd),
78 bfd *abfd)
79{
80 bfd_size_type data_pad = 0;
81 struct external_exec exec_bytes;
82 struct internal_exec *execp = exec_hdr (abfd);
83
84 WRITE_HEADERS(abfd, execp);
85 return true;
86}
87\f
88/* Transfer vector */
89
90/* We use BSD archive files. */
91#define aout386_openr_next_archived_file bfd_generic_openr_next_archived_file
92#define aout386_generic_stat_arch_elt bfd_generic_stat_arch_elt
93#define aout386_slurp_armap bfd_slurp_bsd_armap
94#define aout386_slurp_extended_name_table bfd_true
95#define aout386_write_armap bsd_write_armap
96#define aout386_truncate_arname bfd_bsd_truncate_arname
97
98/* We don't support core files here. */
99#define aout386_core_file_failing_command _bfd_dummy_core_file_failing_command
100#define aout386_core_file_failing_signal _bfd_dummy_core_file_failing_signal
101#define aout386_core_file_matches_executable_p \
102 _bfd_dummy_core_file_matches_executable_p
103#define aout386_core_file_p _bfd_dummy_target
104
105#define aout386_bfd_debug_info_start bfd_void
106#define aout386_bfd_debug_info_end bfd_void
107#define aout386_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
108
109#define aout386_mkobject aout_32_mkobject
110#define aout386_close_and_cleanup aout_32_close_and_cleanup
111#define aout386_set_section_contents aout_32_set_section_contents
112#define aout386_get_section_contents aout_32_get_section_contents
113#define aout386_new_section_hook aout_32_new_section_hook
114#define aout386_get_symtab_upper_bound aout_32_get_symtab_upper_bound
115#define aout386_get_symtab aout_32_get_symtab
116#define aout386_get_reloc_upper_bound aout_32_get_reloc_upper_bound
117#define aout386_canonicalize_reloc aout_32_canonicalize_reloc
118#define aout386_make_empty_symbol aout_32_make_empty_symbol
119#define aout386_print_symbol aout_32_print_symbol
120#define aout386_get_lineno aout_32_get_lineno
121#define aout386_set_arch_mach aout_32_set_arch_mach
122#define aout386_find_nearest_line aout_32_find_nearest_line
123#define aout386_sizeof_headers aout_32_sizeof_headers
124
125bfd_target i386aout_vec = /* Intel 386 running a.out, embedded. */
126{
127 "a.out-i386", /* name */
128 bfd_target_aout_flavour,
129 false, /* target byte order */
130 false, /* target headers byte order */
131 (HAS_RELOC | EXEC_P | /* object flags */
132 HAS_LINENO | HAS_DEBUG |
133 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
134 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
135 ' ', /* ar_pad_char */
136 16, /* ar_max_namelen */
137 1, /* minimum alignment */
138 /* data swap routines */
139 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16,
140 /* header swap routines */
141 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16,
142
143 {_bfd_dummy_target, aout386_object_p, /* bfd_check_format */
144 bfd_generic_archive_p, aout386_core_file_p},
145 {bfd_false, aout386_mkobject, /* bfd_set_format */
146 _bfd_generic_mkarchive, bfd_false},
147 {bfd_false, aout386_write_object_contents, /* bfd_write_contents */
148 _bfd_write_archive_contents, bfd_false},
149
150 JUMP_TABLE(aout386)
151};
This page took 0.040938 seconds and 4 git commands to generate.