| 1 | /* Select disassembly routine for specified architecture. | 
|---|
| 2 | Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 | 
|---|
| 3 | Free Software Foundation, Inc. | 
|---|
| 4 |  | 
|---|
| 5 | This program is free software; you can redistribute it and/or modify | 
|---|
| 6 | it under the terms of the GNU General Public License as published by | 
|---|
| 7 | the Free Software Foundation; either version 2 of the License, or | 
|---|
| 8 | (at your option) any later version. | 
|---|
| 9 |  | 
|---|
| 10 | This program is distributed in the hope that it will be useful, | 
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 13 | GNU General Public License for more details. | 
|---|
| 14 |  | 
|---|
| 15 | You should have received a copy of the GNU General Public License | 
|---|
| 16 | along with this program; if not, write to the Free Software | 
|---|
| 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */ | 
|---|
| 18 |  | 
|---|
| 19 | #include "sysdep.h" | 
|---|
| 20 | #include "dis-asm.h" | 
|---|
| 21 |  | 
|---|
| 22 | #ifdef ARCH_all | 
|---|
| 23 | #define ARCH_a29k | 
|---|
| 24 | #define ARCH_alpha | 
|---|
| 25 | #define ARCH_arc | 
|---|
| 26 | #define ARCH_arm | 
|---|
| 27 | #define ARCH_avr | 
|---|
| 28 | #define ARCH_cris | 
|---|
| 29 | #define ARCH_d10v | 
|---|
| 30 | #define ARCH_d30v | 
|---|
| 31 | #define ARCH_h8300 | 
|---|
| 32 | #define ARCH_h8500 | 
|---|
| 33 | #define ARCH_hppa | 
|---|
| 34 | #define ARCH_i370 | 
|---|
| 35 | #define ARCH_i386 | 
|---|
| 36 | #define ARCH_i860 | 
|---|
| 37 | #define ARCH_i960 | 
|---|
| 38 | #define ARCH_ia64 | 
|---|
| 39 | #define ARCH_fr30 | 
|---|
| 40 | #define ARCH_m32r | 
|---|
| 41 | #define ARCH_m68k | 
|---|
| 42 | #define ARCH_m68hc11 | 
|---|
| 43 | #define ARCH_m68hc12 | 
|---|
| 44 | #define ARCH_m88k | 
|---|
| 45 | #define ARCH_mcore | 
|---|
| 46 | #define ARCH_mips | 
|---|
| 47 | #define ARCH_mn10200 | 
|---|
| 48 | #define ARCH_mn10300 | 
|---|
| 49 | #define ARCH_ns32k | 
|---|
| 50 | #define ARCH_pj | 
|---|
| 51 | #define ARCH_powerpc | 
|---|
| 52 | #define ARCH_rs6000 | 
|---|
| 53 | #define ARCH_sh | 
|---|
| 54 | #define ARCH_sparc | 
|---|
| 55 | #define ARCH_tic30 | 
|---|
| 56 | #define ARCH_tic54x | 
|---|
| 57 | #define ARCH_tic80 | 
|---|
| 58 | #define ARCH_v850 | 
|---|
| 59 | #define ARCH_vax | 
|---|
| 60 | #define ARCH_w65 | 
|---|
| 61 | #define ARCH_z8k | 
|---|
| 62 | #endif | 
|---|
| 63 |  | 
|---|
| 64 |  | 
|---|
| 65 | disassembler_ftype | 
|---|
| 66 | disassembler (abfd) | 
|---|
| 67 | bfd *abfd; | 
|---|
| 68 | { | 
|---|
| 69 | enum bfd_architecture a = bfd_get_arch (abfd); | 
|---|
| 70 | disassembler_ftype disassemble; | 
|---|
| 71 |  | 
|---|
| 72 | switch (a) | 
|---|
| 73 | { | 
|---|
| 74 | /* If you add a case to this table, also add it to the | 
|---|
| 75 | ARCH_all definition right above this function.  */ | 
|---|
| 76 | #ifdef ARCH_a29k | 
|---|
| 77 | case bfd_arch_a29k: | 
|---|
| 78 | /* As far as I know we only handle big-endian 29k objects.  */ | 
|---|
| 79 | disassemble = print_insn_big_a29k; | 
|---|
| 80 | break; | 
|---|
| 81 | #endif | 
|---|
| 82 | #ifdef ARCH_alpha | 
|---|
| 83 | case bfd_arch_alpha: | 
|---|
| 84 | disassemble = print_insn_alpha; | 
|---|
| 85 | break; | 
|---|
| 86 | #endif | 
|---|
| 87 | #ifdef ARCH_arc | 
|---|
| 88 | case bfd_arch_arc: | 
|---|
| 89 | { | 
|---|
| 90 | disassemble = arc_get_disassembler (abfd); | 
|---|
| 91 | break; | 
|---|
| 92 | } | 
|---|
| 93 | #endif | 
|---|
| 94 | #ifdef ARCH_arm | 
|---|
| 95 | case bfd_arch_arm: | 
|---|
| 96 | if (bfd_big_endian (abfd)) | 
|---|
| 97 | disassemble = print_insn_big_arm; | 
|---|
| 98 | else | 
|---|
| 99 | disassemble = print_insn_little_arm; | 
|---|
| 100 | break; | 
|---|
| 101 | #endif | 
|---|
| 102 | #ifdef ARCH_avr | 
|---|
| 103 | case bfd_arch_avr: | 
|---|
| 104 | disassemble = print_insn_avr; | 
|---|
| 105 | break; | 
|---|
| 106 | #endif | 
|---|
| 107 | #ifdef ARCH_cris | 
|---|
| 108 | case bfd_arch_cris: | 
|---|
| 109 | disassemble = cris_get_disassembler (abfd); | 
|---|
| 110 | break; | 
|---|
| 111 | #endif | 
|---|
| 112 | #ifdef ARCH_d10v | 
|---|
| 113 | case bfd_arch_d10v: | 
|---|
| 114 | disassemble = print_insn_d10v; | 
|---|
| 115 | break; | 
|---|
| 116 | #endif | 
|---|
| 117 | #ifdef ARCH_d30v | 
|---|
| 118 | case bfd_arch_d30v: | 
|---|
| 119 | disassemble = print_insn_d30v; | 
|---|
| 120 | break; | 
|---|
| 121 | #endif | 
|---|
| 122 | #ifdef ARCH_h8300 | 
|---|
| 123 | case bfd_arch_h8300: | 
|---|
| 124 | if (bfd_get_mach(abfd) == bfd_mach_h8300h) | 
|---|
| 125 | disassemble = print_insn_h8300h; | 
|---|
| 126 | else if (bfd_get_mach(abfd) == bfd_mach_h8300s) | 
|---|
| 127 | disassemble = print_insn_h8300s; | 
|---|
| 128 | else | 
|---|
| 129 | disassemble = print_insn_h8300; | 
|---|
| 130 | break; | 
|---|
| 131 | #endif | 
|---|
| 132 | #ifdef ARCH_h8500 | 
|---|
| 133 | case bfd_arch_h8500: | 
|---|
| 134 | disassemble = print_insn_h8500; | 
|---|
| 135 | break; | 
|---|
| 136 | #endif | 
|---|
| 137 | #ifdef ARCH_hppa | 
|---|
| 138 | case bfd_arch_hppa: | 
|---|
| 139 | disassemble = print_insn_hppa; | 
|---|
| 140 | break; | 
|---|
| 141 | #endif | 
|---|
| 142 | #ifdef ARCH_i370 | 
|---|
| 143 | case bfd_arch_i370: | 
|---|
| 144 | disassemble = print_insn_i370; | 
|---|
| 145 | break; | 
|---|
| 146 | #endif | 
|---|
| 147 | #ifdef ARCH_i386 | 
|---|
| 148 | case bfd_arch_i386: | 
|---|
| 149 | if (bfd_get_mach (abfd) == bfd_mach_i386_i386_intel_syntax | 
|---|
| 150 | || bfd_get_mach (abfd) == bfd_mach_x86_64_intel_syntax) | 
|---|
| 151 | disassemble = print_insn_i386_intel; | 
|---|
| 152 | else | 
|---|
| 153 | disassemble = print_insn_i386_att; | 
|---|
| 154 | break; | 
|---|
| 155 | #endif | 
|---|
| 156 | #ifdef ARCH_i860 | 
|---|
| 157 | case bfd_arch_i860: | 
|---|
| 158 | disassemble = print_insn_i860; | 
|---|
| 159 | break; | 
|---|
| 160 | #endif | 
|---|
| 161 | #ifdef ARCH_i960 | 
|---|
| 162 | case bfd_arch_i960: | 
|---|
| 163 | disassemble = print_insn_i960; | 
|---|
| 164 | break; | 
|---|
| 165 | #endif | 
|---|
| 166 | #ifdef ARCH_ia64 | 
|---|
| 167 | case bfd_arch_ia64: | 
|---|
| 168 | disassemble = print_insn_ia64; | 
|---|
| 169 | break; | 
|---|
| 170 | #endif | 
|---|
| 171 | #ifdef ARCH_fr30 | 
|---|
| 172 | case bfd_arch_fr30: | 
|---|
| 173 | disassemble = print_insn_fr30; | 
|---|
| 174 | break; | 
|---|
| 175 | #endif | 
|---|
| 176 | #ifdef ARCH_m32r | 
|---|
| 177 | case bfd_arch_m32r: | 
|---|
| 178 | disassemble = print_insn_m32r; | 
|---|
| 179 | break; | 
|---|
| 180 | #endif | 
|---|
| 181 | #if defined(ARCH_m68hc11) || defined(ARCH_m68hc12) | 
|---|
| 182 | case bfd_arch_m68hc11: | 
|---|
| 183 | disassemble = print_insn_m68hc11; | 
|---|
| 184 | break; | 
|---|
| 185 | case bfd_arch_m68hc12: | 
|---|
| 186 | disassemble = print_insn_m68hc12; | 
|---|
| 187 | break; | 
|---|
| 188 | #endif | 
|---|
| 189 | #ifdef ARCH_m68k | 
|---|
| 190 | case bfd_arch_m68k: | 
|---|
| 191 | disassemble = print_insn_m68k; | 
|---|
| 192 | break; | 
|---|
| 193 | #endif | 
|---|
| 194 | #ifdef ARCH_m88k | 
|---|
| 195 | case bfd_arch_m88k: | 
|---|
| 196 | disassemble = print_insn_m88k; | 
|---|
| 197 | break; | 
|---|
| 198 | #endif | 
|---|
| 199 | #ifdef ARCH_ns32k | 
|---|
| 200 | case bfd_arch_ns32k: | 
|---|
| 201 | disassemble = print_insn_ns32k; | 
|---|
| 202 | break; | 
|---|
| 203 | #endif | 
|---|
| 204 | #ifdef ARCH_mcore | 
|---|
| 205 | case bfd_arch_mcore: | 
|---|
| 206 | disassemble = print_insn_mcore; | 
|---|
| 207 | break; | 
|---|
| 208 | #endif | 
|---|
| 209 | #ifdef ARCH_mips | 
|---|
| 210 | case bfd_arch_mips: | 
|---|
| 211 | if (bfd_big_endian (abfd)) | 
|---|
| 212 | disassemble = print_insn_big_mips; | 
|---|
| 213 | else | 
|---|
| 214 | disassemble = print_insn_little_mips; | 
|---|
| 215 | break; | 
|---|
| 216 | #endif | 
|---|
| 217 | #ifdef ARCH_mn10200 | 
|---|
| 218 | case bfd_arch_mn10200: | 
|---|
| 219 | disassemble = print_insn_mn10200; | 
|---|
| 220 | break; | 
|---|
| 221 | #endif | 
|---|
| 222 | #ifdef ARCH_mn10300 | 
|---|
| 223 | case bfd_arch_mn10300: | 
|---|
| 224 | disassemble = print_insn_mn10300; | 
|---|
| 225 | break; | 
|---|
| 226 | #endif | 
|---|
| 227 | #ifdef ARCH_pj | 
|---|
| 228 | case bfd_arch_pj: | 
|---|
| 229 | disassemble = print_insn_pj; | 
|---|
| 230 | break; | 
|---|
| 231 | #endif | 
|---|
| 232 | #ifdef ARCH_powerpc | 
|---|
| 233 | case bfd_arch_powerpc: | 
|---|
| 234 | if (bfd_big_endian (abfd)) | 
|---|
| 235 | disassemble = print_insn_big_powerpc; | 
|---|
| 236 | else | 
|---|
| 237 | disassemble = print_insn_little_powerpc; | 
|---|
| 238 | break; | 
|---|
| 239 | #endif | 
|---|
| 240 | #ifdef ARCH_rs6000 | 
|---|
| 241 | case bfd_arch_rs6000: | 
|---|
| 242 | if (bfd_get_mach (abfd) == bfd_mach_ppc_620) | 
|---|
| 243 | disassemble = print_insn_big_powerpc; | 
|---|
| 244 | else | 
|---|
| 245 | disassemble = print_insn_rs6000; | 
|---|
| 246 | break; | 
|---|
| 247 | #endif | 
|---|
| 248 | #ifdef ARCH_sh | 
|---|
| 249 | case bfd_arch_sh: | 
|---|
| 250 | if (bfd_big_endian (abfd)) | 
|---|
| 251 | disassemble = print_insn_sh; | 
|---|
| 252 | else | 
|---|
| 253 | disassemble = print_insn_shl; | 
|---|
| 254 | break; | 
|---|
| 255 | #endif | 
|---|
| 256 | #ifdef ARCH_sparc | 
|---|
| 257 | case bfd_arch_sparc: | 
|---|
| 258 | disassemble = print_insn_sparc; | 
|---|
| 259 | break; | 
|---|
| 260 | #endif | 
|---|
| 261 | #ifdef ARCH_tic30 | 
|---|
| 262 | case bfd_arch_tic30: | 
|---|
| 263 | disassemble = print_insn_tic30; | 
|---|
| 264 | break; | 
|---|
| 265 | #endif | 
|---|
| 266 | #ifdef ARCH_tic54x | 
|---|
| 267 | case bfd_arch_tic54x: | 
|---|
| 268 | disassemble = print_insn_tic54x; | 
|---|
| 269 | break; | 
|---|
| 270 | #endif | 
|---|
| 271 | #ifdef ARCH_tic80 | 
|---|
| 272 | case bfd_arch_tic80: | 
|---|
| 273 | disassemble = print_insn_tic80; | 
|---|
| 274 | break; | 
|---|
| 275 | #endif | 
|---|
| 276 | #ifdef ARCH_v850 | 
|---|
| 277 | case bfd_arch_v850: | 
|---|
| 278 | disassemble = print_insn_v850; | 
|---|
| 279 | break; | 
|---|
| 280 | #endif | 
|---|
| 281 | #ifdef ARCH_w65 | 
|---|
| 282 | case bfd_arch_w65: | 
|---|
| 283 | disassemble = print_insn_w65; | 
|---|
| 284 | break; | 
|---|
| 285 | #endif | 
|---|
| 286 | #ifdef ARCH_z8k | 
|---|
| 287 | case bfd_arch_z8k: | 
|---|
| 288 | if (bfd_get_mach(abfd) == bfd_mach_z8001) | 
|---|
| 289 | disassemble = print_insn_z8001; | 
|---|
| 290 | else | 
|---|
| 291 | disassemble = print_insn_z8002; | 
|---|
| 292 | break; | 
|---|
| 293 | #endif | 
|---|
| 294 | #ifdef ARCH_vax | 
|---|
| 295 | case bfd_arch_vax: | 
|---|
| 296 | disassemble = print_insn_vax; | 
|---|
| 297 | break; | 
|---|
| 298 | #endif | 
|---|
| 299 | default: | 
|---|
| 300 | return 0; | 
|---|
| 301 | } | 
|---|
| 302 | return disassemble; | 
|---|
| 303 | } | 
|---|
| 304 |  | 
|---|
| 305 | void | 
|---|
| 306 | disassembler_usage (stream) | 
|---|
| 307 | FILE * stream ATTRIBUTE_UNUSED; | 
|---|
| 308 | { | 
|---|
| 309 | #ifdef ARCH_arm | 
|---|
| 310 | print_arm_disassembler_options (stream); | 
|---|
| 311 | #endif | 
|---|
| 312 |  | 
|---|
| 313 | return; | 
|---|
| 314 | } | 
|---|