| 1 | /* BFD library support routines for the Z800n architecture. | 
|---|
| 2 | Copyright 1992, 1993, 1994, 2000, 2001, 2002 | 
|---|
| 3 | Free Software Foundation, Inc. | 
|---|
| 4 | Hacked by Steve Chamberlain of Cygnus Support. | 
|---|
| 5 |  | 
|---|
| 6 | This file is part of BFD, the Binary File Descriptor library. | 
|---|
| 7 |  | 
|---|
| 8 | This program is free software; you can redistribute it and/or modify | 
|---|
| 9 | it under the terms of the GNU General Public License as published by | 
|---|
| 10 | the Free Software Foundation; either version 2 of the License, or | 
|---|
| 11 | (at your option) any later version. | 
|---|
| 12 |  | 
|---|
| 13 | This program is distributed in the hope that it will be useful, | 
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 16 | GNU General Public License for more details. | 
|---|
| 17 |  | 
|---|
| 18 | You should have received a copy of the GNU General Public License | 
|---|
| 19 | along with this program; if not, write to the Free Software | 
|---|
| 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ | 
|---|
| 21 |  | 
|---|
| 22 | #include "bfd.h" | 
|---|
| 23 | #include "sysdep.h" | 
|---|
| 24 | #include "libbfd.h" | 
|---|
| 25 |  | 
|---|
| 26 | static const bfd_arch_info_type *compatible | 
|---|
| 27 | PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *)); | 
|---|
| 28 |  | 
|---|
| 29 | #if 0                           /* not used currently */ | 
|---|
| 30 | /* | 
|---|
| 31 | Relocations for the Z8K | 
|---|
| 32 |  | 
|---|
| 33 | */ | 
|---|
| 34 | static bfd_reloc_status_type | 
|---|
| 35 | howto16_callback (abfd, reloc_entry, symbol_in, data, | 
|---|
| 36 | ignore_input_section, ignore_bfd) | 
|---|
| 37 | bfd *abfd; | 
|---|
| 38 | arelent *reloc_entry; | 
|---|
| 39 | struct symbol_cache_entry *symbol_in; | 
|---|
| 40 | PTR data; | 
|---|
| 41 | asection *ignore_input_section; | 
|---|
| 42 | bfd *ignore_bfd; | 
|---|
| 43 | { | 
|---|
| 44 | long relocation = 0; | 
|---|
| 45 | bfd_vma addr = reloc_entry->address; | 
|---|
| 46 | long x = bfd_get_16 (abfd, (bfd_byte *) data + addr); | 
|---|
| 47 |  | 
|---|
| 48 | HOWTO_PREPARE (relocation, symbol_in); | 
|---|
| 49 |  | 
|---|
| 50 | x = (x + relocation + reloc_entry->addend); | 
|---|
| 51 |  | 
|---|
| 52 | bfd_put_16 (abfd, x, (bfd_byte *) data + addr); | 
|---|
| 53 | return bfd_reloc_ok; | 
|---|
| 54 | } | 
|---|
| 55 |  | 
|---|
| 56 | static bfd_reloc_status_type | 
|---|
| 57 | howto8_callback (abfd, reloc_entry, symbol_in, data, | 
|---|
| 58 | ignore_input_section, ignore_bfd) | 
|---|
| 59 | bfd *abfd; | 
|---|
| 60 | arelent *reloc_entry; | 
|---|
| 61 | struct symbol_cache_entry *symbol_in; | 
|---|
| 62 | PTR data; | 
|---|
| 63 | asection *ignore_input_section; | 
|---|
| 64 | bfd *ignore_bfd; | 
|---|
| 65 | { | 
|---|
| 66 | long relocation = 0; | 
|---|
| 67 | bfd_vma addr = reloc_entry->address; | 
|---|
| 68 | long x = bfd_get_8 (abfd, (bfd_byte *) data + addr); | 
|---|
| 69 |  | 
|---|
| 70 | HOWTO_PREPARE (relocation, symbol_in); | 
|---|
| 71 |  | 
|---|
| 72 | x = (x + relocation + reloc_entry->addend); | 
|---|
| 73 |  | 
|---|
| 74 | bfd_put_8 (abfd, x, (bfd_byte *) data + addr); | 
|---|
| 75 | return bfd_reloc_ok; | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|
| 78 | static bfd_reloc_status_type | 
|---|
| 79 | howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data, | 
|---|
| 80 | ignore_input_section, ignore_bfd) | 
|---|
| 81 | bfd *abfd; | 
|---|
| 82 | arelent *reloc_entry; | 
|---|
| 83 | struct symbol_cache_entry *symbol_in; | 
|---|
| 84 | PTR data; | 
|---|
| 85 | asection *ignore_input_section; | 
|---|
| 86 | bfd *ignore_bfd; | 
|---|
| 87 | { | 
|---|
| 88 | long relocation = 0; | 
|---|
| 89 | bfd_vma addr = reloc_entry->address; | 
|---|
| 90 |  | 
|---|
| 91 | long x = bfd_get_8 (abfd, (bfd_byte *) data + addr); | 
|---|
| 92 | abort (); | 
|---|
| 93 | HOWTO_PREPARE (relocation, symbol_in); | 
|---|
| 94 |  | 
|---|
| 95 | x = (x + relocation + reloc_entry->addend); | 
|---|
| 96 |  | 
|---|
| 97 | bfd_put_8 (abfd, x, (bfd_byte *) data + addr); | 
|---|
| 98 | return bfd_reloc_ok; | 
|---|
| 99 | } | 
|---|
| 100 |  | 
|---|
| 101 | static bfd_reloc_status_type | 
|---|
| 102 | howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data, | 
|---|
| 103 | ignore_input_section, ignore_bfd) | 
|---|
| 104 | bfd *abfd; | 
|---|
| 105 | arelent *reloc_entry; | 
|---|
| 106 | struct symbol_cache_entry *symbol_in; | 
|---|
| 107 | PTR data; | 
|---|
| 108 | asection *ignore_input_section; | 
|---|
| 109 | bfd *ignore_bfd; | 
|---|
| 110 | { | 
|---|
| 111 | long relocation = 0; | 
|---|
| 112 | bfd_vma addr = reloc_entry->address; | 
|---|
| 113 | long x = bfd_get_8 (abfd, (bfd_byte *) data + addr); | 
|---|
| 114 | abort (); | 
|---|
| 115 | HOWTO_PREPARE (relocation, symbol_in); | 
|---|
| 116 |  | 
|---|
| 117 | x = (x + relocation + reloc_entry->addend); | 
|---|
| 118 |  | 
|---|
| 119 | bfd_put_8 (abfd, x, (bfd_byte *) data + addr); | 
|---|
| 120 | return bfd_reloc_ok; | 
|---|
| 121 | } | 
|---|
| 122 |  | 
|---|
| 123 | static reloc_howto_type howto_16 | 
|---|
| 124 | = NEWHOWTO (howto16_callback, "abs16", 1, FALSE, FALSE); | 
|---|
| 125 | static reloc_howto_type howto_8 | 
|---|
| 126 | = NEWHOWTO (howto8_callback, "abs8", 0, FALSE, FALSE); | 
|---|
| 127 |  | 
|---|
| 128 | static reloc_howto_type howto_8_FFnn | 
|---|
| 129 | = NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, FALSE, FALSE); | 
|---|
| 130 |  | 
|---|
| 131 | static reloc_howto_type howto_8_pcrel | 
|---|
| 132 | = NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, FALSE, TRUE); | 
|---|
| 133 |  | 
|---|
| 134 | static reloc_howto_type * | 
|---|
| 135 | local_bfd_reloc_type_lookup (arch, code) | 
|---|
| 136 | const struct bfd_arch_info *arch; | 
|---|
| 137 | bfd_reloc_code_real_type code; | 
|---|
| 138 | { | 
|---|
| 139 | switch (code) | 
|---|
| 140 | { | 
|---|
| 141 | case BFD_RELOC_16: | 
|---|
| 142 | return &howto_16; | 
|---|
| 143 | case BFD_RELOC_8_FFnn: | 
|---|
| 144 | return &howto_8_FFnn; | 
|---|
| 145 | case BFD_RELOC_8: | 
|---|
| 146 | return &howto_8; | 
|---|
| 147 | case BFD_RELOC_8_PCREL: | 
|---|
| 148 | return &howto_8_pcrel; | 
|---|
| 149 | default: | 
|---|
| 150 | return (reloc_howto_type *) NULL; | 
|---|
| 151 | } | 
|---|
| 152 | } | 
|---|
| 153 | #endif | 
|---|
| 154 |  | 
|---|
| 155 | /* This routine is provided two arch_infos and returns whether | 
|---|
| 156 | they'd be compatible */ | 
|---|
| 157 |  | 
|---|
| 158 | static const bfd_arch_info_type * | 
|---|
| 159 | compatible (a, b) | 
|---|
| 160 | const bfd_arch_info_type *a; | 
|---|
| 161 | const bfd_arch_info_type *b; | 
|---|
| 162 | { | 
|---|
| 163 | if (a->arch != b->arch || a->mach != b->mach) | 
|---|
| 164 | return NULL; | 
|---|
| 165 | return a; | 
|---|
| 166 | } | 
|---|
| 167 |  | 
|---|
| 168 | static const bfd_arch_info_type arch_info_struct[] = | 
|---|
| 169 | { | 
|---|
| 170 | { 32, 16, 8, bfd_arch_z8k, bfd_mach_z8002, "z8k", "z8002", 1, FALSE, | 
|---|
| 171 | compatible, bfd_default_scan, 0 } | 
|---|
| 172 | }; | 
|---|
| 173 |  | 
|---|
| 174 | const bfd_arch_info_type bfd_z8k_arch = | 
|---|
| 175 | { | 
|---|
| 176 | 32, 32, 8, bfd_arch_z8k, bfd_mach_z8001, "z8k", "z8001", 1, TRUE, | 
|---|
| 177 | compatible, bfd_default_scan, &arch_info_struct[0] | 
|---|
| 178 | }; | 
|---|