diff options
Diffstat (limited to 'meta-microblaze/recipes-devtools/binutils/binutils/0004-LOCAL-Fix-relaxation-of-assembler-resolved-reference.patch')
-rw-r--r-- | meta-microblaze/recipes-devtools/binutils/binutils/0004-LOCAL-Fix-relaxation-of-assembler-resolved-reference.patch | 312 |
1 files changed, 0 insertions, 312 deletions
diff --git a/meta-microblaze/recipes-devtools/binutils/binutils/0004-LOCAL-Fix-relaxation-of-assembler-resolved-reference.patch b/meta-microblaze/recipes-devtools/binutils/binutils/0004-LOCAL-Fix-relaxation-of-assembler-resolved-reference.patch deleted file mode 100644 index d645db9f..00000000 --- a/meta-microblaze/recipes-devtools/binutils/binutils/0004-LOCAL-Fix-relaxation-of-assembler-resolved-reference.patch +++ /dev/null | |||
@@ -1,312 +0,0 @@ | |||
1 | From f7c540994e73e430e73d220109e911dff5961f16 Mon Sep 17 00:00:00 2001 | ||
2 | From: Mahesh Bodapati <mbodapat@xilinx.com> | ||
3 | Date: Tue, 8 Nov 2016 11:54:08 +0530 | ||
4 | Subject: [PATCH 04/34] [LOCAL]: Fix relaxation of assembler resolved | ||
5 | references,Fixup debug_loc sections after linker relaxation Adds a new | ||
6 | reloctype R_MICROBLAZE_32_NONE, used for passing reloc info from the | ||
7 | assembler to the linker when the linker manages to fully resolve a local | ||
8 | symbol reference. | ||
9 | |||
10 | This is a workaround for design flaws in the assembler to | ||
11 | linker interface with regards to linker relaxation. | ||
12 | |||
13 | Upstream-Status: Pending | ||
14 | |||
15 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> | ||
16 | Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com> | ||
17 | |||
18 | Conflicts: | ||
19 | bfd/elf32-microblaze.c | ||
20 | binutils/readelf.c | ||
21 | include/elf/microblaze.h | ||
22 | |||
23 | Conflicts: | ||
24 | binutils/readelf.c | ||
25 | |||
26 | Conflicts: | ||
27 | bfd/elf32-microblaze.c | ||
28 | --- | ||
29 | bfd/bfd-in2.h | 5 ++ | ||
30 | bfd/elf32-microblaze.c | 126 ++++++++++++++++++++++++++++--------- | ||
31 | bfd/libbfd.h | 1 + | ||
32 | bfd/reloc.c | 6 ++ | ||
33 | binutils/readelf.c | 4 ++ | ||
34 | gas/config/tc-microblaze.c | 4 ++ | ||
35 | include/elf/microblaze.h | 2 + | ||
36 | 7 files changed, 119 insertions(+), 29 deletions(-) | ||
37 | |||
38 | diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h | ||
39 | index 1f0f18a7e75..26e3bb2b34b 100644 | ||
40 | --- a/bfd/bfd-in2.h | ||
41 | +++ b/bfd/bfd-in2.h | ||
42 | @@ -5379,6 +5379,11 @@ value relative to the read-write small data area anchor */ | ||
43 | expressions of the form "Symbol Op Symbol" */ | ||
44 | BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM, | ||
45 | |||
46 | +/* This is a 32 bit reloc that stores the 32 bit pc relative | ||
47 | +value in two words (with an imm instruction).No relocation is | ||
48 | +done here - only used for relaxing */ | ||
49 | + BFD_RELOC_MICROBLAZE_32_NONE, | ||
50 | + | ||
51 | /* This is a 64 bit reloc that stores the 32 bit pc relative | ||
52 | value in two words (with an imm instruction). No relocation is | ||
53 | done here - only used for relaxing */ | ||
54 | diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c | ||
55 | index 013c32a1e51..7cf1b6eab5b 100644 | ||
56 | --- a/bfd/elf32-microblaze.c | ||
57 | +++ b/bfd/elf32-microblaze.c | ||
58 | @@ -175,6 +175,20 @@ static reloc_howto_type microblaze_elf_howto_raw[] = | ||
59 | false), /* PC relative offset? */ | ||
60 | |||
61 | /* This reloc does nothing. Used for relaxation. */ | ||
62 | + HOWTO (R_MICROBLAZE_32_NONE, /* Type. */ | ||
63 | + 0, /* Rightshift. */ | ||
64 | + 2, /* Size (0 = byte, 1 = short, 2 = long). */ | ||
65 | + 32, /* Bitsize. */ | ||
66 | + true, /* PC_relative. */ | ||
67 | + 0, /* Bitpos. */ | ||
68 | + complain_overflow_bitfield, /* Complain on overflow. */ | ||
69 | + NULL, /* Special Function. */ | ||
70 | + "R_MICROBLAZE_32_NONE",/* Name. */ | ||
71 | + false, /* Partial Inplace. */ | ||
72 | + 0, /* Source Mask. */ | ||
73 | + 0, /* Dest Mask. */ | ||
74 | + false), /* PC relative offset? */ | ||
75 | + | ||
76 | HOWTO (R_MICROBLAZE_64_NONE, /* Type. */ | ||
77 | 0, /* Rightshift. */ | ||
78 | 0, /* Size. */ | ||
79 | @@ -560,7 +574,10 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, | ||
80 | case BFD_RELOC_NONE: | ||
81 | microblaze_reloc = R_MICROBLAZE_NONE; | ||
82 | break; | ||
83 | - case BFD_RELOC_MICROBLAZE_64_NONE: | ||
84 | + case BFD_RELOC_MICROBLAZE_32_NONE: | ||
85 | + microblaze_reloc = R_MICROBLAZE_32_NONE; | ||
86 | + break; | ||
87 | + case BFD_RELOC_MICROBLAZE_64_NONE: | ||
88 | microblaze_reloc = R_MICROBLAZE_64_NONE; | ||
89 | break; | ||
90 | case BFD_RELOC_32: | ||
91 | @@ -1954,18 +1971,26 @@ microblaze_elf_relax_section (bfd *abfd, | ||
92 | } | ||
93 | break; | ||
94 | case R_MICROBLAZE_NONE: | ||
95 | + case R_MICROBLAZE_32_NONE: | ||
96 | { | ||
97 | /* This was a PC-relative instruction that was | ||
98 | completely resolved. */ | ||
99 | size_t sfix, efix; | ||
100 | + unsigned int val; | ||
101 | bfd_vma target_address; | ||
102 | target_address = irel->r_addend + irel->r_offset; | ||
103 | sfix = calc_fixup (irel->r_offset, 0, sec); | ||
104 | efix = calc_fixup (target_address, 0, sec); | ||
105 | - irel->r_addend -= (efix - sfix); | ||
106 | - /* Should use HOWTO. */ | ||
107 | - microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset, | ||
108 | - irel->r_addend); | ||
109 | + | ||
110 | + /* Validate the in-band val. */ | ||
111 | + val = bfd_get_32 (abfd, contents + irel->r_offset); | ||
112 | + if (val != irel->r_addend && ELF32_R_TYPE (irel->r_info) == R_MICROBLAZE_32_NONE) { | ||
113 | + fprintf(stderr, "%d: CORRUPT relax reloc %x %lx\n", __LINE__, val, irel->r_addend); | ||
114 | + } | ||
115 | + irel->r_addend -= (efix - sfix); | ||
116 | + /* Should use HOWTO. */ | ||
117 | + microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset, | ||
118 | + irel->r_addend); | ||
119 | } | ||
120 | break; | ||
121 | case R_MICROBLAZE_64_NONE: | ||
122 | @@ -2009,30 +2034,73 @@ microblaze_elf_relax_section (bfd *abfd, | ||
123 | irelscanend = irelocs + o->reloc_count; | ||
124 | for (irelscan = irelocs; irelscan < irelscanend; irelscan++) | ||
125 | { | ||
126 | - if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32) | ||
127 | - { | ||
128 | - isym = isymbuf + ELF32_R_SYM (irelscan->r_info); | ||
129 | + if (1 && ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE) | ||
130 | + { | ||
131 | + unsigned int val; | ||
132 | + | ||
133 | + isym = isymbuf + ELF32_R_SYM (irelscan->r_info); | ||
134 | + | ||
135 | + /* hax: We only do the following fixup for debug location lists. */ | ||
136 | + if (strcmp(".debug_loc", o->name)) | ||
137 | + continue; | ||
138 | + | ||
139 | + /* This was a PC-relative instruction that was completely resolved. */ | ||
140 | + if (ocontents == NULL) | ||
141 | + { | ||
142 | + if (elf_section_data (o)->this_hdr.contents != NULL) | ||
143 | + ocontents = elf_section_data (o)->this_hdr.contents; | ||
144 | + else | ||
145 | + { | ||
146 | + /* We always cache the section contents. | ||
147 | + Perhaps, if info->keep_memory is FALSE, we | ||
148 | + should free them, if we are permitted to. */ | ||
149 | + | ||
150 | + if (o->rawsize == 0) | ||
151 | + o->rawsize = o->size; | ||
152 | + ocontents = (bfd_byte *) bfd_malloc (o->rawsize); | ||
153 | + if (ocontents == NULL) | ||
154 | + goto error_return; | ||
155 | + if (!bfd_get_section_contents (abfd, o, ocontents, | ||
156 | + (file_ptr) 0, | ||
157 | + o->rawsize)) | ||
158 | + goto error_return; | ||
159 | + elf_section_data (o)->this_hdr.contents = ocontents; | ||
160 | + } | ||
161 | + } | ||
162 | |||
163 | - /* Look at the reloc only if the value has been resolved. */ | ||
164 | - if (isym->st_shndx == shndx | ||
165 | - && (ELF32_ST_TYPE (isym->st_info) == STT_SECTION)) | ||
166 | - { | ||
167 | - if (ocontents == NULL) | ||
168 | - { | ||
169 | - if (elf_section_data (o)->this_hdr.contents != NULL) | ||
170 | - ocontents = elf_section_data (o)->this_hdr.contents; | ||
171 | - else | ||
172 | - { | ||
173 | - /* We always cache the section contents. | ||
174 | - Perhaps, if info->keep_memory is FALSE, we | ||
175 | - should free them, if we are permitted to. */ | ||
176 | - if (o->rawsize == 0) | ||
177 | - o->rawsize = o->size; | ||
178 | - ocontents = (bfd_byte *) bfd_malloc (o->rawsize); | ||
179 | - if (ocontents == NULL) | ||
180 | - goto error_return; | ||
181 | - if (!bfd_get_section_contents (abfd, o, ocontents, | ||
182 | - (file_ptr) 0, | ||
183 | + val = bfd_get_32 (abfd, ocontents + irelscan->r_offset); | ||
184 | + if (val != irelscan->r_addend) { | ||
185 | + fprintf(stderr, "%d: CORRUPT relax reloc! %x %lx\n", __LINE__, val, irelscan->r_addend); | ||
186 | + } | ||
187 | + | ||
188 | + irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec); | ||
189 | + microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset, | ||
190 | + irelscan->r_addend); | ||
191 | + } | ||
192 | + if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32) | ||
193 | + { | ||
194 | + isym = isymbuf + ELF32_R_SYM (irelscan->r_info); | ||
195 | + | ||
196 | + /* Look at the reloc only if the value has been resolved. */ | ||
197 | + if (isym->st_shndx == shndx | ||
198 | + && (ELF32_ST_TYPE (isym->st_info) == STT_SECTION)) | ||
199 | + { | ||
200 | + if (ocontents == NULL) | ||
201 | + { | ||
202 | + if (elf_section_data (o)->this_hdr.contents != NULL) | ||
203 | + ocontents = elf_section_data (o)->this_hdr.contents; | ||
204 | + else | ||
205 | + { | ||
206 | + /* We always cache the section contents. | ||
207 | + Perhaps, if info->keep_memory is FALSE, we | ||
208 | + should free them, if we are permitted to. */ | ||
209 | + if (o->rawsize == 0) | ||
210 | + o->rawsize = o->size; | ||
211 | + ocontents = (bfd_byte *) bfd_malloc (o->rawsize); | ||
212 | + if (ocontents == NULL) | ||
213 | + goto error_return; | ||
214 | + if (!bfd_get_section_contents (abfd, o, ocontents, | ||
215 | + (file_ptr) 0, | ||
216 | o->rawsize)) | ||
217 | goto error_return; | ||
218 | elf_section_data (o)->this_hdr.contents = ocontents; | ||
219 | @@ -2068,7 +2136,7 @@ microblaze_elf_relax_section (bfd *abfd, | ||
220 | elf_section_data (o)->this_hdr.contents = ocontents; | ||
221 | } | ||
222 | } | ||
223 | - irelscan->r_addend -= calc_fixup (irel->r_addend | ||
224 | + irelscan->r_addend -= calc_fixup (irelscan->r_addend | ||
225 | + isym->st_value, | ||
226 | 0, | ||
227 | sec); | ||
228 | diff --git a/bfd/libbfd.h b/bfd/libbfd.h | ||
229 | index 29e8187f95f..ea2507d1879 100644 | ||
230 | --- a/bfd/libbfd.h | ||
231 | +++ b/bfd/libbfd.h | ||
232 | @@ -2989,6 +2989,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", | ||
233 | "BFD_RELOC_MICROBLAZE_32_ROSDA", | ||
234 | "BFD_RELOC_MICROBLAZE_32_RWSDA", | ||
235 | "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM", | ||
236 | + "BFD_RELOC_MICROBLAZE_32_NONE", | ||
237 | "BFD_RELOC_MICROBLAZE_64_NONE", | ||
238 | "BFD_RELOC_MICROBLAZE_64_GOTPC", | ||
239 | "BFD_RELOC_MICROBLAZE_64_GOT", | ||
240 | diff --git a/bfd/reloc.c b/bfd/reloc.c | ||
241 | index 36999fe9a40..5ac8a8536a7 100644 | ||
242 | --- a/bfd/reloc.c | ||
243 | +++ b/bfd/reloc.c | ||
244 | @@ -6867,6 +6867,12 @@ ENUM | ||
245 | ENUMDOC | ||
246 | This is a 32 bit reloc for the microblaze to handle | ||
247 | expressions of the form "Symbol Op Symbol" | ||
248 | +ENUM | ||
249 | + BFD_RELOC_MICROBLAZE_32_NONE | ||
250 | +ENUMDOC | ||
251 | + This is a 32 bit reloc that stores the 32 bit pc relative | ||
252 | + value in two words (with an imm instruction). No relocation is | ||
253 | + done here - only used for relaxing | ||
254 | ENUM | ||
255 | BFD_RELOC_MICROBLAZE_64_NONE | ||
256 | ENUMDOC | ||
257 | diff --git a/binutils/readelf.c b/binutils/readelf.c | ||
258 | index 0f5977bc072..acd12713361 100644 | ||
259 | --- a/binutils/readelf.c | ||
260 | +++ b/binutils/readelf.c | ||
261 | @@ -14621,6 +14621,10 @@ is_8bit_abs_reloc (Filedata * filedata, unsigned int reloc_type) | ||
262 | return reloc_type == 1; /* R_Z80_8. */ | ||
263 | default: | ||
264 | return false; | ||
265 | + case EM_MICROBLAZE: | ||
266 | + return reloc_type == 33 /* R_MICROBLAZE_32_NONE. */ | ||
267 | + || reloc_type == 0 /* R_MICROBLAZE_NONE. */ | ||
268 | + || reloc_type == 9; /* R_MICROBLAZE_64_NONE. */ | ||
269 | } | ||
270 | } | ||
271 | |||
272 | diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c | ||
273 | index c927331ea0a..8018d1f5686 100644 | ||
274 | --- a/gas/config/tc-microblaze.c | ||
275 | +++ b/gas/config/tc-microblaze.c | ||
276 | @@ -2211,9 +2211,12 @@ md_apply_fix (fixS * fixP, | ||
277 | moves code around due to relaxing. */ | ||
278 | if (fixP->fx_r_type == BFD_RELOC_64_PCREL) | ||
279 | fixP->fx_r_type = BFD_RELOC_MICROBLAZE_64_NONE; | ||
280 | + else if (fixP->fx_r_type == BFD_RELOC_32) | ||
281 | + fixP->fx_r_type = BFD_RELOC_MICROBLAZE_32_NONE; | ||
282 | else | ||
283 | fixP->fx_r_type = BFD_RELOC_NONE; | ||
284 | fixP->fx_addsy = section_symbol (absolute_section); | ||
285 | + fixP->fx_done = 0; | ||
286 | } | ||
287 | return; | ||
288 | } | ||
289 | @@ -2434,6 +2437,7 @@ tc_gen_reloc (asection * section ATTRIBUTE_UNUSED, fixS * fixp) | ||
290 | switch (fixp->fx_r_type) | ||
291 | { | ||
292 | case BFD_RELOC_NONE: | ||
293 | + case BFD_RELOC_MICROBLAZE_32_NONE: | ||
294 | case BFD_RELOC_MICROBLAZE_64_NONE: | ||
295 | case BFD_RELOC_32: | ||
296 | case BFD_RELOC_MICROBLAZE_32_LO: | ||
297 | diff --git a/include/elf/microblaze.h b/include/elf/microblaze.h | ||
298 | index 43ad3ad3904..a2e1ce4580f 100644 | ||
299 | --- a/include/elf/microblaze.h | ||
300 | +++ b/include/elf/microblaze.h | ||
301 | @@ -61,6 +61,8 @@ START_RELOC_NUMBERS (elf_microblaze_reloc_type) | ||
302 | RELOC_NUMBER (R_MICROBLAZE_TEXTPCREL_64, 30) /* PC-relative TEXT offset. */ | ||
303 | RELOC_NUMBER (R_MICROBLAZE_TEXTREL_64, 31) /* TEXT Entry offset 64-bit. */ | ||
304 | RELOC_NUMBER (R_MICROBLAZE_TEXTREL_32_LO, 32) /* TEXT Entry offset 32-bit. */ | ||
305 | + RELOC_NUMBER (R_MICROBLAZE_32_NONE, 33) | ||
306 | + | ||
307 | END_RELOC_NUMBERS (R_MICROBLAZE_max) | ||
308 | |||
309 | /* Global base address names. */ | ||
310 | -- | ||
311 | 2.37.1 (Apple Git-137.1) | ||
312 | |||