1 /* BFD back-end for m68k binaries under Lynx.
2 Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
20 #define BYTES_IN_WORD 4
22 #define N_SHARED_LIB(x) 0
24 #define TEXT_START_ADDR 0
25 #define PAGE_SIZE 4096
26 #define SEGMENT_SIZE PAGE_SIZE
27 #define DEFAULT_ARCH bfd_arch_m68k
29 #define MY(OP) CAT(m68klynx_aout,OP)
30 #define TARGETNAME "a.out-m68k-lynx"
40 #include "aout-target.h"
42 bfd_target m68klynx_aout_vec =
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) */
50 false, /* target byte order (little) */
51 false, /* target headers byte order (little) */
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 */
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 */
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},
83 MY_core_file_failing_command,
84 MY_core_file_failing_signal,
85 MY_core_file_matches_executable_p,
87 MY_slurp_extended_name_table,
91 MY_set_section_contents,
92 MY_get_section_contents,
94 MY_get_symtab_upper_bound,
96 MY_get_reloc_upper_bound,
97 MY_canonicalize_reloc,
103 MY_openr_next_archived_file,
104 MY_find_nearest_line,
105 MY_generic_stat_arch_elt,
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,
118 /* BFD back-end for Motorola 68000 COFF binaries.
119 Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
120 Written by Cygnus Support.
122 This file is part of BFD, the Binary File Descriptor library.
124 This program is free software; you can redistribute it and/or modify
125 it under the terms of the GNU General Public License as published by
126 the Free Software Foundation; either version 2 of the License, or
127 (at your option) any later version.
129 This program is distributed in the hope that it will be useful,
130 but WITHOUT ANY WARRANTY; without even the implied warranty of
131 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132 GNU General Public License for more details.
134 You should have received a copy of the GNU General Public License
135 along with this program; if not, write to the Free Software
136 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
141 #undef obj_sym_filepos
144 #include "coff/m68k.h"
145 #include "coff/internal.h"
148 #define COFF_LONG_FILENAMES
150 #ifdef ONLY_DECLARE_RELOCS
151 extern reloc_howto_type m68kcoff_howto_table[];
153 reloc_howto_type m68kcoff_howto_table[] =
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),
163 #endif /* not ONLY_DECLARE_RELOCS */
166 #define BADMAG(x) M68KBADMAG(x)
168 #define M68 1 /* Customize coffcode.h */
170 /* Turn a howto into a reloc number */
172 #ifdef ONLY_DECLARE_RELOCS
173 extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry));
174 extern int m68k_howto2rtype PARAMS ((CONST struct reloc_howto_struct *));
177 m68k_rtype2howto(internal, relocentry)
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;
194 m68k_howto2rtype (internal)
195 CONST struct reloc_howto_struct *internal;
197 if (internal->pc_relative)
199 switch (internal->bitsize)
201 case 32: return R_PCRLONG;
202 case 16: return R_PCRWORD;
203 case 8: return R_PCRBYTE;
208 switch (internal->bitsize)
210 case 32: return R_RELLONG;
211 case 16: return R_RELWORD;
212 case 8: return R_RELBYTE;
217 #endif /* not ONLY_DECLARE_RELOCS */
219 #define RTYPE2HOWTO(internal, relocentry) \
220 m68k_rtype2howto(internal, (relocentry)->r_type)
222 #define SELECT_RELOC(external, internal) \
223 external = m68k_howto2rtype(internal);
225 #include "coffcode.h"
227 bfd_target m68klynx_coff_vec =
231 bfd_target_coff_flavour,
232 true, /* data byte order is big */
233 true, /* header byte order is big */
235 (HAS_RELOC | EXEC_P | /* object flags */
236 HAS_LINENO | HAS_DEBUG |
237 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
239 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
240 #ifdef NAMES_HAVE_UNDERSCORE
243 0, /* leading underscore */
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 */
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 */
259 {bfd_false, coff_write_object_contents, /* bfd_write_contents */
260 _bfd_write_archive_contents, bfd_false},