1 /* BFD back-end for Hitachi Super-H COFF binaries.
2 Copyright 1993, 1994 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
4 Written by Steve Chamberlain, <sac@cygnus.com>.
6 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
28 #include "coff/internal.h"
31 static reloc_howto_type r_imm32
=
32 HOWTO (R_SH_IMM32
, 0,2, 32, false, 0,
33 complain_overflow_bitfield
, 0, "r_imm32", false, 0x0, 0xffffffff,
38 /* Turn a howto into a reloc number */
41 coff_SH_select_reloc (howto
)
42 reloc_howto_type
*howto
;
47 #define SELECT_RELOC(x,howto) x.r_type = coff_SH_select_reloc(howto)
50 #define BADMAG(x) SHBADMAG(x)
51 #define SH 1 /* Customize coffcode.h */
53 #define __A_MAGIC_SET__
55 /* Code to swap in the reloc */
56 #define SWAP_IN_RELOC_OFFSET bfd_h_get_32
57 #define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
58 #define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
59 dst->r_stuff[0] = 'S'; \
60 dst->r_stuff[1] = 'C';
62 /* Code to turn a r_type into a howto ptr, uses the above howto table
66 rtype2howto (internal
, dst
)
68 struct internal_reloc
*dst
;
73 fprintf (stderr
, "BAD 0x%x\n", dst
->r_type
);
75 internal
->howto
= &r_imm32
;
80 #define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
83 /* Perform any necessaru magic to the addend in a reloc entry */
86 #define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
87 cache_ptr->addend = ext_reloc.r_offset;
90 #define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
91 reloc_processing(relent, reloc, symbols, abfd, section)
94 reloc_processing (relent
, reloc
, symbols
, abfd
, section
)
96 struct internal_reloc
*reloc
;
101 relent
->address
= reloc
->r_vaddr
;
102 rtype2howto (relent
, reloc
);
104 if (reloc
->r_symndx
> 0)
106 relent
->sym_ptr_ptr
= symbols
+ obj_convert (abfd
)[reloc
->r_symndx
];
110 relent
->sym_ptr_ptr
= &(bfd_abs_symbol
);
114 relent
->addend
= reloc
->r_offset
;
115 relent
->address
-= section
->vma
;
119 extra_case (in_abfd
, link_info
, link_order
, reloc
, data
, src_ptr
, dst_ptr
)
121 struct bfd_link_info
*link_info
;
122 struct bfd_link_order
*link_order
;
125 unsigned int *src_ptr
;
126 unsigned int *dst_ptr
;
128 switch (reloc
->howto
->type
)
132 int v
= bfd_coff_reloc16_get_value(reloc
, link_info
,
133 link_order
->u
.indirect
.section
);
134 bfd_put_32 (in_abfd
, v
, data
+ *dst_ptr
);
145 #define coff_reloc16_extra_cases extra_case
147 #include "coffcode.h"
150 #undef coff_bfd_get_relocated_section_contents
151 #undef coff_bfd_relax_section
152 #define coff_bfd_get_relocated_section_contents \
153 bfd_coff_reloc16_get_relocated_section_contents
154 #define coff_bfd_relax_section bfd_coff_reloc16_relax_section
156 const bfd_target shcoff_vec
=
158 "coff-sh", /* name */
159 bfd_target_coff_flavour
,
160 true, /* data byte order is big */
161 true, /* header byte order is big */
163 (HAS_RELOC
| EXEC_P
| /* object flags */
164 HAS_LINENO
| HAS_DEBUG
|
165 HAS_SYMS
| HAS_LOCALS
| WP_TEXT
| BFD_IS_RELAXABLE
),
167 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
168 '_', /* leading symbol underscore */
169 '/', /* ar_pad_char */
170 15, /* ar_max_namelen */
171 2, /* minimum section alignment */
172 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
173 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
174 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* data */
175 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
176 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
177 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* hdrs */
179 {_bfd_dummy_target
, coff_object_p
, /* bfd_check_format */
180 bfd_generic_archive_p
, _bfd_dummy_target
},
181 {bfd_false
, coff_mkobject
, _bfd_generic_mkarchive
, /* bfd_set_format */
183 {bfd_false
, coff_write_object_contents
, /* bfd_write_contents */
184 _bfd_write_archive_contents
, bfd_false
},
186 BFD_JUMP_TABLE_GENERIC (coff
),
187 BFD_JUMP_TABLE_COPY (coff
),
188 BFD_JUMP_TABLE_CORE (_bfd_nocore
),
189 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff
),
190 BFD_JUMP_TABLE_SYMBOLS (coff
),
191 BFD_JUMP_TABLE_RELOCS (coff
),
192 BFD_JUMP_TABLE_WRITE (coff
),
193 BFD_JUMP_TABLE_LINK (coff
),
194 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic
),