diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2003-07-11 14:59:41 +0000 |
---|---|---|
committer | Richard Sandiford <rdsandiford@googlemail.com> | 2003-07-11 14:59:41 +0000 |
commit | 7a9823f1a9d50e9541153fd77c692f389c8c081c (patch) | |
tree | faff27fedc6d18fe09b0c30a9113094cab0f07d7 /bfd/coff-h8300.c | |
parent | 91f78506d286a335cbe3d195abfa98e7136b5823 (diff) | |
download | gdb-7a9823f1a9d50e9541153fd77c692f389c8c081c.zip gdb-7a9823f1a9d50e9541153fd77c692f389c8c081c.tar.gz gdb-7a9823f1a9d50e9541153fd77c692f389c8c081c.tar.bz2 |
bfd/
* bfd-in.h (bfd_h8300_pad_address): Declare.
* bfd-in2.h: Regenerate.
* cpu-h8300.c (bfd_h8300_pad_address): New function.
* coff-h8300.c (h8300_reloc16_estimate): Use it to canonicalize
addresses before checking whether they can be relaxed.
(h8300_reloc16_extra_cases): Likewise for the R_MOVL2 sanity check.
Don't complain about overflows in general 8-bit relocations.
* elf32-h8300.c (elf32_h8_relax_section): Use bfd_h8300_pad_address.
Fix handling of R_H8_DIR24A8.
ld/testsuite/
* ld-h8300/relax-3{.s,.d,-coff.d}: New test.
* ld-h8300/h8300.exp: Run it.
Diffstat (limited to 'bfd/coff-h8300.c')
-rw-r--r-- | bfd/coff-h8300.c | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c index 23286f8..bfe31c6 100644 --- a/bfd/coff-h8300.c +++ b/bfd/coff-h8300.c @@ -573,17 +573,11 @@ h8300_reloc16_estimate (bfd *abfd, asection *input_section, arelent *reloc, case R_MOV16B1: /* Get the address of the data referenced by this mov.b insn. */ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section); + value = bfd_h8300_pad_address (abfd, value); - /* The address is in 0xff00..0xffff inclusive on the h8300 or - 0xffff00..0xffffff inclusive on the h8300h, then we can - relax this mov.b */ - 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_h8300s) - && value >= 0xffff00 - && value <= 0xffffff)) + /* If the address is in the top 256 bytes of the address space + then we can relax this instruction. */ + if (value >= 0xffffff00u) { /* Change the reloc type. */ reloc->howto = reloc->howto + 1; @@ -600,13 +594,9 @@ h8300_reloc16_estimate (bfd *abfd, asection *input_section, arelent *reloc, case R_MOV24B1: /* Get the address of the data referenced by this mov.b insn. */ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section); + value = bfd_h8300_pad_address (abfd, value); - /* 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 - || bfd_get_mach (abfd) == bfd_mach_h8300s) - && value >= 0xffff00 - && value <= 0xffffff) + if (value >= 0xffffff00u) { /* Change the reloc type. */ reloc->howto = reloc->howto + 1; @@ -627,10 +617,11 @@ h8300_reloc16_estimate (bfd *abfd, asection *input_section, arelent *reloc, case R_MOVL1: /* Get the address of the data referenced by this mov insn. */ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section); + value = bfd_h8300_pad_address (abfd, value); - /* If this address is in 0x0000..0x7fff inclusive or - 0xff8000..0xffffff inclusive, then it can be relaxed. */ - if (value <= 0x7fff || value >= 0xff8000) + /* If the address is a sign-extended 16-bit value then we can + relax this instruction. */ + if (value <= 0x7fff || value >= 0xffff8000u) { /* Change the reloc type. */ reloc->howto = howto_table + 17; @@ -737,26 +728,9 @@ h8300_reloc16_extra_cases (bfd *abfd, struct bfd_link_info *link_info, /* Get the address of the object referenced by this insn. */ value = bfd_coff_reloc16_get_value (reloc, link_info, input_section); - /* Sanity check. */ - 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, value & 0xff, data + dst_address); - dst_address += 1; - src_address += 1; - } - else - { - if (! ((*link_info->callbacks->reloc_overflow) - (link_info, bfd_asymbol_name (*reloc->sym_ptr_ptr), - reloc->howto->name, reloc->addend, input_section->owner, - input_section, reloc->address))) - abort (); - } + bfd_put_8 (abfd, value & 0xff, data + dst_address); + dst_address += 1; + src_address += 1; /* All done. */ break; @@ -798,9 +772,10 @@ h8300_reloc16_extra_cases (bfd *abfd, struct bfd_link_info *link_info, absolute relocation. */ case R_MOVL2: value = bfd_coff_reloc16_get_value (reloc, link_info, input_section); + value = bfd_h8300_pad_address (abfd, value); /* Sanity check. */ - if (value <= 0x7fff || value >= 0xff8000) + if (value <= 0x7fff || value >= 0xffff8000u) { /* Insert the 16bit value into the proper location. */ bfd_put_16 (abfd, value, data + dst_address); |