summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/binutils/binutils/0005-Fix-relaxation-of-assembler-resolved-references.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-microblaze/recipes-devtools/binutils/binutils/0005-Fix-relaxation-of-assembler-resolved-references.patch')
-rw-r--r--meta-microblaze/recipes-devtools/binutils/binutils/0005-Fix-relaxation-of-assembler-resolved-references.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/meta-microblaze/recipes-devtools/binutils/binutils/0005-Fix-relaxation-of-assembler-resolved-references.patch b/meta-microblaze/recipes-devtools/binutils/binutils/0005-Fix-relaxation-of-assembler-resolved-references.patch
new file mode 100644
index 00000000..14a4f329
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/binutils/binutils/0005-Fix-relaxation-of-assembler-resolved-references.patch
@@ -0,0 +1,77 @@
1From c4ce6cb47613293e02837fc00c2c2ebfcdd596f6 Mon Sep 17 00:00:00 2001
2From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
3Date: Tue, 14 Feb 2012 01:00:22 +0100
4Subject: [PATCH 05/40] Fix relaxation of assembler resolved references
5
6---
7 bfd/elf32-microblaze.c | 41 ++++++++++++++++++++++++++++++++++++++
8 gas/config/tc-microblaze.c | 1 +
9 2 files changed, 42 insertions(+)
10
11diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
12index 693fc71f730..09dedc46106 100644
13--- a/bfd/elf32-microblaze.c
14+++ b/bfd/elf32-microblaze.c
15@@ -1969,6 +1969,47 @@ microblaze_elf_relax_section (bfd *abfd,
16 irelscanend = irelocs + o->reloc_count;
17 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
18 {
19+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
20+ {
21+ unsigned int val;
22+
23+ isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
24+
25+ /* This was a PC-relative instruction that was completely resolved. */
26+ if (ocontents == NULL)
27+ {
28+ if (elf_section_data (o)->this_hdr.contents != NULL)
29+ ocontents = elf_section_data (o)->this_hdr.contents;
30+ else
31+ {
32+ /* We always cache the section contents.
33+ Perhaps, if info->keep_memory is FALSE, we
34+ should free them, if we are permitted to. */
35+
36+ if (o->rawsize == 0)
37+ o->rawsize = o->size;
38+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
39+ if (ocontents == NULL)
40+ goto error_return;
41+ if (!bfd_get_section_contents (abfd, o, ocontents,
42+ (file_ptr) 0,
43+ o->rawsize))
44+ goto error_return;
45+ elf_section_data (o)->this_hdr.contents = ocontents;
46+ }
47+ }
48+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
49+ if (val != irelscan->r_addend) {
50+ fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend);
51+ }
52+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
53+ + isym->st_value, 0, sec);
54+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
55+ irelscan->r_addend);
56+ }
57+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_NONE) {
58+ fprintf(stderr, "Unhandled NONE 64\n");
59+ }
60 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
61 {
62 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
63diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
64index 34eeb972357..d01653aeef9 100644
65--- a/gas/config/tc-microblaze.c
66+++ b/gas/config/tc-microblaze.c
67@@ -2201,6 +2201,7 @@ md_apply_fix (fixS * fixP,
68 else
69 fixP->fx_r_type = BFD_RELOC_NONE;
70 fixP->fx_addsy = section_symbol (absolute_section);
71+ fixP->fx_done = 0;
72 }
73 return;
74 }
75--
762.17.1
77