+#endif
+
+/* this function is in charge of performing all the 29k relocations */
+
+static bfd_reloc_status_type
+sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
+ error_message)
+ bfd *abfd;
+ arelent *reloc_entry;
+ asymbol *symbol_in;
+ PTR data;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message;
+{
+ /* the consth relocation comes in two parts, we have to remember
+ the state between calls, in these variables */
+ unsigned long insn;
+ unsigned long sym_value;
+ unsigned short r_type;
+
+ unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/
+ bfd_byte *hit_data =addr + (bfd_byte *)(data);
+
+ r_type = reloc_entry->howto->type;
+
+ if (output_bfd) {
+ /* Partial linking - do nothing */
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+
+ if (symbol_in != NULL
+ && bfd_is_und_section (symbol_in->section))
+ {
+ /* Keep the state machine happy in case we're called again */
+ return (bfd_reloc_undefined);
+ }
+
+
+ sym_value = get_symbol_value(symbol_in);
+
+ switch (r_type)
+ {
+ case R_SH_IMM32:
+ /* We ignore the previous contents ! */
+ insn = sym_value + reloc_entry->addend;
+ bfd_put_32(abfd, insn, hit_data);
+ break;
+ default:
+ *error_message = "Unrecognized reloc";
+ return (bfd_reloc_dangerous);
+ }
+
+
+ return(bfd_reloc_ok);
+}
+
+/* The reloc processing routine for the optimized COFF linker. */
+
+static boolean
+coff_sh_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, syms, sections)
+ bfd *output_bfd;
+ struct bfd_link_info *info;
+ bfd *input_bfd;
+ asection *input_section;
+ bfd_byte *contents;
+ struct internal_reloc *relocs;
+ struct internal_syment *syms;
+ asection **sections;
+{
+ struct internal_reloc *rel;
+ struct internal_reloc *relend;
+
+ /* If we are performing a relocateable link, we don't need to do a
+ thing. The caller will take care of adjusting the reloc
+ addresses and symbol indices. */
+ if (info->relocateable)
+ return true;
+
+
+ rel = relocs;
+ relend = rel + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ long symndx;
+ bfd_byte *loc;
+ struct coff_link_hash_entry *h;
+ struct internal_syment *sym;
+ asection *sec;
+ bfd_vma val;
+ bfd_reloc_status_type rstat;
+
+ symndx = rel->r_symndx;
+ loc = contents + rel->r_vaddr - input_section->vma;
+
+ if (symndx == -1)
+ h = NULL;
+ else
+ h = obj_coff_sym_hashes (input_bfd)[symndx];
+
+ sym = NULL;
+ sec = NULL;
+ val = 0;
+
+
+ if (h == NULL)
+ {
+ if (symndx == -1)
+ sec = bfd_abs_section_ptr;
+ else
+ {
+ sym = syms + symndx;
+ sec = sections[symndx];
+ val = (sec->output_section->vma
+ + sec->output_offset
+ + sym->n_value
+ - sec->vma
+ - sec->vma);
+ }
+ }
+ else
+ {
+ if (h->root.type == bfd_link_hash_defined)
+ {
+ sec = h->root.u.def.section;
+ val = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ }
+ else
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma)))
+ return false;
+ }
+ }
+
+ switch (rel->r_type)
+ {
+ default:
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+
+ case R_SH_IMM32:
+ {
+ long x = bfd_get_32 (input_bfd, loc);
+ x += val;
+ bfd_put_32 (input_bfd, x, loc);
+
+ }
+
+ break;
+ }
+ }
+
+ return true;
+}