~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to binutils/bfd/cpu-z8k.c

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* BFD library support routines for the Z800n architecture.
 
2
   Copyright 1992, 1993, 1994, 2000, 2001 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
20
 
 
21
#include "bfd.h"
 
22
#include "sysdep.h"
 
23
#include "libbfd.h"
 
24
 
 
25
static boolean scan_mach
 
26
  PARAMS ((const struct bfd_arch_info *, const char *));
 
27
static const bfd_arch_info_type *compatible
 
28
  PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
 
29
 
 
30
#if 0                           /* not used currently */
 
31
/*
 
32
Relocations for the Z8K
 
33
 
 
34
*/
 
35
static bfd_reloc_status_type
 
36
howto16_callback (abfd, reloc_entry, symbol_in, data,
 
37
                  ignore_input_section, ignore_bfd)
 
38
     bfd *abfd;
 
39
     arelent *reloc_entry;
 
40
     struct symbol_cache_entry *symbol_in;
 
41
     PTR data;
 
42
     asection *ignore_input_section;
 
43
     bfd *ignore_bfd;
 
44
{
 
45
  long relocation = 0;
 
46
  bfd_vma addr = reloc_entry->address;
 
47
  long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
 
48
 
 
49
  HOWTO_PREPARE (relocation, symbol_in);
 
50
 
 
51
  x = (x + relocation + reloc_entry->addend);
 
52
 
 
53
  bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
 
54
  return bfd_reloc_ok;
 
55
}
 
56
 
 
57
static bfd_reloc_status_type
 
58
howto8_callback (abfd, reloc_entry, symbol_in, data,
 
59
                 ignore_input_section, ignore_bfd)
 
60
     bfd *abfd;
 
61
     arelent *reloc_entry;
 
62
     struct symbol_cache_entry *symbol_in;
 
63
     PTR data;
 
64
     asection *ignore_input_section;
 
65
     bfd *ignore_bfd;
 
66
{
 
67
  long relocation = 0;
 
68
  bfd_vma addr = reloc_entry->address;
 
69
  long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
 
70
 
 
71
  HOWTO_PREPARE (relocation, symbol_in);
 
72
 
 
73
  x = (x + relocation + reloc_entry->addend);
 
74
 
 
75
  bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
 
76
  return bfd_reloc_ok;
 
77
}
 
78
 
 
79
static bfd_reloc_status_type
 
80
howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
 
81
                      ignore_input_section, ignore_bfd)
 
82
     bfd *abfd;
 
83
     arelent *reloc_entry;
 
84
     struct symbol_cache_entry *symbol_in;
 
85
     PTR data;
 
86
     asection *ignore_input_section;
 
87
     bfd *ignore_bfd;
 
88
{
 
89
  long relocation = 0;
 
90
  bfd_vma addr = reloc_entry->address;
 
91
 
 
92
  long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
 
93
  abort ();
 
94
  HOWTO_PREPARE (relocation, symbol_in);
 
95
 
 
96
  x = (x + relocation + reloc_entry->addend);
 
97
 
 
98
  bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
 
99
  return bfd_reloc_ok;
 
100
}
 
101
 
 
102
static bfd_reloc_status_type
 
103
howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
 
104
                       ignore_input_section, ignore_bfd)
 
105
     bfd *abfd;
 
106
     arelent *reloc_entry;
 
107
     struct symbol_cache_entry *symbol_in;
 
108
     PTR data;
 
109
     asection *ignore_input_section;
 
110
     bfd *ignore_bfd;
 
111
{
 
112
  long relocation = 0;
 
113
  bfd_vma addr = reloc_entry->address;
 
114
  long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
 
115
  abort ();
 
116
  HOWTO_PREPARE (relocation, symbol_in);
 
117
 
 
118
  x = (x + relocation + reloc_entry->addend);
 
119
 
 
120
  bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
 
121
  return bfd_reloc_ok;
 
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
static reloc_howto_type *
 
136
local_bfd_reloc_type_lookup (arch, code)
 
137
     const struct bfd_arch_info *arch;
 
138
     bfd_reloc_code_real_type code;
 
139
{
 
140
  switch (code)
 
141
    {
 
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
static boolean
 
157
scan_mach (info, string)
 
158
     const struct bfd_arch_info *info;
 
159
     const char *string;
 
160
{
 
161
  if (strcmp (string, "z8001") == 0 || strcmp (string, "z8k") == 0)
 
162
    {
 
163
      return bfd_mach_z8001 == info->mach;
 
164
    }
 
165
  if (strcmp (string, "z8002") == 0)
 
166
    {
 
167
      return bfd_mach_z8002 == info->mach;
 
168
    }
 
169
  return false;
 
170
}
 
171
 
 
172
/* This routine is provided two arch_infos and returns whether
 
173
   they'd be compatible */
 
174
 
 
175
static const bfd_arch_info_type *
 
176
compatible (a, b)
 
177
     const bfd_arch_info_type *a;
 
178
     const bfd_arch_info_type *b;
 
179
{
 
180
  if (a->arch != b->arch || a->mach != b->mach)
 
181
    return NULL;
 
182
  return a;
 
183
}
 
184
 
 
185
static const bfd_arch_info_type arch_info_struct[] =
 
186
{
 
187
  {32, 32, 8, bfd_arch_z8k, bfd_mach_z8001, "z8k", "z8001", 1, false, compatible, scan_mach, 0,},
 
188
};
 
189
 
 
190
const bfd_arch_info_type bfd_z8k_arch =
 
191
{
 
192
  32, 16, 8, bfd_arch_z8k, bfd_mach_z8002, "z8k", "z8002", 1, true, compatible, scan_mach, &arch_info_struct[0],
 
193
};