blob: d1b754c37bdec2c2dfe0feaf1da7ab73d0e1884b [file] [log] [blame]
Andrew Geissler84ad7c52020-06-27 00:00:16 -05001From ababe1df64146c616455eb1af4cf8fd21eb6f42c 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
Andrew Geissler84ad7c52020-06-27 00:00:16 -05004Subject: [PATCH 04/43] Fix relaxation of assembler resolved references
Brad Bishop286d45c2018-10-02 15:21:57 -04005
6---
Brad Bishop26bdd442019-08-16 17:08:17 -04007 bfd/elf32-microblaze.c | 38 ++++++++++++++++++++++++++++++++++++++
Brad Bishop286d45c2018-10-02 15:21:57 -04008 gas/config/tc-microblaze.c | 1 +
Brad Bishop26bdd442019-08-16 17:08:17 -04009 2 files changed, 39 insertions(+)
Brad Bishop286d45c2018-10-02 15:21:57 -040010
11diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
Andrew Geissler84ad7c52020-06-27 00:00:16 -050012index e3c8027248..359484dd5e 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040013--- a/bfd/elf32-microblaze.c
14+++ b/bfd/elf32-microblaze.c
Brad Bishop26bdd442019-08-16 17:08:17 -040015@@ -1973,6 +1973,44 @@ microblaze_elf_relax_section (bfd *abfd,
Brad Bishop286d45c2018-10-02 15:21:57 -040016 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+ }
Brad Bishop26bdd442019-08-16 17:08:17 -040048+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
Brad Bishop286d45c2018-10-02 15:21:57 -040049+ + isym->st_value, sec);
50+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
51+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
52+ irelscan->r_addend);
53+ }
54+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_NONE) {
55+ fprintf(stderr, "Unhandled NONE 64\n");
56+ }
57 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
58 {
59 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
60diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
Andrew Geissler84ad7c52020-06-27 00:00:16 -050061index c92e9ce563..3e728400b7 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040062--- a/gas/config/tc-microblaze.c
63+++ b/gas/config/tc-microblaze.c
Brad Bishop26bdd442019-08-16 17:08:17 -040064@@ -2205,6 +2205,7 @@ md_apply_fix (fixS * fixP,
Brad Bishop286d45c2018-10-02 15:21:57 -040065 else
66 fixP->fx_r_type = BFD_RELOC_NONE;
67 fixP->fx_addsy = section_symbol (absolute_section);
68+ fixP->fx_done = 0;
69 }
70 return;
71 }
Andrew Geissler84ad7c52020-06-27 00:00:16 -050072--
732.17.1
74