/* BFD back-end for Hitachi H8/300 COFF binaries.
- Copyright 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
+ Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+ Free Software Foundation, Inc.
Written by Steve Chamberlain, <sac@cygnus.com>.
This file is part of BFD, the Binary File Descriptor library.
#include "bfd.h"
#include "sysdep.h"
-#include "obstack.h"
#include "libbfd.h"
#include "bfdlink.h"
#include "genlink.h"
but it's not easily available here. */
if (bfd_get_mach (table->abfd) == bfd_mach_h8300)
table->offset += 2;
- else if (bfd_get_mach (table->abfd) == bfd_mach_h8300h)
+ else if (bfd_get_mach (table->abfd) == bfd_mach_h8300h
+ || bfd_get_mach (table->abfd) == bfd_mach_h8300s)
table->offset += 4;
else
return NULL;
static bfd_reloc_status_type
special (abfd, reloc_entry, symbol, data, input_section, output_bfd,
error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
+ bfd *abfd ATTRIBUTE_UNUSED;
+ arelent *reloc_entry ATTRIBUTE_UNUSED;
+ asymbol *symbol ATTRIBUTE_UNUSED;
+ PTR data ATTRIBUTE_UNUSED;
+ asection *input_section ATTRIBUTE_UNUSED;
bfd *output_bfd;
- char **error_message;
+ char **error_message ATTRIBUTE_UNUSED;
{
if (output_bfd == (bfd *) NULL)
return bfd_reloc_continue;
#define SELECT_RELOC(x,howto) \
{ x.r_type = select_reloc(howto); }
-#define BADMAG(x) (H8300BADMAG(x)&& H8300HBADMAG(x))
+#define BADMAG(x) (H8300BADMAG(x) && H8300HBADMAG(x) && H8300SBADMAG(x))
#define H8300 1 /* Customize coffcode.h */
#define __A_MAGIC_SET__
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
-/* Perform any necessaru magic to the addend in a reloc entry */
+/* Perform any necessary magic to the addend in a reloc entry */
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
if ((bfd_get_mach (abfd) == bfd_mach_h8300
&& value >= 0xff00
&& value <= 0xffff)
- || (bfd_get_mach (abfd) == bfd_mach_h8300h
+ || ((bfd_get_mach (abfd) == bfd_mach_h8300h
+ || bfd_get_mach (abfd) == bfd_mach_h8300s)
&& value >= 0xffff00
&& value <= 0xffffff))
{
/* The address is in 0xffff00..0xffffff inclusive on the h8300h,
then we can relax this mov.b */
- if (bfd_get_mach (abfd) == bfd_mach_h8300h
+ if ((bfd_get_mach (abfd) == bfd_mach_h8300h
+ || bfd_get_mach (abfd) == bfd_mach_h8300s)
&& value >= 0xffff00
&& value <= 0xffffff)
{
value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
/* Sanity check. */
- if (value < 0xff
+ if (value <= 0xff
|| (value >= 0x0000ff00 && value <= 0x0000ffff)
|| (value >= 0x00ffff00 && value <= 0x00ffffff)
|| (value >= 0xffffff00 && value <= 0xffffffff))
/* Everything looks OK. Apply the relocation and update the
src/dst address appropriately. */
- bfd_put_8 (abfd, gap, data + dst_address);
+ bfd_put_8 (abfd, value & 0xff, data + dst_address);
dst_address += 1;
src_address += 1;
}
symbol = *(reloc->sym_ptr_ptr);
value = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
if (symbol == bfd_abs_section_ptr->symbol
- || (value >= 0 && value <= 0xff))
+ || value <= 0xff)
{
/* This should be handled in a manner very similar to
R_RELBYTES. If the value is in range, then just slam
the value into the right location. Else trigger a
reloc overflow callback. */
- if (value >= 0 && value <= 0xff)
+ if (value <= 0xff)
{
bfd_put_8 (abfd, value, data + dst_address);
dst_address += 1;
link_info,
input_section),
vectors_sec->contents + h->offset);
- else if (bfd_get_mach (input_section->owner) == bfd_mach_h8300h)
+ else if (bfd_get_mach (input_section->owner) == bfd_mach_h8300h
+ || bfd_get_mach (input_section->owner) == bfd_mach_h8300s)
bfd_put_32 (abfd,
bfd_coff_reloc16_get_value (reloc,
link_info,
additional space in the .vectors section as needed. */
for (sec = abfd->sections; sec; sec = sec->next)
{
- unsigned long reloc_size, reloc_count, i;
+ long reloc_size, reloc_count, i;
asymbol **symbols;
arelent **relocs;
saved in the above call. */
symbols = _bfd_generic_link_get_symbols(abfd);
reloc_count = bfd_canonicalize_reloc (abfd, sec, relocs, symbols);
+ if (reloc_count <= 0)
+ {
+ free (relocs);
+ continue;
+ }
/* Now walk through all the relocations in this section. */
for (i = 0; i < reloc_count; i++)
takes 2 bytes on the h8300 and 4 bytes on the h8300h. */
if (bfd_get_mach (abfd) == bfd_mach_h8300)
h8300_coff_hash_table (info)->vectors_sec->_raw_size += 2;
- else if (bfd_get_mach (abfd) == bfd_mach_h8300h)
+ else if (bfd_get_mach (abfd) == bfd_mach_h8300h
+ || bfd_get_mach (abfd) == bfd_mach_h8300s)
h8300_coff_hash_table (info)->vectors_sec->_raw_size += 4;
}
}
#define coff_bfd_relax_section bfd_coff_reloc16_relax_section
-
-const bfd_target h8300coff_vec =
-{
- "coff-h8300", /* name */
- bfd_target_coff_flavour,
- BFD_ENDIAN_BIG, /* data byte order is big */
- BFD_ENDIAN_BIG, /* header byte order is big */
-
- (HAS_RELOC | EXEC_P | /* object flags */
- HAS_LINENO | HAS_DEBUG |
- HAS_SYMS | HAS_LOCALS | WP_TEXT | BFD_IS_RELAXABLE ),
- (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- '_', /* leading char */
- '/', /* ar_pad_char */
- 15, /* ar_max_namelen */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
- bfd_getb64, bfd_getb_signed_64, bfd_putb64,
- bfd_getb32, bfd_getb_signed_32, bfd_putb32,
- bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
-
- {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
- bfd_generic_archive_p, _bfd_dummy_target},
- {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
- bfd_false},
- {bfd_false, coff_write_object_contents, /* bfd_write_contents */
- _bfd_write_archive_contents, bfd_false},
-
- BFD_JUMP_TABLE_GENERIC (coff),
- BFD_JUMP_TABLE_COPY (coff),
- BFD_JUMP_TABLE_CORE (_bfd_nocore),
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
- BFD_JUMP_TABLE_SYMBOLS (coff),
- BFD_JUMP_TABLE_RELOCS (coff),
- BFD_JUMP_TABLE_WRITE (coff),
- BFD_JUMP_TABLE_LINK (coff),
- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
- COFF_SWAP_TABLE,
-};
+CREATE_BIG_COFF_TARGET_VEC (h8300coff_vec, "coff-h8300", BFD_IS_RELAXABLE, 0, '_', NULL)