home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / gnu / gdb-4.12.tar.gz / gdb-4.12.tar / gdb-4.12 / bfd / cpu-z8k.c < prev    next >
C/C++ Source or Header  |  1994-02-03  |  5KB  |  205 lines

  1. /* BFD library support routines for the Z800n architecture.
  2.    Copyright (C) 1992 Free Software Foundation, Inc.
  3.    Hacked by Steve Chamberlain of Cygnus Support.
  4.  
  5. This file is part of BFD, the Binary File Descriptor library.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  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
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #include "bfd.h"
  22. #include "sysdep.h"
  23. #include "libbfd.h"
  24.  
  25.  
  26. #if 0 /* not used currently */
  27. /* 
  28. Relocations for the Z8K
  29.  
  30. */
  31. static bfd_reloc_status_type 
  32. DEFUN(howto16_callback,(abfd, reloc_entry, symbol_in, data,
  33.             ignore_input_section, ignore_bfd),
  34.       bfd *abfd AND
  35.       arelent *reloc_entry AND
  36.       struct symbol_cache_entry *symbol_in AND
  37.       PTR data AND
  38.       asection *ignore_input_section AND
  39.       bfd *ignore_bfd)
  40. {
  41.   long relocation = 0;
  42.   bfd_vma addr = reloc_entry->address;
  43.   long x = bfd_get_16(abfd, (bfd_byte *)data + addr);
  44.  
  45.   HOWTO_PREPARE(relocation, symbol_in);
  46.  
  47.   x = (x + relocation + reloc_entry->addend);
  48.  
  49.   bfd_put_16(abfd, x, (bfd_byte *)data + addr);
  50.   return bfd_reloc_ok;
  51. }
  52.  
  53.  
  54. static bfd_reloc_status_type 
  55. DEFUN(howto8_callback,(abfd, reloc_entry, symbol_in, data,
  56.                ignore_input_section, ignore_bfd),
  57.       bfd *abfd AND
  58.       arelent *reloc_entry AND
  59.       struct symbol_cache_entry *symbol_in AND
  60.       PTR data AND
  61.       asection *ignore_input_section AND
  62.       bfd *ignore_bfd)
  63. {
  64.   long relocation = 0;
  65.   bfd_vma addr = reloc_entry->address;
  66.   long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
  67.  
  68.   HOWTO_PREPARE(relocation, symbol_in);
  69.  
  70.   x = (x + relocation + reloc_entry->addend);
  71.  
  72.   bfd_put_8(abfd, x, (bfd_byte *)data + addr);
  73.   return bfd_reloc_ok;
  74. }
  75.  
  76.  
  77. static bfd_reloc_status_type 
  78. DEFUN(howto8_FFnn_callback,(abfd, reloc_entry, symbol_in, data,
  79.                 ignore_input_section, ignore_bfd),
  80.       bfd *abfd AND
  81.       arelent *reloc_entry AND
  82.       struct symbol_cache_entry *symbol_in AND
  83.       PTR data AND
  84.       asection *ignore_input_section AND
  85.       bfd *ignore_bfd)
  86. {
  87.   long relocation = 0;
  88.   bfd_vma addr = reloc_entry->address;
  89.  
  90.   long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
  91.   abort();
  92.   HOWTO_PREPARE(relocation, symbol_in);
  93.  
  94.   x = (x + relocation + reloc_entry->addend);
  95.  
  96.   bfd_put_8(abfd, x, (bfd_byte *)data + addr);
  97.   return bfd_reloc_ok;
  98. }
  99.  
  100. static bfd_reloc_status_type 
  101. DEFUN(howto8_pcrel_callback,(abfd, reloc_entry, symbol_in, data,
  102.                  ignore_input_section, ignore_bfd),
  103.       bfd *abfd AND
  104.       arelent *reloc_entry AND
  105.       struct symbol_cache_entry *symbol_in AND
  106.       PTR data AND
  107.       asection *ignore_input_section AND
  108.       bfd *ignore_bfd)
  109. {
  110.   long relocation = 0;
  111.   bfd_vma addr = reloc_entry->address;
  112.   long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
  113.   abort();
  114.   HOWTO_PREPARE(relocation, symbol_in);
  115.  
  116.   x = (x + relocation + reloc_entry->addend);
  117.  
  118.   bfd_put_8(abfd, x, (bfd_byte *)data + addr);
  119.   return bfd_reloc_ok;
  120. }
  121.  
  122.  
  123.  
  124. static reloc_howto_type howto_16
  125.   = NEWHOWTO(howto16_callback,"abs16",1,false,false);
  126. static reloc_howto_type howto_8
  127.   = NEWHOWTO(howto8_callback,"abs8",0,false,false);
  128.  
  129. static reloc_howto_type howto_8_FFnn
  130.   = NEWHOWTO(howto8_FFnn_callback,"ff00+abs8",0,false,false);
  131.  
  132. static reloc_howto_type howto_8_pcrel
  133.   = NEWHOWTO(howto8_pcrel_callback,"pcrel8",0,false,true);
  134.  
  135.  
  136. static CONST struct reloc_howto_struct *
  137. DEFUN(local_bfd_reloc_type_lookup,(arch, code),
  138.  CONST struct bfd_arch_info *arch AND
  139.  bfd_reloc_code_real_type code)
  140. {
  141.   switch (code) {
  142.   case BFD_RELOC_16:
  143.     return &howto_16;
  144.   case BFD_RELOC_8_FFnn:
  145.     return &howto_8_FFnn;
  146.   case BFD_RELOC_8:
  147.     return &howto_8;
  148.   case BFD_RELOC_8_PCREL:
  149.     return &howto_8_pcrel;
  150.   default:
  151.     return (reloc_howto_type *)NULL;
  152.   }
  153. }
  154. #endif
  155.  
  156. int bfd_default_scan_num_mach();
  157.  
  158. static boolean 
  159. DEFUN(scan_mach,(info, string),
  160. CONST struct bfd_arch_info *info AND
  161. CONST char *string)
  162. {
  163.   if (strcmp(string,"z8001") == 0 || strcmp(string,"z8k") == 0) 
  164.   {
  165.     return bfd_mach_z8001 == info->mach;
  166.   }
  167.   if (strcmp(string,"z8002") == 0) 
  168.   {
  169.     return bfd_mach_z8002 == info->mach;
  170.   }
  171.   return false;
  172. }
  173.  
  174.  
  175. /* This routine is provided two arch_infos and returns whether
  176.    they'd be compatible */
  177.  
  178. static CONST bfd_arch_info_type *
  179. DEFUN(compatible,(a,b),
  180.       CONST bfd_arch_info_type *a AND
  181.       CONST bfd_arch_info_type *b)
  182. {
  183.   if (a->arch != b->arch || a->mach != b->mach)
  184.    return NULL;
  185.   return a;
  186. }
  187.  
  188.  
  189. static bfd_arch_info_type arch_info_struct[] = 
  190.   { 32, 16, 8, bfd_arch_z8k, bfd_mach_z8002, "z8k", "z8002", 1, false, compatible, scan_mach, 0,},
  191.   { 32, 32, 8, bfd_arch_z8k, bfd_mach_z8001, "z8k", "z8001", 1, true, compatible, scan_mach, 0,},
  192. };
  193.  
  194.  
  195.  
  196. void
  197. DEFUN_VOID(bfd_z8k_arch)
  198. {
  199.   bfd_arch_linkin(&arch_info_struct[0]);
  200.   bfd_arch_linkin(&arch_info_struct[1]);
  201. }
  202.  
  203.  
  204.