* stabs.texinfo (Include Files): Fix typo (start -> end).
[deliverable/binutils-gdb.git] / bfd / m68klynx.c
CommitLineData
96e39d2a
SS
1/* BFD back-end for m68k binaries under Lynx.
2 Copyright (C) 1990, 1991, 1992 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 BYTES_IN_WORD 4
21#define ARCH 32
22#define N_SHARED_LIB(x) 0
23
24#define TEXT_START_ADDR 0
25#define PAGE_SIZE 4096
26#define SEGMENT_SIZE PAGE_SIZE
27#define DEFAULT_ARCH bfd_arch_m68k
28
29#define MY(OP) CAT(m68klynx_aout,OP)
30#define TARGETNAME "a.out-m68k-lynx"
31
32#include "bfd.h"
33#include "sysdep.h"
34#include "libbfd.h"
35
36#include "libaout.h"
37
38#define MY_BFD_TARGET
39
40#include "aout-target.h"
41
42bfd_target m68klynx_aout_vec =
43{
44 TARGETNAME, /* name */
45 bfd_target_aout_flavour,
46#ifdef TARGET_IS_BIG_ENDIAN_P
47 true, /* target byte order (big) */
48 true, /* target headers byte order (big) */
49#else
50 false, /* target byte order (little) */
51 false, /* target headers byte order (little) */
52#endif
53 (HAS_RELOC | EXEC_P | /* object flags */
54 HAS_LINENO | HAS_DEBUG |
55 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
56 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
57 MY_symbol_leading_char,
58 AR_PAD_CHAR, /* ar_pad_char */
59 15, /* ar_max_namelen */
60 3, /* minimum alignment */
61#ifdef TARGET_IS_BIG_ENDIAN_P
62 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
63 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
64 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
65 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
66 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
67 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
68#else
69 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
70 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
71 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
72 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
73 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
74 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
75#endif
76 {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
77 bfd_generic_archive_p, MY_core_file_p},
78 {bfd_false, MY_mkobject, /* bfd_set_format */
79 _bfd_generic_mkarchive, bfd_false},
80 {bfd_false, MY_write_object_contents, /* bfd_write_contents */
81 _bfd_write_archive_contents, bfd_false},
82
83 MY_core_file_failing_command,
84 MY_core_file_failing_signal,
85 MY_core_file_matches_executable_p,
86 MY_slurp_armap,
87 MY_slurp_extended_name_table,
88 MY_truncate_arname,
89 MY_write_armap,
90 MY_close_and_cleanup,
91 MY_set_section_contents,
92 MY_get_section_contents,
93 MY_new_section_hook,
94 MY_get_symtab_upper_bound,
95 MY_get_symtab,
96 MY_get_reloc_upper_bound,
97 MY_canonicalize_reloc,
98 MY_make_empty_symbol,
99 MY_print_symbol,
100 MY_get_symbol_info,
101 MY_get_lineno,
102 MY_set_arch_mach,
103 MY_openr_next_archived_file,
104 MY_find_nearest_line,
105 MY_generic_stat_arch_elt,
106 MY_sizeof_headers,
107 MY_bfd_debug_info_start,
108 MY_bfd_debug_info_end,
109 MY_bfd_debug_info_accumulate,
110 bfd_generic_get_relocated_section_contents,
111 bfd_generic_relax_section,
112 bfd_generic_seclet_link,
113 MY_reloc_howto_type_lookup,
114 MY_make_debug_symbol,
115 (PTR) MY_backend_data,
116};
117
118/* BFD back-end for Motorola 68000 COFF binaries.
119 Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
120 Written by Cygnus Support.
121
122This file is part of BFD, the Binary File Descriptor library.
123
124This program is free software; you can redistribute it and/or modify
125it under the terms of the GNU General Public License as published by
126the Free Software Foundation; either version 2 of the License, or
127(at your option) any later version.
128
129This program is distributed in the hope that it will be useful,
130but WITHOUT ANY WARRANTY; without even the implied warranty of
131MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132GNU General Public License for more details.
133
134You should have received a copy of the GNU General Public License
135along with this program; if not, write to the Free Software
136Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
137
138#undef OMAGIC
139#undef N_ABS
140#undef exec_hdr
141#undef obj_sym_filepos
142
143#include "obstack.h"
144#include "coff/m68k.h"
145#include "coff/internal.h"
146#include "libcoff.h"
147
148#define COFF_LONG_FILENAMES
149
150#ifdef ONLY_DECLARE_RELOCS
151extern reloc_howto_type m68kcoff_howto_table[];
152#else
153reloc_howto_type m68kcoff_howto_table[] =
154{
155 HOWTO(R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, 0, "8", true, 0x000000ff,0x000000ff, false),
156 HOWTO(R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, 0, "16", true, 0x0000ffff,0x0000ffff, false),
157 HOWTO(R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, 0, "32", true, 0xffffffff,0xffffffff, false),
158 HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, complain_overflow_signed, 0, "DISP8", true, 0x000000ff,0x000000ff, false),
159 HOWTO(R_PCRWORD, 0, 1, 16, true, 0, complain_overflow_signed, 0, "DISP16", true, 0x0000ffff,0x0000ffff, false),
160 HOWTO(R_PCRLONG, 0, 2, 32, true, 0, complain_overflow_signed, 0, "DISP32", true, 0xffffffff,0xffffffff, false),
161 HOWTO(R_RELLONG_NEG, 0, -2, 32, false, 0, complain_overflow_bitfield, 0, "-32", true, 0xffffffff,0xffffffff, false),
162};
163#endif /* not ONLY_DECLARE_RELOCS */
164
165#ifndef BADMAG
166#define BADMAG(x) M68KBADMAG(x)
167#endif
168#define M68 1 /* Customize coffcode.h */
169
170/* Turn a howto into a reloc number */
171
172#ifdef ONLY_DECLARE_RELOCS
173extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry));
174extern int m68k_howto2rtype PARAMS ((CONST struct reloc_howto_struct *));
175#else
176void
177m68k_rtype2howto(internal, relocentry)
178 arelent *internal;
179 int relocentry;
180{
181 switch (relocentry)
182 {
183 case R_RELBYTE: internal->howto = m68kcoff_howto_table + 0; break;
184 case R_RELWORD: internal->howto = m68kcoff_howto_table + 1; break;
185 case R_RELLONG: internal->howto = m68kcoff_howto_table + 2; break;
186 case R_PCRBYTE: internal->howto = m68kcoff_howto_table + 3; break;
187 case R_PCRWORD: internal->howto = m68kcoff_howto_table + 4; break;
188 case R_PCRLONG: internal->howto = m68kcoff_howto_table + 5; break;
189 case R_RELLONG_NEG: internal->howto = m68kcoff_howto_table + 6; break;
190 }
191}
192
193int
194m68k_howto2rtype (internal)
195 CONST struct reloc_howto_struct *internal;
196{
197 if (internal->pc_relative)
198 {
199 switch (internal->bitsize)
200 {
201 case 32: return R_PCRLONG;
202 case 16: return R_PCRWORD;
203 case 8: return R_PCRBYTE;
204 }
205 }
206 else
207 {
208 switch (internal->bitsize)
209 {
210 case 32: return R_RELLONG;
211 case 16: return R_RELWORD;
212 case 8: return R_RELBYTE;
213 }
214 }
215 return R_RELLONG;
216}
217#endif /* not ONLY_DECLARE_RELOCS */
218
219#define RTYPE2HOWTO(internal, relocentry) \
220 m68k_rtype2howto(internal, (relocentry)->r_type)
221
222#define SELECT_RELOC(external, internal) \
223 external = m68k_howto2rtype(internal);
224
225#include "coffcode.h"
226
227bfd_target m68klynx_coff_vec =
228{
229 "coff-m68k-lynx",
230
231 bfd_target_coff_flavour,
232 true, /* data byte order is big */
233 true, /* header byte order is big */
234
235 (HAS_RELOC | EXEC_P | /* object flags */
236 HAS_LINENO | HAS_DEBUG |
237 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
238
239 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
240#ifdef NAMES_HAVE_UNDERSCORE
241 '_',
242#else
243 0, /* leading underscore */
244#endif
245 '/', /* ar_pad_char */
246 15, /* ar_max_namelen */
247 1, /* minimum section alignment */
248 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
249 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
250 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
251 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
252 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
253 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
254
255 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
256 bfd_generic_archive_p, _bfd_dummy_target},
257 {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
258 bfd_false},
259 {bfd_false, coff_write_object_contents, /* bfd_write_contents */
260 _bfd_write_archive_contents, bfd_false},
261
262 JUMP_TABLE(coff),
263 COFF_SWAP_TABLE
264 };
This page took 0.032095 seconds and 4 git commands to generate.