Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 1 | From 2b87c5c4ec4a7d6285c0991c202aae3cf8401d99 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 2 | From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 3 | Date: Tue, 14 Feb 2012 01:00:22 +0100 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 4 | Subject: [PATCH] Fix relaxation of assembler resolved references |
| 5 | |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 7 | Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 8 | |
| 9 | --- |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 10 | bfd/elf32-microblaze.c | 38 ++++++++++++++++++++++++++++++++++++++ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 11 | gas/config/tc-microblaze.c | 1 + |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 12 | 2 files changed, 39 insertions(+) |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 13 | |
| 14 | diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 15 | index e3c8027..359484d 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 16 | --- a/bfd/elf32-microblaze.c |
| 17 | +++ b/bfd/elf32-microblaze.c |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 18 | @@ -1973,6 +1973,44 @@ microblaze_elf_relax_section (bfd *abfd, |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 19 | 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 Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 51 | + irelscan->r_addend -= calc_fixup (irelscan->r_addend |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 52 | + + 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); |
| 63 | diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 64 | index c92e9ce..3e72840 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 65 | --- a/gas/config/tc-microblaze.c |
| 66 | +++ b/gas/config/tc-microblaze.c |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame^] | 67 | @@ -2205,6 +2205,7 @@ md_apply_fix (fixS * fixP, |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 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 | } |