-/* Forward declarations. */
-static reloc_howto_type * xstormy16_reloc_type_lookup
- PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-static void xstormy16_info_to_howto_rela
- PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
-static bfd_reloc_status_type xstormy16_elf_24_reloc
- PARAMS ((bfd *abfd, arelent *reloc_entry, asymbol *symbol,
- PTR data, asection *input_section, bfd *output_bfd,
- char **error_message));
-static boolean xstormy16_elf_check_relocs
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- const Elf_Internal_Rela *));
-static boolean xstormy16_relax_plt_check
- PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean xstormy16_relax_plt_realloc
- PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean xstormy16_elf_relax_section
- PARAMS ((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
- boolean *again));
-static boolean xstormy16_elf_always_size_sections
- PARAMS ((bfd *, struct bfd_link_info *));
-static boolean xstormy16_elf_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static boolean xstormy16_elf_finish_dynamic_sections
- PARAMS((bfd *, struct bfd_link_info *));
-static boolean xstormy16_elf_gc_sweep_hook
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
- const Elf_Internal_Rela *));
-static asection * xstormy16_elf_gc_mark_hook
- PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
- struct elf_link_hash_entry *, Elf_Internal_Sym *));
+/* Handle the R_XSTORMY16_24 reloc, which has an odd bit arrangement. */
+
+static bfd_reloc_status_type
+xstormy16_elf_24_reloc (bfd *abfd,
+ arelent *reloc_entry,
+ asymbol *symbol,
+ void * data,
+ asection *input_section,
+ bfd *output_bfd,
+ char **error_message ATTRIBUTE_UNUSED)
+{
+ bfd_vma relocation, x;
+
+ if (output_bfd != NULL)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
+ return bfd_reloc_outofrange;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ relocation += reloc_entry->addend;
+
+ x = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ x &= 0x0000ff00;
+ x |= relocation & 0xff;
+ x |= (relocation << 8) & 0xffff0000;
+ bfd_put_32 (abfd, x, (bfd_byte *) data + reloc_entry->address);
+
+ if (relocation & ~ (bfd_vma) 0xffffff)
+ return bfd_reloc_overflow;
+
+ return bfd_reloc_ok;
+}