+
+bfd_reloc_status_type
+cris_elf_pcrel_reloc (abfd, reloc_entry, symbol, data, input_section,
+ output_bfd, error_message)
+ bfd *abfd ATTRIBUTE_UNUSED;
+ arelent *reloc_entry;
+ asymbol *symbol;
+ PTR data ATTRIBUTE_UNUSED;
+ asection *input_section;
+ bfd *output_bfd;
+ char **error_message ATTRIBUTE_UNUSED;
+{
+ /* By default (using only bfd_elf_generic_reloc when linking to
+ non-ELF formats) PC-relative relocs are relative to the beginning
+ of the reloc. CRIS PC-relative relocs are relative to the position
+ *after* the reloc because that's what pre-CRISv32 PC points to
+ after reading an insn field with that reloc. (For CRISv32, PC is
+ actually relative to the start of the insn, but we keep the old
+ definition.) Still, we use as much generic machinery as we can.
+
+ Only adjust when doing a final link. */
+ if (output_bfd == (bfd *) NULL)
+ reloc_entry->addend -= 1 << reloc_entry->howto->size;
+
+ return
+ bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message);
+}
+\f
+/* Support for core dump NOTE sections.
+ The slightly unintuitive code layout is an attempt to keep at least
+ some similarities with other ports, hoping to simplify general
+ changes, while still keeping Linux/CRIS and Linux/CRISv32 code apart. */
+
+static bfd_boolean
+cris_elf_grok_prstatus (abfd, note)
+ bfd *abfd;
+ Elf_Internal_Note *note;
+{
+ int offset;
+ size_t size;
+
+ if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
+ switch (note->descsz)
+ {
+ default:
+ return FALSE;
+
+ case 202: /* Linux/CRISv32 */
+ /* pr_cursig */
+ elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+
+ /* pr_pid */
+ elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 22);
+
+ /* pr_reg */
+ offset = 70;
+ size = 128;
+
+ break;
+ }
+ else
+ switch (note->descsz)
+ {
+ default:
+ return FALSE;
+
+ case 214: /* Linux/CRIS */
+ /* pr_cursig */
+ elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+
+ /* pr_pid */
+ elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 22);
+
+ /* pr_reg */
+ offset = 70;
+ size = 140;
+
+ break;
+ }
+
+ /* Make a ".reg/999" section. */
+ return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+ size, note->descpos + offset);
+}
+
+static bfd_boolean
+cris_elf_grok_psinfo (abfd, note)
+ bfd *abfd;
+ Elf_Internal_Note *note;
+{
+ if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
+ switch (note->descsz)
+ {
+ default:
+ return FALSE;
+
+ case 124: /* Linux/CRISv32 elf_prpsinfo */
+ elf_tdata (abfd)->core_program
+ = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
+ elf_tdata (abfd)->core_command
+ = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
+ }
+ else
+ switch (note->descsz)
+ {
+ default:
+ return FALSE;
+
+ case 124: /* Linux/CRIS elf_prpsinfo */
+ elf_tdata (abfd)->core_program
+ = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
+ elf_tdata (abfd)->core_command
+ = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
+ }
+
+ /* Note that for some reason, a spurious space is tacked
+ onto the end of the args in some (at least one anyway)
+ implementations, so strip it off if it exists. */
+
+ {
+ char *command = elf_tdata (abfd)->core_command;
+ int n = strlen (command);
+
+ if (0 < n && command[n - 1] == ' ')
+ command[n - 1] = '\0';
+ }
+
+ return TRUE;
+}