]>
Commit | Line | Data |
---|---|---|
6585e9e3 ILT |
1 | /* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files. |
2 | Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc. | |
156e3852 | 3 | Written by Cygnus Support. |
a7fe4c59 | 4 | |
156e3852 | 5 | This file is part of BFD, the Binary File Descriptor library. |
a7fe4c59 | 6 | |
156e3852 | 7 | This program is free software; you can redistribute it and/or modify |
a7fe4c59 | 8 | it under the terms of the GNU General Public License as published by |
156e3852 JG |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | |
a7fe4c59 | 11 | |
156e3852 | 12 | This program is distributed in the hope that it will be useful, |
a7fe4c59 SC |
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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
156e3852 JG |
18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
a7fe4c59 | 20 | |
156e3852 | 21 | #define M88 1 /* Customize various include files */ |
a7fe4c59 | 22 | #include "bfd.h" |
156e3852 | 23 | #include "sysdep.h" |
a7fe4c59 | 24 | #include "libbfd.h" |
9872a49c | 25 | #include "obstack.h" |
294eaca4 SC |
26 | #include "coff/m88k.h" |
27 | #include "coff/internal.h" | |
9872a49c | 28 | #include "libcoff.h" |
294eaca4 | 29 | #undef HOWTO_PREPARE |
4cddd1c9 SC |
30 | /* Provided the symbol, returns the value reffed */ |
31 | #define HOWTO_PREPARE(relocation, symbol) \ | |
32 | { \ | |
33 | if (symbol != (asymbol *)NULL) { \ | |
6585e9e3 | 34 | if (bfd_is_com_section (symbol->section)) { \ |
4cddd1c9 SC |
35 | relocation = 0; \ |
36 | } \ | |
37 | else { \ | |
38 | relocation = symbol->value; \ | |
39 | } \ | |
40 | } \ | |
41 | if (symbol->section != (asection *)NULL) { \ | |
42 | relocation += symbol->section->output_section->vma + \ | |
43 | symbol->section->output_offset; \ | |
44 | } \ | |
45 | } | |
4cddd1c9 SC |
46 | |
47 | ||
156e3852 | 48 | static bfd_reloc_status_type |
6812b607 ILT |
49 | howto_hvrt16 (abfd, reloc_entry, symbol_in, data, |
50 | ignore_input_section, ignore_bfd, error_message) | |
51 | bfd *abfd; | |
52 | arelent *reloc_entry; | |
53 | asymbol *symbol_in; | |
54 | PTR data; | |
55 | asection *ignore_input_section; | |
56 | bfd *ignore_bfd; | |
57 | char **error_message; | |
4cddd1c9 | 58 | { |
294eaca4 | 59 | long relocation = 0; |
4cddd1c9 | 60 | bfd_vma addr = reloc_entry->address; |
19b03b7a | 61 | long x = bfd_get_16(abfd, (bfd_byte *)data + addr); |
4cddd1c9 SC |
62 | |
63 | HOWTO_PREPARE(relocation, symbol_in); | |
64 | ||
65 | x = (x + relocation + reloc_entry->addend) >> 16; | |
66 | ||
19b03b7a | 67 | bfd_put_16(abfd, x, (bfd_byte *)data + addr); |
4cddd1c9 SC |
68 | return bfd_reloc_ok; |
69 | } | |
70 | ||
a7fe4c59 SC |
71 | |
72 | ||
73 | static reloc_howto_type howto_table[] = | |
74 | { | |
6812b607 ILT |
75 | HOWTO(R_PCR16L,02,1,16,true, 0,complain_overflow_signed, 0, "PCR16L",false,0x0000ffff,0x0000ffff,true), |
76 | HOWTO(R_PCR26L,02,2,26,true, 0,complain_overflow_signed, 0, "PCR26L",false,0x03ffffff,0x03ffffff,true), | |
77 | HOWTO(R_VRT16, 00,1,16,false,0,complain_overflow_bitfield, 0, "VRT16", false,0x0000ffff,0x0000ffff,true), | |
78 | HOWTO(R_HVRT16,16,1,16,false,0,complain_overflow_dont,howto_hvrt16,"HVRT16",false,0x0000ffff,0x0000ffff,true), | |
79 | HOWTO(R_LVRT16,00,1,16,false,0,complain_overflow_dont, 0, "LVRT16",false,0x0000ffff,0x0000ffff,true), | |
80 | HOWTO(R_VRT32, 00,2,32,false,0,complain_overflow_bitfield, 0, "VRT32", false,0xffffffff,0xffffffff,true), | |
a7fe4c59 SC |
81 | }; |
82 | ||
83 | ||
3b4f1a5d SC |
84 | /* Code to swap in the reloc offset */ |
85 | #define SWAP_IN_RELOC_OFFSET bfd_h_get_16 | |
86 | #define SWAP_OUT_RELOC_OFFSET bfd_h_put_16 | |
87 | ||
88 | ||
89 | /* Code to turn an external r_type into a pointer to an entry in the | |
90 | above howto table */ | |
91 | #define RTYPE2HOWTO(cache_ptr, dst) \ | |
294eaca4 SC |
92 | if ((dst)->r_type >= R_PCR16L && (dst)->r_type <= R_VRT32) {\ |
93 | cache_ptr->howto = howto_table + (dst)->r_type - R_PCR16L;\ | |
94 | cache_ptr->addend += (dst)->r_offset << 16; \ | |
3b4f1a5d SC |
95 | } \ |
96 | else { \ | |
97 | BFD_ASSERT(0); \ | |
98 | } | |
99 | ||
100 | ||
a7fe4c59 SC |
101 | |
102 | #define BADMAG(x) MC88BADMAG(x) | |
2700c3c7 | 103 | #include "coffcode.h" |
a7fe4c59 | 104 | |
5685fb50 | 105 | #undef coff_write_armap |
9872a49c | 106 | |
080f6324 | 107 | bfd_target m88kbcs_vec = |
a7fe4c59 | 108 | { |
3b4f1a5d | 109 | "coff-m88kbcs", /* name */ |
156e3852 | 110 | bfd_target_coff_flavour, |
9872a49c | 111 | true, /* data byte order is big */ |
a7fe4c59 SC |
112 | true, /* header byte order is big */ |
113 | ||
114 | (HAS_RELOC | EXEC_P | /* object flags */ | |
115 | HAS_LINENO | HAS_DEBUG | | |
6812b607 | 116 | HAS_SYMS | HAS_LOCALS | WP_TEXT), |
a7fe4c59 SC |
117 | |
118 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
6585e9e3 | 119 | '_', /* leading underscore */ |
a7fe4c59 SC |
120 | '/', /* ar_pad_char */ |
121 | 15, /* ar_max_namelen */ | |
156e3852 | 122 | 3, /* default alignment power */ |
6812b607 ILT |
123 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, |
124 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
125 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ | |
126 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
127 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
128 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ | |
a7fe4c59 | 129 | |
156e3852 JG |
130 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ |
131 | bfd_generic_archive_p, _bfd_dummy_target}, | |
132 | {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ | |
133 | bfd_false}, | |
134 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
135 | _bfd_write_archive_contents, bfd_false}, | |
9872a49c | 136 | |
6812b607 ILT |
137 | BFD_JUMP_TABLE_GENERIC (coff), |
138 | BFD_JUMP_TABLE_COPY (coff), | |
139 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
140 | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), | |
141 | BFD_JUMP_TABLE_SYMBOLS (coff), | |
142 | BFD_JUMP_TABLE_RELOCS (coff), | |
143 | BFD_JUMP_TABLE_WRITE (coff), | |
144 | BFD_JUMP_TABLE_LINK (coff), | |
145 | ||
6585e9e3 | 146 | COFF_SWAP_TABLE, |
2b1d8a50 | 147 | }; |