summaryrefslogtreecommitdiff
path: root/bfd/elf32-h8300.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2001-08-30 02:15:58 +0000
committerJeff Law <law@redhat.com>2001-08-30 02:15:58 +0000
commit4d8e5c5a3e5336878a31f6aa92f9c181b6fd71b3 (patch)
treec9a61d305913cf3ee52fc450692b1aeb21bf509c /bfd/elf32-h8300.c
parent3d0d67201d65aafca414fd987fdb6e1835b6e64d (diff)
downloadgdb-4d8e5c5a3e5336878a31f6aa92f9c181b6fd71b3.tar.gz
* elf32-h8300.c (h8_elf_howto_table): Add new PC relative
relocations. (h8_reloc_map): Similarly. (elf32_h8_final_link_relocate): Remove incorrect overflow tests. Add support for PC relative relocations.
Diffstat (limited to 'bfd/elf32-h8300.c')
-rw-r--r--bfd/elf32-h8300.c54
1 files changed, 48 insertions, 6 deletions
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index 786787ce963..531088b76d9 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -171,6 +171,34 @@ static reloc_howto_type h8_elf_howto_table[] =
0, /* src_mask */
0xffffffff, /* dst_mask */
false), /* pcrel_offset */
+#define R_H8_PCREL16_X (R_H8_DIR32A16_X + 1)
+ HOWTO (R_H8_PCREL16, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_H8_PCREL16", /* name */
+ false, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ true), /* pcrel_offset */
+#define R_H8_PCREL8_X (R_H8_PCREL16_X + 1)
+ HOWTO (R_H8_PCREL8, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ NULL, /* special_function */
+ "R_H8_PCREL8", /* name */
+ false, /* partial_inplace */
+ 0xff, /* src_mask */
+ 0xff, /* dst_mask */
+ true), /* pcrel_offset */
};
/* This structure is used to map BFD reloc codes to H8 ELF relocs. */
@@ -194,6 +222,8 @@ static const struct elf_reloc_map h8_reloc_map[] =
{ BFD_RELOC_H8_DIR24A8, R_H8_DIR24A8_X },
{ BFD_RELOC_H8_DIR24R8, R_H8_DIR24R8_X },
{ BFD_RELOC_H8_DIR32A16, R_H8_DIR32A16_X },
+ { BFD_RELOC_16_PCREL, R_H8_PCREL16_X },
+ { BFD_RELOC_8_PCREL, R_H8_PCREL8_X },
};
@@ -287,9 +317,6 @@ elf32_h8_final_link_relocate (r_type, input_bfd, output_bfd,
case R_H8_DIR8:
value += addend;
- if ((long) value > 0x7f || (long) value < -0x80)
- return bfd_reloc_overflow;
-
bfd_put_8 (input_bfd, value, hit_data);
return bfd_reloc_ok;
@@ -297,14 +324,29 @@ elf32_h8_final_link_relocate (r_type, input_bfd, output_bfd,
case R_H8_DIR24R8:
value += addend;
- if ((long) value > 0x7fffff || (long) value < -0x800000)
- return bfd_reloc_overflow;
-
value &= 0xffffff;
value |= (bfd_get_32 (input_bfd, hit_data) & 0xff000000);
bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
+ case R_H8_PCREL16:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset);
+ value -= offset;
+ value += addend;
+
+ bfd_put_16 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_H8_PCREL8:
+ value -= (input_section->output_section->vma
+ + input_section->output_offset);
+ value -= offset;
+ value += addend;
+
+ bfd_put_8 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
default:
return bfd_reloc_notsupported;
}