blob: 3a0eae83344a6d0f54fc4949b6ae8d2cdec2586d [file] [log] [blame]
Brad Bishop286d45c2018-10-02 15:21:57 -04001From c9f1f07e5b0756069e3d4b04eb9505027f09677f 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 13/16] [LOCAL]: Fix relaxation of assembler resolved
5 references
6
7Upstream-Status: Pending
8---
9 bfd/elf32-microblaze.c | 39 +++++++++++++++++++++++++++++++++++++++
10 1 file changed, 39 insertions(+)
11
12diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
13index cbd18f0..f90df47 100644
14--- a/bfd/elf32-microblaze.c
15+++ b/bfd/elf32-microblaze.c
16@@ -1968,6 +1968,45 @@ microblaze_elf_relax_section (bfd *abfd,
17 irelscanend = irelocs + o->reloc_count;
18 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
19 {
20+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_NONE)
21+ {
22+ unsigned int val;
23+
24+ isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
25+
26+ /* This was a PC-relative instruction that was completely resolved. */
27+ if (ocontents == NULL)
28+ {
29+ if (elf_section_data (o)->this_hdr.contents != NULL)
30+ ocontents = elf_section_data (o)->this_hdr.contents;
31+ else
32+ {
33+ /* We always cache the section contents.
34+ Perhaps, if info->keep_memory is FALSE, we
35+ should free them, if we are permitted to. */
36+
37+ if (o->rawsize == 0)
38+ o->rawsize = o->size;
39+ ocontents = (bfd_byte *) bfd_malloc (o->rawsize);
40+ if (ocontents == NULL)
41+ goto error_return;
42+ if (!bfd_get_section_contents (abfd, o, ocontents,
43+ (file_ptr) 0,
44+ o->rawsize))
45+ goto error_return;
46+ elf_section_data (o)->this_hdr.contents = ocontents;
47+ }
48+ }
49+
50+ irelscan->r_addend -= calc_fixup (irelscan->r_addend
51+ + isym->st_value, sec);
52+ val = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
53+ microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
54+ irelscan->r_addend);
55+ }
56+ if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_NONE) {
57+ fprintf(stderr, "Unhandled NONE 64\n");
58+ }
59 if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
60 {
61 isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
62--
631.9.0
64