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