Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 1 | From 52f6c56353aad424dfdaf713e0192f8fc9c874f4 Mon Sep 17 00:00:00 2001 |
| 2 | From: Nagaraju Mekala <nmekala@xilix.com> |
| 3 | Date: Wed, 24 Oct 2018 12:34:37 +0530 |
| 4 | Subject: [PATCH] fixing the .bss relocation issue |
| 5 | |
| 6 | Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com> |
| 7 | Signed-off-by: Nagaraju Mekala <nagaraju.mekala@xilinx.com> |
| 8 | |
| 9 | --- |
| 10 | bfd/elf64-microblaze.c | 18 ++++++++++++------ |
| 11 | 1 file changed, 12 insertions(+), 6 deletions(-) |
| 12 | |
| 13 | diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c |
| 14 | index 4d9b906..184b7d5 100644 |
| 15 | --- a/bfd/elf64-microblaze.c |
| 16 | +++ b/bfd/elf64-microblaze.c |
| 17 | @@ -1480,7 +1480,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, |
| 18 | + input_section->output_offset |
| 19 | + offset + INST_WORD_SIZE); |
| 20 | unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian); |
| 21 | - if (insn == 0xb2000000 || insn == 0xb2ffffff) |
| 22 | + if ((insn & 0xff000000) == 0xb2000000) |
| 23 | { |
| 24 | insn &= ~0x00ffffff; |
| 25 | insn |= (relocation >> 16) & 0xffffff; |
| 26 | @@ -1593,7 +1593,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, |
| 27 | + offset + INST_WORD_SIZE); |
| 28 | } |
| 29 | unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian); |
| 30 | - if (insn == 0xb2000000 || insn == 0xb2ffffff) |
| 31 | + if ((insn & 0xff000000) == 0xb2000000) |
| 32 | { |
| 33 | insn &= ~0x00ffffff; |
| 34 | insn |= (relocation >> 16) & 0xffffff; |
| 35 | @@ -1722,7 +1722,7 @@ microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val) |
| 36 | { |
| 37 | unsigned long instr = bfd_get_32 (abfd, bfd_addr); |
| 38 | |
| 39 | - if (instr == 0xb2000000 || instr == 0xb2ffffff) |
| 40 | + if ((instr & 0xff000000) == 0xb2000000) |
| 41 | { |
| 42 | instr &= ~0x00ffffff; |
| 43 | instr |= (val & 0xffffff); |
| 44 | @@ -1745,7 +1745,7 @@ microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val) |
| 45 | unsigned long instr_lo; |
| 46 | |
| 47 | instr_hi = bfd_get_32 (abfd, bfd_addr); |
| 48 | - if (instr_hi == 0xb2000000 || instr_hi == 0xb2ffffff) |
| 49 | + if ((instr_hi & 0xff000000) == 0xb2000000) |
| 50 | { |
| 51 | instr_hi &= ~0x00ffffff; |
| 52 | instr_hi |= (val >> 16) & 0xffffff; |
| 53 | @@ -2238,7 +2238,10 @@ microblaze_elf_relax_section (bfd *abfd, |
| 54 | unsigned long instr_lo = bfd_get_32 (abfd, ocontents |
| 55 | + irelscan->r_offset |
| 56 | + INST_WORD_SIZE); |
| 57 | - immediate = (instr_hi & 0x0000ffff) << 16; |
| 58 | + if ((instr_hi & 0xff000000) == 0xb2000000) |
| 59 | + immediate = (instr_hi & 0x00ffffff) << 24; |
| 60 | + else |
| 61 | + immediate = (instr_hi & 0x0000ffff) << 16; |
| 62 | immediate |= (instr_lo & 0x0000ffff); |
| 63 | offset = calc_fixup (irelscan->r_addend, 0, sec); |
| 64 | immediate -= offset; |
| 65 | @@ -2282,7 +2285,10 @@ microblaze_elf_relax_section (bfd *abfd, |
| 66 | unsigned long instr_lo = bfd_get_32 (abfd, ocontents |
| 67 | + irelscan->r_offset |
| 68 | + INST_WORD_SIZE); |
| 69 | - immediate = (instr_hi & 0x0000ffff) << 16; |
| 70 | + if ((instr_hi & 0xff000000) == 0xb2000000) |
| 71 | + immediate = (instr_hi & 0x00ffffff) << 24; |
| 72 | + else |
| 73 | + immediate = (instr_hi & 0x0000ffff) << 16; |
| 74 | immediate |= (instr_lo & 0x0000ffff); |
| 75 | target_address = immediate; |
| 76 | offset = calc_fixup (target_address, 0, sec); |