blob: b543c54eea7abd23d52bcda1533a77021e1df00f [file] [log] [blame]
Brad Bishop286d45c2018-10-02 15:21:57 -04001From 927ef228dfedf229dc915b273a308ab2c7bf9e19 Mon Sep 17 00:00:00 2001
2From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
3Date: Mon, 28 Aug 2017 19:53:55 -0700
4Subject: [PATCH] Fix relaxation of assembler resolved references
5
603/2018
7Rebased for binutils 2.30
8
9Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
10Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
11Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandr@xilinx.com>
12
13Upstream-Status: Pending
14
15---
16 bfd/elf32-microblaze.c | 39 +++++++++++++++++++++++++++++++++++++++
17 gas/config/tc-microblaze.c | 1 +
18 2 files changed, 40 insertions(+)
19
20diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
21index f1808bc..a1d810c 100644
22--- a/bfd/elf32-microblaze.c
23+++ b/bfd/elf32-microblaze.c
24@@ -1887,6 +1887,45 @@ microblaze_elf_relax_section (bfd *abfd,
25 irelscanend = irelocs + o->reloc_count;
26 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
27 {
28+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
29+ {
30+ unsigned int val;
31+
32+ isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
33+
34+ /* This was a PC-relative instruction that was completely resolved. */
35+ if (ocontents == NULL)
36+ {
37+ if (elf_section_data (o)->this_hdr.contents != NULL)
38+ ocontents = elf_section_data (o)->this_hdr.contents;
39+ else
40+ {
41+ /* We always cache the section contents.
42+ Perhaps, if info->keep_memory is FALSE, we
43+ should free them, if we are permitted to. */
44+
45+ if (o->rawsize == 0)
46+ o->rawsize = o->size;
47+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
48+ if (ocontents == NULL)
49+ goto error_return;
50+ if (!bfd_get_section_contents (abfd, o, ocontents,
51+ (file_ptr) 0,
52+ o->rawsize))
53+ goto error_return;
54+ elf_section_data (o)->this_hdr.contents = ocontents;
55+ }
56+ }
57+
58+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
59+ + isym->st_value, sec);
60+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
61+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
62+ irelscan->r_addend);
63+ }
64+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_NONE) {
65+ fprintf(stderr, "Unhandled NONE 64\n");
66+ }
67 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
68 {
69 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
70diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
71index 42dd7ae..50dbfc7 100644
72--- a/gas/config/tc-microblaze.c
73+++ b/gas/config/tc-microblaze.c
74@@ -2183,6 +2183,7 @@ md_apply_fix (fixS * fixP,
75 else
76 fixP->fx_r_type = BFD_RELOC_NONE;
77 fixP->fx_addsy = section_symbol (absolute_section);
78+ fixP->fx_done = 0;
79 }
80 return;
81 }