blob: 4cae439ed0f0b694a08178b8fb5a0f3566edfdbb [file] [log] [blame]
Brad Bishop26bdd442019-08-16 17:08:17 -04001From 2b87c5c4ec4a7d6285c0991c202aae3cf8401d99 Mon Sep 17 00:00:00 2001
Brad Bishop286d45c2018-10-02 15:21:57 -04002From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Brad Bishop26bdd442019-08-16 17:08:17 -04003Date: Tue, 14 Feb 2012 01:00:22 +0100
Brad Bishop286d45c2018-10-02 15:21:57 -04004Subject: [PATCH] Fix relaxation of assembler resolved references
5
Brad Bishop286d45c2018-10-02 15:21:57 -04006Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Brad Bishop26bdd442019-08-16 17:08:17 -04007Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com>
Brad Bishop286d45c2018-10-02 15:21:57 -04008
9---
Brad Bishop26bdd442019-08-16 17:08:17 -040010 bfd/elf32-microblaze.c | 38 ++++++++++++++++++++++++++++++++++++++
Brad Bishop286d45c2018-10-02 15:21:57 -040011 gas/config/tc-microblaze.c | 1 +
Brad Bishop26bdd442019-08-16 17:08:17 -040012 2 files changed, 39 insertions(+)
Brad Bishop286d45c2018-10-02 15:21:57 -040013
14diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
Brad Bishop26bdd442019-08-16 17:08:17 -040015index e3c8027..359484d 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040016--- a/bfd/elf32-microblaze.c
17+++ b/bfd/elf32-microblaze.c
Brad Bishop26bdd442019-08-16 17:08:17 -040018@@ -1973,6 +1973,44 @@ microblaze_elf_relax_section (bfd *abfd,
Brad Bishop286d45c2018-10-02 15:21:57 -040019 irelscanend = irelocs + o->reloc_count;
20 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
21 {
22+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
23+ {
24+ unsigned int val;
25+
26+ isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
27+
28+ /* This was a PC-relative instruction that was completely resolved. */
29+ if (ocontents == NULL)
30+ {
31+ if (elf_section_data (o)->this_hdr.contents != NULL)
32+ ocontents = elf_section_data (o)->this_hdr.contents;
33+ else
34+ {
35+ /* We always cache the section contents.
36+ Perhaps, if info->keep_memory is FALSE, we
37+ should free them, if we are permitted to. */
38+
39+ if (o->rawsize == 0)
40+ o->rawsize = o->size;
41+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
42+ if (ocontents == NULL)
43+ goto error_return;
44+ if (!bfd_get_section_contents (abfd, o, ocontents,
45+ (file_ptr) 0,
46+ o->rawsize))
47+ goto error_return;
48+ elf_section_data (o)->this_hdr.contents = ocontents;
49+ }
50+ }
Brad Bishop26bdd442019-08-16 17:08:17 -040051+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
Brad Bishop286d45c2018-10-02 15:21:57 -040052+ + isym->st_value, sec);
53+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
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
Brad Bishop26bdd442019-08-16 17:08:17 -040064index c92e9ce..3e72840 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040065--- a/gas/config/tc-microblaze.c
66+++ b/gas/config/tc-microblaze.c
Brad Bishop26bdd442019-08-16 17:08:17 -040067@@ -2205,6 +2205,7 @@ md_apply_fix (fixS * fixP,
Brad Bishop286d45c2018-10-02 15:21:57 -040068 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 }