blob: ec82926d672855472b7ea83599c5fe0d322d04fa [file] [log] [blame]
Andrew Geissler84ad7c52020-06-27 00:00:16 -05001From beeceebb05a4eeaeca697f4ba7e214485b10369a Mon Sep 17 00:00:00 2001
Brad Bishop26bdd442019-08-16 17:08:17 -04002From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Sat, 13 Oct 2018 21:17:01 +0530
Andrew Geissler84ad7c52020-06-27 00:00:16 -05004Subject: [PATCH 22/43] Adding new relocation to support 64bit rodata
Brad Bishop26bdd442019-08-16 17:08:17 -04005
6---
Andrew Geissler84ad7c52020-06-27 00:00:16 -05007 bfd/elf64-microblaze.c | 11 +++++++--
8 gas/config/tc-microblaze.c | 49 ++++++++++++++++++++++++++++++++++----
Brad Bishop26bdd442019-08-16 17:08:17 -04009 2 files changed, 54 insertions(+), 6 deletions(-)
10
11diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
Andrew Geissler84ad7c52020-06-27 00:00:16 -050012index 40f10aac6d..4d9b90647f 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040013--- a/bfd/elf64-microblaze.c
14+++ b/bfd/elf64-microblaze.c
15@@ -1461,6 +1461,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
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
23@@ -1470,6 +1471,8 @@ microblaze_elf_relocate_section (bfd *output_bfd,
24 relocation += addend;
25 if (r_type == R_MICROBLAZE_32)// || r_type == R_MICROBLAZE_IMML_64)
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)
32@@ -1547,7 +1550,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
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;
41@@ -1573,6 +1576,8 @@ microblaze_elf_relocate_section (bfd *output_bfd,
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)
50@@ -2085,7 +2090,8 @@ microblaze_elf_relax_section (bfd *abfd,
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
60@@ -2591,6 +2597,7 @@ microblaze_elf_check_relocs (bfd * abfd,
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 {
68diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
Andrew Geissler84ad7c52020-06-27 00:00:16 -050069index 46df32e72f..c6d2e4c82d 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040070--- a/gas/config/tc-microblaze.c
71+++ b/gas/config/tc-microblaze.c
72@@ -1119,6 +1119,13 @@ md_assemble (char * str)
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)
86@@ -1182,7 +1189,10 @@ md_assemble (char * str)
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)
98@@ -1794,6 +1804,11 @@ md_assemble (char * str)
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+ {
104+ opc = str_microblaze_64;
105+ subtype = opcode->inst_offset_type;
106+ }
107 else
108 subtype = opcode->inst_offset_type;
109
110@@ -1811,6 +1826,31 @@ md_assemble (char * str)
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))
142@@ -1834,6 +1874,7 @@ md_assemble (char * str)
143
144 inst |= (reg1 << RD_LOW) & RD_MASK;
145 inst |= (immed << IMM_LOW) & IMM_MASK;
146+ }
147 break;
148
149 case INST_TYPE_R2:
150@@ -3085,10 +3126,10 @@ cons_fix_new_microblaze (fragS * frag,
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 Geissler84ad7c52020-06-27 00:00:16 -0500164--
1652.17.1
166