/[gcl]/gcl/binutils/bfd/coff-z8k.c
ViewVC logotype

Diff of /gcl/binutils/bfd/coff-z8k.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by camm, Fri Aug 9 05:34:55 2002 UTC revision 1.2 by camm, Fri Sep 9 23:32:07 2005 UTC
# Line 1  Line 1 
1  /* BFD back-end for Zilog Z800n COFF binaries.  /* BFD back-end for Zilog Z800n COFF binaries.
2     Copyright 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001     Copyright 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
3     Free Software Foundation, Inc.     2004 Free Software Foundation, Inc.
4     Contributed by Cygnus Support.     Contributed by Cygnus Support.
5     Written by Steve Chamberlain, <sac@cygnus.com>.     Written by Steve Chamberlain, <sac@cygnus.com>.
6    
# Line 28  Foundation, Inc., 59 Temple Place - Suit Line 28  Foundation, Inc., 59 Temple Place - Suit
28  #include "coff/internal.h"  #include "coff/internal.h"
29  #include "libcoff.h"  #include "libcoff.h"
30    
 static void extra_case PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *, bfd_byte *, unsigned int *, unsigned int *));  
 static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));  
 static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));  
 static int coff_z8k_select_reloc PARAMS ((reloc_howto_type *));  
   
31  #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)  #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
32    
33  static reloc_howto_type r_imm32 =  static reloc_howto_type r_imm32 =
34  HOWTO (R_IMM32, 0, 2, 32, false, 0,  HOWTO (R_IMM32, 0, 2, 32, FALSE, 0,
35         complain_overflow_bitfield, 0, "r_imm32", true, 0xffffffff,         complain_overflow_bitfield, 0, "r_imm32", TRUE, 0xffffffff,
36         0xffffffff, false);         0xffffffff, FALSE);
37    
38  static reloc_howto_type r_imm4l =  static reloc_howto_type r_imm4l =
39  HOWTO (R_IMM4L, 0, 0, 4, false, 0,  HOWTO (R_IMM4L, 0, 0, 4, FALSE, 0,
40         complain_overflow_bitfield, 0, "r_imm4l", true, 0xf, 0xf, false);         complain_overflow_bitfield, 0, "r_imm4l", TRUE, 0xf, 0xf, FALSE);
41    
42  static reloc_howto_type r_da =  static reloc_howto_type r_da =
43  HOWTO (R_IMM16, 0, 1, 16, false, 0,  HOWTO (R_IMM16, 0, 1, 16, FALSE, 0,
44         complain_overflow_bitfield, 0, "r_da", true, 0x0000ffff, 0x0000ffff,         complain_overflow_bitfield, 0, "r_da", TRUE, 0x0000ffff, 0x0000ffff,
45         false);         FALSE);
46    
47  static reloc_howto_type r_imm8 =  static reloc_howto_type r_imm8 =
48  HOWTO (R_IMM8, 0, 0, 8, false, 0,  HOWTO (R_IMM8, 0, 0, 8, FALSE, 0,
49         complain_overflow_bitfield, 0, "r_imm8", true, 0x000000ff, 0x000000ff,         complain_overflow_bitfield, 0, "r_imm8", TRUE, 0x000000ff, 0x000000ff,
50         false);         FALSE);
51    
52  static reloc_howto_type r_rel16 =  static reloc_howto_type r_rel16 =
53  HOWTO (R_REL16, 0, 1, 16, false, 0,  HOWTO (R_REL16, 0, 1, 16, FALSE, 0,
54         complain_overflow_bitfield, 0, "r_rel16", true, 0x0000ffff, 0x0000ffff,         complain_overflow_bitfield, 0, "r_rel16", TRUE, 0x0000ffff, 0x0000ffff,
55         true);         TRUE);
56    
57  static reloc_howto_type r_jr =  static reloc_howto_type r_jr =
58  HOWTO (R_JR, 0, 0, 8, true, 0, complain_overflow_signed, 0,  HOWTO (R_JR, 0, 0, 8, TRUE, 0, complain_overflow_signed, 0,
59         "r_jr", true, 0, 0, true);         "r_jr", TRUE, 0, 0, TRUE);
60    
61  static reloc_howto_type r_disp7 =  static reloc_howto_type r_disp7 =
62  HOWTO (R_DISP7, 0, 0, 7, true, 0, complain_overflow_bitfield, 0,  HOWTO (R_DISP7, 0, 0, 7, TRUE, 0, complain_overflow_bitfield, 0,
63         "r_disp7", true, 0, 0, true);         "r_disp7", TRUE, 0, 0, TRUE);
64    
65  static reloc_howto_type r_callr =  static reloc_howto_type r_callr =
66  HOWTO (R_CALLR, 0, 1, 12, true, 0, complain_overflow_signed, 0,  HOWTO (R_CALLR, 0, 1, 12, TRUE, 0, complain_overflow_signed, 0,
67         "r_callr", true, 0xfff, 0xfff, true);         "r_callr", TRUE, 0xfff, 0xfff, TRUE);
68    
69  /* Turn a howto into a reloc number */  /* Turn a howto into a reloc number */
70    
71  static int  static int
72  coff_z8k_select_reloc (howto)  coff_z8k_select_reloc (reloc_howto_type *howto)
      reloc_howto_type *howto;  
73  {  {
74    return howto->type;    return howto->type;
75  }  }
# Line 96  coff_z8k_select_reloc (howto) Line 90  coff_z8k_select_reloc (howto)
90  /* Code to turn a r_type into a howto ptr, uses the above howto table.  */  /* Code to turn a r_type into a howto ptr, uses the above howto table.  */
91    
92  static void  static void
93  rtype2howto (internal, dst)  rtype2howto (arelent *internal, struct internal_reloc *dst)
      arelent * internal;  
      struct internal_reloc *dst;  
94  {  {
95    switch (dst->r_type)    switch (dst->r_type)
96      {      {
# Line 143  rtype2howto (internal, dst) Line 135  rtype2howto (internal, dst)
135   reloc_processing(relent, reloc, symbols, abfd, section)   reloc_processing(relent, reloc, symbols, abfd, section)
136    
137  static void  static void
138  reloc_processing (relent, reloc, symbols, abfd, section)  reloc_processing (arelent *relent,
139       arelent * relent;                    struct internal_reloc *reloc,
140       struct internal_reloc * reloc;                    asymbol **symbols,
141       asymbol ** symbols;                    bfd *abfd,
142       bfd * abfd;                    asection *section)
      asection * section;  
143  {  {
144    relent->address = reloc->r_vaddr;    relent->address = reloc->r_vaddr;
145    rtype2howto (relent, reloc);    rtype2howto (relent, reloc);
# Line 163  reloc_processing (relent, reloc, symbols Line 154  reloc_processing (relent, reloc, symbols
154  }  }
155    
156  static void  static void
157  extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)  extra_case (bfd *in_abfd,
158       bfd * in_abfd;              struct bfd_link_info *link_info,
159       struct bfd_link_info * link_info;              struct bfd_link_order *link_order,
160       struct bfd_link_order * link_order;              arelent *reloc,
161       arelent * reloc;              bfd_byte *data,
162       bfd_byte * data;              unsigned int *src_ptr,
163       unsigned int * src_ptr;              unsigned int *dst_ptr)
      unsigned int * dst_ptr;  
164  {  {
165    asection * input_section = link_order->u.indirect.section;    asection * input_section = link_order->u.indirect.section;
166    
# Line 197  extra_case (in_abfd, link_info, link_ord Line 187  extra_case (in_abfd, link_info, link_ord
187          {          {
188            bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,            bfd_vma dst = bfd_coff_reloc16_get_value (reloc, link_info,
189                                                      input_section);                                                      input_section);
190            /* Adresses are 23 bit, and the layout of those in a 32-bit            /* Addresses are 23 bit, and the layout of those in a 32-bit
191               value is as follows:               value is as follows:
192                 1AAAAAAA xxxxxxxx AAAAAAAA AAAAAAAA                 1AAAAAAA xxxxxxxx AAAAAAAA AAAAAAAA
193               (A - address bits,  x - ignore).  */               (A - address bits,  x - ignore).  */
# Line 243  extra_case (in_abfd, link_info, link_ord Line 233  extra_case (in_abfd, link_info, link_ord
233          if (gap > 128 || gap < -128)          if (gap > 128 || gap < -128)
234            {            {
235              if (! ((*link_info->callbacks->reloc_overflow)              if (! ((*link_info->callbacks->reloc_overflow)
236                     (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),                     (link_info, NULL,
237                        bfd_asymbol_name (*reloc->sym_ptr_ptr),
238                      reloc->howto->name, reloc->addend, input_section->owner,                      reloc->howto->name, reloc->addend, input_section->owner,
239                      input_section, reloc->address)))                      input_section, reloc->address)))
240                abort ();                abort ();
# Line 268  extra_case (in_abfd, link_info, link_ord Line 259  extra_case (in_abfd, link_info, link_ord
259            abort ();            abort ();
260          gap /= 2;          gap /= 2;
261    
262          if (gap > 0 || gap < -128)          if (gap > 0 || gap < -127)
263            {            {
264              if (! ((*link_info->callbacks->reloc_overflow)              if (! ((*link_info->callbacks->reloc_overflow)
265                     (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),                     (link_info, NULL,
266                        bfd_asymbol_name (*reloc->sym_ptr_ptr),
267                      reloc->howto->name, reloc->addend, input_section->owner,                      reloc->howto->name, reloc->addend, input_section->owner,
268                      input_section, reloc->address)))                      input_section, reloc->address)))
269                abort ();                abort ();
# Line 295  extra_case (in_abfd, link_info, link_ord Line 287  extra_case (in_abfd, link_info, link_ord
287    
288          if (gap & 1)          if (gap & 1)
289            abort ();            abort ();
290          gap /= 2;          if (gap > 4096 || gap < -4095)
         if (gap > 8191 || gap < -8192)  
291            {            {
292              if (! ((*link_info->callbacks->reloc_overflow)              if (! ((*link_info->callbacks->reloc_overflow)
293                     (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),                     (link_info, NULL,
294                        bfd_asymbol_name (*reloc->sym_ptr_ptr),
295                      reloc->howto->name, reloc->addend, input_section->owner,                      reloc->howto->name, reloc->addend, input_section->owner,
296                      input_section, reloc->address)))                      input_section, reloc->address)))
297                abort ();                abort ();
298            }            }
299            gap /= 2;
300          bfd_put_16 (in_abfd,          bfd_put_16 (in_abfd,
301                      (bfd_get_16 ( in_abfd, data + *dst_ptr) & 0xf000) | (-gap & 0x0fff),                      (bfd_get_16 ( in_abfd, data + *dst_ptr) & 0xf000) | (-gap & 0x0fff),
302                      data + *dst_ptr);                      data + *dst_ptr);
# Line 324  extra_case (in_abfd, link_info, link_ord Line 317  extra_case (in_abfd, link_info, link_ord
317          if (gap > 32767 || gap < -32768)          if (gap > 32767 || gap < -32768)
318            {            {
319              if (! ((*link_info->callbacks->reloc_overflow)              if (! ((*link_info->callbacks->reloc_overflow)
320                     (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr),                     (link_info, NULL,
321                        bfd_asymbol_name (*reloc->sym_ptr_ptr),
322                      reloc->howto->name, reloc->addend, input_section->owner,                      reloc->howto->name, reloc->addend, input_section->owner,
323                      input_section, reloc->address)))                      input_section, reloc->address)))
324                abort ();                abort ();
# Line 350  extra_case (in_abfd, link_info, link_ord Line 344  extra_case (in_abfd, link_info, link_ord
344    bfd_coff_reloc16_get_relocated_section_contents    bfd_coff_reloc16_get_relocated_section_contents
345  #define coff_bfd_relax_section bfd_coff_reloc16_relax_section  #define coff_bfd_relax_section bfd_coff_reloc16_relax_section
346    
347  CREATE_BIG_COFF_TARGET_VEC (z8kcoff_vec, "coff-z8k", 0, 0, '_', NULL)  CREATE_BIG_COFF_TARGET_VEC (z8kcoff_vec, "coff-z8k", 0, 0, '_', NULL, COFF_SWAP_TABLE)

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26