| From 188a60b441711f663f07dc3c3902c8c5d590eb6c Mon Sep 17 00:00:00 2001 |
| From: Nagaraju Mekala <nmekala@xilix.com> |
| Date: Tue, 9 Oct 2018 10:14:22 +0530 |
| Subject: [PATCH 20/40] Various fixes |
| |
| - Fixed address computation issues with 64bit address |
| - Fixed imml dissassamble issue |
| --- |
| bfd/bfd-in2.h | 5 +++ |
| bfd/elf64-microblaze.c | 14 ++++---- |
| opcodes/microblaze-dis.c | 2 +- |
| 4 files changed, 79 insertions(+), 16 deletions(-) |
| |
| diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h |
| index 3899352b1d5..91761bf6964 100644 |
| --- a/bfd/bfd-in2.h |
| +++ b/bfd/bfd-in2.h |
| @@ -5378,6 +5378,11 @@ value in two words (with an imml instruction). No relocation is |
| done here - only used for relaxing */ |
| BFD_RELOC_MICROBLAZE_64, |
| |
| +/* This is a 64 bit reloc that stores the 32 bit relative |
| +value in two words (with an imml instruction). No relocation is |
| +done here - only used for relaxing */ |
| + BFD_RELOC_MICROBLAZE_EA64, |
| + |
| /* This is a 64 bit reloc that stores the 32 bit pc relative |
| value in two words (with an imm instruction). No relocation is |
| done here - only used for relaxing */ |
| diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c |
| index f8f52870639..17e58748a0b 100644 |
| --- a/bfd/elf64-microblaze.c |
| +++ b/bfd/elf64-microblaze.c |
| @@ -121,15 +121,15 @@ static reloc_howto_type microblaze_elf_howto_raw[] = |
| 0, /* Rightshift. */ |
| 4, /* Size (0 = byte, 1 = short, 2 = long). */ |
| 64, /* Bitsize. */ |
| - TRUE, /* PC_relative. */ |
| + FALSE, /* PC_relative. */ |
| 0, /* Bitpos. */ |
| complain_overflow_dont, /* Complain on overflow. */ |
| bfd_elf_generic_reloc,/* Special Function. */ |
| "R_MICROBLAZE_IMML_64", /* Name. */ |
| FALSE, /* Partial Inplace. */ |
| 0, /* Source Mask. */ |
| - 0x0000ffff, /* Dest Mask. */ |
| - TRUE), /* PC relative offset? */ |
| + 0xffffffffffffff, /* Dest Mask. */ |
| + FALSE), /* PC relative offset? */ |
| |
| /* A 64 bit relocation. Table entry not really used. */ |
| HOWTO (R_MICROBLAZE_64, /* Type. */ |
| @@ -585,9 +585,9 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, |
| case BFD_RELOC_32: |
| microblaze_reloc = R_MICROBLAZE_32; |
| break; |
| - /* RVA is treated the same as 32 */ |
| + /* RVA is treated the same as 64 */ |
| case BFD_RELOC_RVA: |
| - microblaze_reloc = R_MICROBLAZE_32; |
| + microblaze_reloc = R_MICROBLAZE_IMML_64; |
| break; |
| case BFD_RELOC_32_PCREL: |
| microblaze_reloc = R_MICROBLAZE_32_PCREL; |
| @@ -619,7 +619,7 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, |
| case BFD_RELOC_VTABLE_ENTRY: |
| microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY; |
| break; |
| - case BFD_RELOC_MICROBLAZE_64: |
| + case BFD_RELOC_MICROBLAZE_EA64: |
| microblaze_reloc = R_MICROBLAZE_IMML_64; |
| break; |
| case BFD_RELOC_MICROBLAZE_64_GOTPC: |
| @@ -1956,7 +1956,7 @@ microblaze_elf_relax_section (bfd *abfd, |
| efix = calc_fixup (target_address, 0, sec); |
| |
| /* Validate the in-band val. */ |
| - val = bfd_get_32 (abfd, contents + irel->r_offset); |
| + val = bfd_get_64 (abfd, contents + irel->r_offset); |
| if (val != irel->r_addend && ELF64_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) { |
| fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend); |
| } |
| diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c |
| index 437f536e96a..24ede714858 100644 |
| --- a/opcodes/microblaze-dis.c |
| +++ b/opcodes/microblaze-dis.c |
| @@ -78,7 +78,7 @@ get_field_imml (struct string_buf *buf, long instr) |
| { |
| char *p = strbuf (buf); |
| |
| - sprintf (p, "%d", (short)((instr & IMML_MASK) >> IMM_LOW)); |
| + sprintf (p, "%d", (int)((instr & IMML_MASK) >> IMM_LOW)); |
| return p; |
| } |
| |
| -- |
| 2.17.1 |
| |