-/* This function is used for relocs which are only used for relaxing,
- which the linker should otherwise ignore. */
-
-static bfd_reloc_status_type
-m68hc11_elf_ignore_reloc (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd ATTRIBUTE_UNUSED;
- arelent *reloc_entry;
- asymbol *symbol ATTRIBUTE_UNUSED;
- PTR data ATTRIBUTE_UNUSED;
- asection *input_section;
- bfd *output_bfd;
- char **error_message ATTRIBUTE_UNUSED;
-{
- if (output_bfd != NULL)
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
-}
-
-static int
-m68hc12_addr_is_banked (addr)
- bfd_vma addr;
-{
- return (addr >= M68HC12_BANK_VIRT) ? 1 : 0;
-}
-
-/* Return the physical address seen by the processor, taking
- into account banked memory. */
-static bfd_vma
-m68hc12_phys_addr (addr)
- bfd_vma addr;
-{
- if (addr < M68HC12_BANK_VIRT)
- return addr;
-
- /* Map the address to the memory bank. */
- addr -= M68HC12_BANK_VIRT;
- addr &= M68HC12_BANK_MASK;
- addr += M68HC12_BANK_BASE;
- return addr;
-}
-
-/* Return the page number corresponding to an address in banked memory. */
-static bfd_vma
-m68hc12_phys_page (addr)
- bfd_vma addr;
-{
- if (addr < M68HC12_BANK_VIRT)
- return 0;
-
- /* Map the address to the memory bank. */
- addr -= M68HC12_BANK_VIRT;
- addr >>= M68HC12_BANK_SHIFT;
- addr &= M68HC12_BANK_PAGE_MASK;
- return addr;
-}
-
-static bfd_reloc_status_type
-m68hc12_elf_special_reloc (abfd, reloc_entry, symbol, data, input_section,
- output_bfd, error_message)
- bfd *abfd;
- arelent *reloc_entry;
- asymbol *symbol;
- PTR data;
- asection *input_section;
- bfd *output_bfd;
- char **error_message ATTRIBUTE_UNUSED;
-{
- reloc_howto_type *howto;
- bfd_vma relocation;
- bfd_vma phys_addr;
- bfd_vma phys_page;
- bfd_vma insn_page;
- bfd_vma insn_addr;
-
- if (output_bfd != (bfd *) NULL
- && (symbol->flags & BSF_SECTION_SYM) == 0
- && (! reloc_entry->howto->partial_inplace
- || reloc_entry->addend == 0))
- {
- reloc_entry->address += input_section->output_offset;
- return bfd_reloc_ok;
- }
-
- if (output_bfd != NULL)
- return bfd_reloc_continue;
-
- if (reloc_entry->address > input_section->_cooked_size)
- return bfd_reloc_outofrange;
-
- /* Compute relocation. */
- relocation = (symbol->value
- + symbol->section->output_section->vma
- + symbol->section->output_offset);
- relocation += reloc_entry->addend;
- relocation += bfd_get_16 (abfd, (bfd_byte*) data + reloc_entry->address);
-
- /* Do the memory bank mapping. */
- phys_addr = m68hc12_phys_addr (relocation);
- phys_page = m68hc12_phys_page (relocation);
-
- howto = reloc_entry->howto;
- if (howto->complain_on_overflow != complain_overflow_dont
- && (phys_addr & (((bfd_vma) -1) << 16)))
- return bfd_reloc_overflow;
-
- switch (howto->type)
- {
- case R_M68HC11_16:
- /* Get virtual address of instruction having the relocation. */
- insn_addr = input_section->output_section->vma
- + input_section->output_offset
- + reloc_entry->address;
-
- insn_page = m68hc12_phys_page (insn_addr);
-
- if (m68hc12_addr_is_banked (relocation)
- && m68hc12_addr_is_banked (insn_addr)
- && phys_page != insn_page)
- {
- *error_message = _("address is not in the same bank");
- return bfd_reloc_dangerous;
- }
- if (m68hc12_addr_is_banked (relocation)
- && !m68hc12_addr_is_banked (insn_addr))
- {
- *error_message = _("reference to a banked address in "
- "the normal address space");
- return bfd_reloc_dangerous;
- }
-
- case R_M68HC11_LO16:
- bfd_put_16 (abfd, phys_addr, (bfd_byte*) data + reloc_entry->address);
- break;
-
- case R_M68HC11_24:
- bfd_put_16 (abfd, phys_addr, (bfd_byte*) data + reloc_entry->address);
- bfd_put_8 (abfd, phys_page, (bfd_byte*) data + reloc_entry->address + 2);
- break;
-
- case R_M68HC11_PAGE:
- bfd_put_8 (abfd, phys_page, (bfd_byte*) data + reloc_entry->address);
- break;
-
- default:
- abort ();
- break;
- }
-
- return bfd_reloc_ok;
-}
-