]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/i386os9k.c
Fix error message typo.
[thirdparty/binutils-gdb.git] / bfd / i386os9k.c
CommitLineData
252b5132 1/* BFD back-end for os9000 i386 binaries.
2571583a 2 Copyright (C) 1990-2017 Free Software Foundation, Inc.
252b5132
RH
3 Written by Cygnus Support.
4
cd123cb7 5 This file is part of BFD, the Binary File Descriptor library.
252b5132 6
cd123cb7
NC
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 3 of the License, or
10 (at your option) any later version.
252b5132 11
cd123cb7
NC
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.
252b5132 16
cd123cb7
NC
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., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
252b5132 21
252b5132 22#include "sysdep.h"
3db64b00 23#include "bfd.h"
252b5132
RH
24#include "libbfd.h"
25#include "bfdlink.h"
26#include "libaout.h" /* BFD a.out internal data structures */
27#include "os9k.h"
28
252b5132
RH
29/* Swaps the information in an executable header taken from a raw byte
30 stream memory image, into the internal exec_header structure. */
a6b96beb
AM
31static bfd_boolean
32os9k_swap_exec_header_in (bfd *abfd,
33 mh_com *raw_bytes,
34 struct internal_exec *execp)
252b5132
RH
35{
36 mh_com *bytes = (mh_com *) raw_bytes;
37 unsigned int dload, dmemsize, dmemstart;
38
39 /* Now fill in fields in the execp, from the bytes in the raw data. */
dc810e39 40 execp->a_info = H_GET_16 (abfd, bytes->m_sync);
252b5132 41 execp->a_syms = 0;
dc810e39 42 execp->a_entry = H_GET_32 (abfd, bytes->m_exec);
252b5132
RH
43 execp->a_talign = 2;
44 execp->a_dalign = 2;
45 execp->a_balign = 2;
46
dc810e39 47 dload = H_GET_32 (abfd, bytes->m_idata);
252b5132
RH
48 execp->a_data = dload + 8;
49
50 if (bfd_seek (abfd, (file_ptr) dload, SEEK_SET) != 0
dc810e39 51 || (bfd_bread (&dmemstart, (bfd_size_type) sizeof (dmemstart), abfd)
252b5132 52 != sizeof (dmemstart))
dc810e39 53 || (bfd_bread (&dmemsize, (bfd_size_type) sizeof (dmemsize), abfd)
252b5132 54 != sizeof (dmemsize)))
b34976b6 55 return FALSE;
252b5132
RH
56
57 execp->a_tload = 0;
dc810e39 58 execp->a_dload = H_GET_32 (abfd, (unsigned char *) &dmemstart);
252b5132 59 execp->a_text = dload - execp->a_tload;
dc810e39
AM
60 execp->a_data = H_GET_32 (abfd, (unsigned char *) &dmemsize);
61 execp->a_bss = H_GET_32 (abfd, bytes->m_data) - execp->a_data;
252b5132
RH
62
63 execp->a_trsize = 0;
64 execp->a_drsize = 0;
65
b34976b6 66 return TRUE;
252b5132
RH
67}
68
252b5132
RH
69
70/* Finish up the opening of a b.out file for reading. Fill in all the
71 fields that are not handled by common code. */
72
73static const bfd_target *
a6b96beb 74os9k_callback (bfd *abfd)
252b5132
RH
75{
76 struct internal_exec *execp = exec_hdr (abfd);
77 unsigned long bss_start;
78
e4b17274 79 /* Architecture and machine type. */
252b5132
RH
80 bfd_set_arch_mach (abfd, bfd_arch_i386, 0);
81
82 /* The positions of the string table and symbol table. */
83 obj_str_filepos (abfd) = 0;
84 obj_sym_filepos (abfd) = 0;
85
e4b17274 86 /* The alignments of the sections. */
252b5132
RH
87 obj_textsec (abfd)->alignment_power = execp->a_talign;
88 obj_datasec (abfd)->alignment_power = execp->a_dalign;
89 obj_bsssec (abfd)->alignment_power = execp->a_balign;
90
91 /* The starting addresses of the sections. */
92 obj_textsec (abfd)->vma = execp->a_tload;
93 obj_datasec (abfd)->vma = execp->a_dload;
94
e4b17274 95 /* And reload the sizes, since the aout module zaps them. */
eea6121a 96 obj_textsec (abfd)->size = execp->a_text;
252b5132 97
e4b17274 98 bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section. */
252b5132
RH
99 obj_bsssec (abfd)->vma = align_power (bss_start, execp->a_balign);
100
e4b17274 101 /* The file positions of the sections. */
252b5132
RH
102 obj_textsec (abfd)->filepos = execp->a_entry;
103 obj_datasec (abfd)->filepos = execp->a_dload;
104
105 /* The file positions of the relocation info ***
bbb1afc8
AM
106 obj_textsec (abfd)->rel_filepos = N_TROFF (execp);
107 obj_datasec (abfd)->rel_filepos = N_DROFF (execp); */
252b5132 108
e4b17274
NC
109 adata (abfd).page_size = 1; /* Not applicable. */
110 adata (abfd).segment_size = 1;/* Not applicable. */
252b5132
RH
111 adata (abfd).exec_bytes_size = MHCOM_BYTES_SIZE;
112
113 return abfd->xvec;
114}
115
a6b96beb
AM
116static const bfd_target *
117os9k_object_p (bfd *abfd)
118{
119 struct internal_exec anexec;
120 mh_com exec_bytes;
121
2c3fc389 122 if (bfd_bread (&exec_bytes, (bfd_size_type) MHCOM_BYTES_SIZE, abfd)
a6b96beb
AM
123 != MHCOM_BYTES_SIZE)
124 {
125 if (bfd_get_error () != bfd_error_system_call)
126 bfd_set_error (bfd_error_wrong_format);
127 return 0;
128 }
129
130 anexec.a_info = H_GET_16 (abfd, exec_bytes.m_sync);
bbb1afc8 131 if (N_BADMAG (&anexec))
a6b96beb
AM
132 {
133 bfd_set_error (bfd_error_wrong_format);
134 return 0;
135 }
136
137 if (! os9k_swap_exec_header_in (abfd, &exec_bytes, &anexec))
138 {
139 if (bfd_get_error () != bfd_error_system_call)
140 bfd_set_error (bfd_error_wrong_format);
141 return NULL;
142 }
143 return aout_32_some_aout_object_p (abfd, &anexec, os9k_callback);
144}
145
252b5132 146static int
a6b96beb
AM
147os9k_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
148 struct bfd_link_info *info ATTRIBUTE_UNUSED)
252b5132
RH
149{
150 return sizeof (struct internal_exec);
151}
152
e4b17274 153\f
252b5132
RH
154
155#define aout_32_close_and_cleanup aout_32_bfd_free_cached_info
156
9c461f7d 157#define aout_32_find_line _bfd_nosymbols_find_line
60bb06bc
L
158#define aout_32_get_symbol_version_string \
159 _bfd_nosymbols_get_symbol_version_string
252b5132
RH
160#define aout_32_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
161
162#define aout_32_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
157090f7 163#define aout_32_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
252b5132
RH
164
165#define aout_32_get_section_contents_in_window \
166 _bfd_generic_get_section_contents_in_window
167
23186865
JM
168#define aout_32_set_reloc _bfd_generic_set_reloc
169
252b5132
RH
170#define os9k_bfd_get_relocated_section_contents \
171 bfd_generic_get_relocated_section_contents
172#define os9k_bfd_relax_section bfd_generic_relax_section
173#define os9k_bfd_gc_sections bfd_generic_gc_sections
ae17ab41 174#define os9k_bfd_lookup_section_flags bfd_generic_lookup_section_flags
8550eb6e 175#define os9k_bfd_merge_sections bfd_generic_merge_sections
72adc230 176#define os9k_bfd_is_group_section bfd_generic_is_group_section
e61463e1 177#define os9k_bfd_discard_group bfd_generic_discard_group
082b7297
L
178#define os9k_section_already_linked \
179 _bfd_generic_section_already_linked
3023e3f6 180#define os9k_bfd_define_common_symbol bfd_generic_define_common_symbol
7dba9362 181#define os9k_bfd_define_start_stop bfd_generic_define_start_stop
252b5132
RH
182#define os9k_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
183#define os9k_bfd_link_add_symbols _bfd_generic_link_add_symbols
2d653fc7 184#define os9k_bfd_link_just_syms _bfd_generic_link_just_syms
1338dd10
PB
185#define os9k_bfd_copy_link_hash_symbol_type \
186 _bfd_generic_copy_link_hash_symbol_type
252b5132
RH
187#define os9k_bfd_final_link _bfd_generic_final_link
188#define os9k_bfd_link_split_section _bfd_generic_link_split_section
4f3b23b3 189#define os9k_bfd_link_check_relocs _bfd_generic_link_check_relocs
252b5132 190
6d00b590 191const bfd_target i386_aout_os9k_vec =
e4b17274
NC
192 {
193 "i386os9k", /* name */
194 bfd_target_os9k_flavour,
195 BFD_ENDIAN_LITTLE, /* data byte order is little */
196 BFD_ENDIAN_LITTLE, /* hdr byte order is little */
197 (HAS_RELOC | EXEC_P | WP_TEXT), /* object flags */
198 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD), /* section flags */
199 0, /* symbol leading char */
200 ' ', /* ar_pad_char */
201 16, /* ar_max_namelen */
0aabe54e 202 0, /* match priority. */
e4b17274
NC
203
204 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
205 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
206 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
207 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
208 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
209 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
210 {_bfd_dummy_target, os9k_object_p, /* bfd_check_format */
211 bfd_generic_archive_p, _bfd_dummy_target},
212 {bfd_false, bfd_false, /* bfd_set_format */
213 _bfd_generic_mkarchive, bfd_false},
214 {bfd_false, bfd_false, /* bfd_write_contents */
215 _bfd_write_archive_contents, bfd_false},
216
217 BFD_JUMP_TABLE_GENERIC (aout_32),
218 BFD_JUMP_TABLE_COPY (_bfd_generic),
219 BFD_JUMP_TABLE_CORE (_bfd_nocore),
220 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
221 BFD_JUMP_TABLE_SYMBOLS (aout_32),
222 BFD_JUMP_TABLE_RELOCS (aout_32),
223 BFD_JUMP_TABLE_WRITE (aout_32),
224 BFD_JUMP_TABLE_LINK (os9k),
225 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
dc810e39 226
e4b17274
NC
227 NULL,
228
2c3fc389 229 NULL,
e4b17274 230 };