1 --- gdb-7.8.2.orig/bfd/elf32-microblaze.c 2015-01-15 11:58:11.000000000 +0100
2 +++ gdb-7.8.2/bfd/elf32-microblaze.c 2016-09-21 10:34:30.025222164 +0200
3 @@ -177,6 +177,20 @@ static reloc_howto_type microblaze_elf_h
4 FALSE), /* PC relative offset? */
6 /* This reloc does nothing. Used for relaxation. */
7 + HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
9 + 2, /* Size (0 = byte, 1 = short, 2 = long). */
11 + TRUE, /* PC_relative. */
13 + complain_overflow_bitfield, /* Complain on overflow. */
14 + NULL, /* Special Function. */
15 + "R_MICROBLAZE_32_NONE",/* Name. */
16 + FALSE, /* Partial Inplace. */
17 + 0, /* Source Mask. */
19 + FALSE), /* PC relative offset? */
21 HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
23 2, /* Size (0 = byte, 1 = short, 2 = long). */
24 @@ -532,7 +546,10 @@ microblaze_elf_reloc_type_lookup (bfd *
26 microblaze_reloc = R_MICROBLAZE_NONE;
28 - case BFD_RELOC_MICROBLAZE_64_NONE:
29 + case BFD_RELOC_MICROBLAZE_32_NONE:
30 + microblaze_reloc = R_MICROBLAZE_32_NONE;
32 + case BFD_RELOC_MICROBLAZE_64_NONE:
33 microblaze_reloc = R_MICROBLAZE_64_NONE;
36 @@ -668,6 +685,67 @@ microblaze_elf_is_local_label_name (bfd
37 return _bfd_elf_is_local_label_name (abfd, name);
40 +/* Support for core dump NOTE sections. */
42 +microblaze_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
47 + switch (note->descsz)
52 + case 228: /* Linux/MicroBlaze */
54 + elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
57 + elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
66 + /* Make a ".reg/999" section. */
67 + return _bfd_elfcore_make_pseudosection (abfd, ".reg",
68 + size, note->descpos + offset);
72 +microblaze_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
74 + switch (note->descsz)
79 + case 128: /* Linux/MicroBlaze elf_prpsinfo */
80 + elf_tdata (abfd)->core->program
81 + = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
82 + elf_tdata (abfd)->core->command
83 + = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
86 + /* Note that for some reason, a spurious space is tacked
87 + onto the end of the args in some (at least one anyway)
88 + implementations, so strip it off if it exists. */
91 + char *command = elf_tdata (abfd)->core->command;
92 + int n = strlen (command);
94 + if (0 < n && command[n - 1] == ' ')
95 + command[n - 1] = '\0';
101 /* The microblaze linker (like many others) needs to keep track of
102 the number of relocs that it decides to copy as dynamic relocs in
103 check_relocs for each symbol. This is so that it can later discard
104 @@ -1023,7 +1101,7 @@ microblaze_elf_relocate_section (bfd *ou
106 /* External symbol. */
107 bfd_boolean warned ATTRIBUTE_UNUSED;
108 - bfd_boolean ignored ATTRIBUTE_UNUSED;
109 + bfd_boolean ignored;
111 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
112 r_symndx, symtab_hdr, sym_hashes,
113 @@ -1852,14 +1930,22 @@ microblaze_elf_relax_section (bfd *abfd,
116 case R_MICROBLAZE_NONE:
117 + case R_MICROBLAZE_32_NONE:
119 /* This was a PC-relative instruction that was
120 completely resolved. */
123 bfd_vma target_address;
124 target_address = irel->r_addend + irel->r_offset;
125 sfix = calc_fixup (irel->r_offset, 0, sec);
126 efix = calc_fixup (target_address, 0, sec);
128 + /* Validate the in-band val. */
129 + val = bfd_get_32 (abfd, contents + irel->r_offset);
130 + if (val != irel->r_addend && ELF32_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) {
131 + fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend);
133 irel->r_addend -= (efix - sfix);
134 /* Should use HOWTO. */
135 microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset,
136 @@ -1907,6 +1993,49 @@ microblaze_elf_relax_section (bfd *abfd,
137 irelscanend = irelocs + o->reloc_count;
138 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
140 + if (1 && ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
144 + isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
146 + /* hax: We only do the following fixup for debug location lists. */
147 + if (strcmp(".debug_loc", o->name))
150 + /* This was a PC-relative instruction that was completely resolved. */
151 + if (ocontents == NULL)
153 + if (elf_section_data (o)->this_hdr.contents != NULL)
154 + ocontents = elf_section_data (o)->this_hdr.contents;
157 + /* We always cache the section contents.
158 + Perhaps, if info->keep_memory is FALSE, we
159 + should free them, if we are permitted to. */
161 + if (o->rawsize == 0)
162 + o->rawsize = o->size;
163 + ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
164 + if (ocontents == NULL)
166 + if (!bfd_get_section_contents (abfd, o, ocontents,
170 + elf_section_data (o)->this_hdr.contents = ocontents;
174 + val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
175 + if (val != irelscan->r_addend) {
176 + fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend);
179 + irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
180 + microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
181 + irelscan->r_addend);
183 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
185 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
186 @@ -1966,7 +2095,7 @@ microblaze_elf_relax_section (bfd *abfd,
187 elf_section_data (o)->this_hdr.contents = ocontents;
190 - irelscan->r_addend -= calc_fixup (irel->r_addend
191 + irelscan->r_addend -= calc_fixup (irelscan->r_addend
195 @@ -3506,4 +3635,7 @@ microblaze_elf_add_symbol_hook (bfd *abf
196 #define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
197 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
199 +#define elf_backend_grok_prstatus microblaze_elf_grok_prstatus
200 +#define elf_backend_grok_psinfo microblaze_elf_grok_psinfo
202 #include "elf32-target.h"