Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 1 | From 9880b06269a176c0b5c4f0ecb9e3784f630a76be Mon Sep 17 00:00:00 2001 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 2 | From: Nagaraju Mekala <nmekala@xilix.com> |
| 3 | Date: Sat, 13 Oct 2018 21:17:01 +0530 |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 4 | Subject: [PATCH 21/52] Adding new relocation to support 64bit rodata |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 5 | |
| 6 | --- |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 7 | bfd/elf64-microblaze.c | 11 +++++++-- |
| 8 | gas/config/tc-microblaze.c | 49 ++++++++++++++++++++++++++++++++++---- |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 9 | 2 files changed, 54 insertions(+), 6 deletions(-) |
| 10 | |
| 11 | diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 12 | index f42d7f429b..ddcb5baf74 100644 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 13 | --- a/bfd/elf64-microblaze.c |
| 14 | +++ b/bfd/elf64-microblaze.c |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 15 | @@ -1473,6 +1473,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 16 | case (int) R_MICROBLAZE_64_PCREL : |
| 17 | case (int) R_MICROBLAZE_64: |
| 18 | case (int) R_MICROBLAZE_32: |
| 19 | + case (int) R_MICROBLAZE_IMML_64: |
| 20 | { |
| 21 | /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols |
| 22 | from removed linkonce sections, or sections discarded by |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 23 | @@ -1482,6 +1483,8 @@ microblaze_elf_relocate_section (bfd *output_bfd, |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 24 | relocation += addend; |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 25 | if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64) |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 26 | bfd_put_32 (input_bfd, relocation, contents + offset); |
| 27 | + else if (r_type == R_MICROBLAZE_IMML_64) |
| 28 | + bfd_put_64 (input_bfd, relocation, contents + offset); |
| 29 | else |
| 30 | { |
| 31 | if (r_type == R_MICROBLAZE_64_PCREL) |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 32 | @@ -1560,7 +1563,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 33 | } |
| 34 | else |
| 35 | { |
| 36 | - if (r_type == R_MICROBLAZE_32) |
| 37 | + if (r_type == R_MICROBLAZE_32 || r_type == R_MICROBLAZE_IMML_64) |
| 38 | { |
| 39 | outrel.r_info = ELF64_R_INFO (0, R_MICROBLAZE_REL); |
| 40 | outrel.r_addend = relocation + addend; |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 41 | @@ -1586,6 +1589,8 @@ microblaze_elf_relocate_section (bfd *output_bfd, |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 42 | relocation += addend; |
| 43 | if (r_type == R_MICROBLAZE_32) |
| 44 | bfd_put_32 (input_bfd, relocation, contents + offset); |
| 45 | + else if (r_type == R_MICROBLAZE_IMML_64) |
| 46 | + bfd_put_64 (input_bfd, relocation, contents + offset + endian); |
| 47 | else |
| 48 | { |
| 49 | if (r_type == R_MICROBLAZE_64_PCREL) |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 50 | @@ -2098,7 +2103,8 @@ microblaze_elf_relax_section (bfd *abfd, |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 51 | microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset, |
| 52 | irelscan->r_addend); |
| 53 | } |
| 54 | - if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32) |
| 55 | + if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32 |
| 56 | + || ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_IMML_64) |
| 57 | { |
| 58 | isym = isymbuf + ELF64_R_SYM (irelscan->r_info); |
| 59 | |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 60 | @@ -2606,6 +2612,7 @@ microblaze_elf_check_relocs (bfd * abfd, |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 61 | case R_MICROBLAZE_64: |
| 62 | case R_MICROBLAZE_64_PCREL: |
| 63 | case R_MICROBLAZE_32: |
| 64 | + case R_MICROBLAZE_IMML_64: |
| 65 | { |
| 66 | if (h != NULL && !bfd_link_pic (info)) |
| 67 | { |
| 68 | diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 69 | index bfb3104720..532a26eaa5 100644 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 70 | --- a/gas/config/tc-microblaze.c |
| 71 | +++ b/gas/config/tc-microblaze.c |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 72 | @@ -1119,6 +1119,13 @@ md_assemble (char * str) |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 73 | as_fatal (_("smi pseudo instruction should not use a label in imm field")); |
| 74 | if(streq (name, "lli") || streq (name, "sli")) |
| 75 | opc = str_microblaze_64; |
| 76 | + else if ((microblaze_arch_size == 64) && ((streq (name, "lbui") |
| 77 | + || streq (name, "lhui") || streq (name, "lwi") || streq (name, "sbi") |
| 78 | + || streq (name, "shi") || streq (name, "swi")))) |
| 79 | + { |
| 80 | + opc = str_microblaze_64; |
| 81 | + subtype = opcode->inst_offset_type; |
| 82 | + } |
| 83 | else if (reg2 == REG_ROSDP) |
| 84 | opc = str_microblaze_ro_anchor; |
| 85 | else if (reg2 == REG_RWSDP) |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 86 | @@ -1182,7 +1189,10 @@ md_assemble (char * str) |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 87 | inst |= (immed << IMM_LOW) & IMM_MASK; |
| 88 | } |
| 89 | } |
| 90 | - else if (streq (name, "lli") || streq (name, "sli")) |
| 91 | + else if (streq (name, "lli") || streq (name, "sli") || ((microblaze_arch_size == 64) |
| 92 | + && ((streq (name, "lbui")) || streq (name, "lhui") |
| 93 | + || streq (name, "lwi") || streq (name, "sbi") |
| 94 | + || streq (name, "shi") || streq (name, "swi")))) |
| 95 | { |
| 96 | temp = immed & 0xFFFFFF8000; |
| 97 | if (temp != 0 && temp != 0xFFFFFF8000) |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 98 | @@ -1794,6 +1804,11 @@ md_assemble (char * str) |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 99 | |
| 100 | if (exp.X_md != 0) |
| 101 | subtype = get_imm_otype(exp.X_md); |
| 102 | + else if (streq (name, "brealid") || streq (name, "breaid") || streq (name, "breai")) |
| 103 | + { |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 104 | + opc = str_microblaze_64; |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 105 | + subtype = opcode->inst_offset_type; |
| 106 | + } |
| 107 | else |
| 108 | subtype = opcode->inst_offset_type; |
| 109 | |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 110 | @@ -1811,6 +1826,31 @@ md_assemble (char * str) |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 111 | output = frag_more (isize); |
| 112 | immed = exp.X_add_number; |
| 113 | } |
| 114 | + if (streq (name, "brealid") || streq (name, "breaid") || streq (name, "breai")) |
| 115 | + { |
| 116 | + temp = immed & 0xFFFFFF8000; |
| 117 | + if (temp != 0 && temp != 0xFFFFFF8000) |
| 118 | + { |
| 119 | + /* Needs an immediate inst. */ |
| 120 | + opcode1 = (struct op_code_struct *) hash_find (opcode_hash_control, "imml"); |
| 121 | + if (opcode1 == NULL) |
| 122 | + { |
| 123 | + as_bad (_("unknown opcode \"%s\""), "imml"); |
| 124 | + return; |
| 125 | + } |
| 126 | + inst1 = opcode1->bit_sequence; |
| 127 | + inst1 |= ((immed & 0xFFFFFFFFFFFF0000L) >> 16) & IMML_MASK; |
| 128 | + output[0] = INST_BYTE0 (inst1); |
| 129 | + output[1] = INST_BYTE1 (inst1); |
| 130 | + output[2] = INST_BYTE2 (inst1); |
| 131 | + output[3] = INST_BYTE3 (inst1); |
| 132 | + output = frag_more (isize); |
| 133 | + } |
| 134 | + inst |= (reg1 << RD_LOW) & RD_MASK; |
| 135 | + inst |= (immed << IMM_LOW) & IMM_MASK; |
| 136 | + } |
| 137 | + else |
| 138 | + { |
| 139 | |
| 140 | temp = immed & 0xFFFF8000; |
| 141 | if ((temp != 0) && (temp != 0xFFFF8000)) |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 142 | @@ -1834,6 +1874,7 @@ md_assemble (char * str) |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 143 | |
| 144 | inst |= (reg1 << RD_LOW) & RD_MASK; |
| 145 | inst |= (immed << IMM_LOW) & IMM_MASK; |
| 146 | + } |
| 147 | break; |
| 148 | |
| 149 | case INST_TYPE_R2: |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 150 | @@ -3081,10 +3122,10 @@ cons_fix_new_microblaze (fragS * frag, |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 151 | r = BFD_RELOC_32; |
| 152 | break; |
| 153 | case 8: |
| 154 | - /*if (microblaze_arch_size == 64) |
| 155 | - r = BFD_RELOC_32; |
| 156 | - else*/ |
| 157 | + if (microblaze_arch_size == 64) |
| 158 | r = BFD_RELOC_MICROBLAZE_EA64; |
| 159 | + else |
| 160 | + r = BFD_RELOC_64; |
| 161 | break; |
| 162 | default: |
| 163 | as_bad (_("unsupported BFD relocation size %u"), size); |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 164 | -- |
| 165 | 2.17.1 |
| 166 | |