- 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;