summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/binutils/binutils/0033-Patch-MB-MB-binutils-Upstream-port-issues.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-microblaze/recipes-devtools/binutils/binutils/0033-Patch-MB-MB-binutils-Upstream-port-issues.patch')
-rw-r--r--meta-microblaze/recipes-devtools/binutils/binutils/0033-Patch-MB-MB-binutils-Upstream-port-issues.patch540
1 files changed, 0 insertions, 540 deletions
diff --git a/meta-microblaze/recipes-devtools/binutils/binutils/0033-Patch-MB-MB-binutils-Upstream-port-issues.patch b/meta-microblaze/recipes-devtools/binutils/binutils/0033-Patch-MB-MB-binutils-Upstream-port-issues.patch
deleted file mode 100644
index f91fcbc6..00000000
--- a/meta-microblaze/recipes-devtools/binutils/binutils/0033-Patch-MB-MB-binutils-Upstream-port-issues.patch
+++ /dev/null
@@ -1,540 +0,0 @@
1From 5b79b9fe7da091664680b86e3b09bc4b926e2e61 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Sun, 28 Nov 2021 17:17:15 +0530
4Subject: [PATCH 33/34] [Patch,MB]: MB binutils Upstream port issues.
5
6It's resolving the seg faults with ADDLIK
7Conflicts:
8 bfd/elf64-microblaze.c
9Upstream-Status: Pending
10
11Signed-off-by: Mark Hatle <mark.hatle@amd.com>
12
13---
14 bfd/elf64-microblaze.c | 248 ++++++++++++++++++++++++++++---------
15 gas/config/tc-microblaze.c | 2 +-
16 opcodes/microblaze-dis.c | 12 +-
17 opcodes/microblaze-opc.h | 2 +-
18 4 files changed, 197 insertions(+), 67 deletions(-)
19
20diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
21index 77872cef1ab..119d266f95a 100644
22--- a/bfd/elf64-microblaze.c
23+++ b/bfd/elf64-microblaze.c
24@@ -807,12 +807,35 @@ microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
25 return _bfd_elf_is_local_label_name (abfd, name);
26 }
27
28+/* The microblaze linker (like many others) needs to keep track of
29+ the number of relocs that it decides to copy as dynamic relocs in
30+ check_relocs for each symbol. This is so that it can later discard
31+ them if they are found to be unnecessary. We store the information
32+ in a field extending the regular ELF linker hash table. */
33+
34+struct elf64_mb_dyn_relocs
35+{
36+ struct elf64_mb_dyn_relocs *next;
37+
38+ /* The input section of the reloc. */
39+ asection *sec;
40+
41+ /* Total number of relocs copied for the input section. */
42+ bfd_size_type count;
43+
44+ /* Number of pc-relative relocs copied for the input section. */
45+ bfd_size_type pc_count;
46+};
47+
48 /* ELF linker hash entry. */
49
50 struct elf64_mb_link_hash_entry
51 {
52 struct elf_link_hash_entry elf;
53
54+ /* Track dynamic relocs copied for this symbol. */
55+ struct elf64_mb_dyn_relocs *dyn_relocs;
56+
57 /* TLS Reference Types for the symbol; Updated by check_relocs */
58 #define TLS_GD 1 /* GD reloc. */
59 #define TLS_LD 2 /* LD reloc. */
60@@ -836,6 +859,18 @@ struct elf64_mb_link_hash_table
61 {
62 struct elf_link_hash_table elf;
63
64+ /* Short-cuts to get to dynamic linker sections. */
65+ asection *sgot;
66+ asection *sgotplt;
67+ asection *srelgot;
68+ asection *splt;
69+ asection *srelplt;
70+ asection *sdynbss;
71+ asection *srelbss;
72+
73+ /* Small local sym to section mapping cache. */
74+ struct sym_cache sym_sec;
75+
76 /* TLS Local Dynamic GOT Entry */
77 union {
78 bfd_signed_vma refcount;
79@@ -1376,8 +1411,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
80 /* Need to generate relocs ? */
81 if ((bfd_link_pic (info) || indx != 0)
82 && (h == NULL
83- || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
84- && !resolved_to_zero)
85+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
86 || h->root.type != bfd_link_hash_undefweak))
87 need_relocs = true;
88
89@@ -1564,13 +1598,11 @@ microblaze_elf_relocate_section (bfd *output_bfd,
90 contents + offset + endian);
91 }
92 else
93- {
94- bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
95- contents + offset + endian);
96- bfd_put_16 (input_bfd, relocation & 0xffff,
97- contents + offset + endian + INST_WORD_SIZE);
98+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
99+ contents + offset + endian);
100+ bfd_put_16 (input_bfd, relocation & 0xffff,
101+ contents + offset + endian + INST_WORD_SIZE);
102 }
103- }
104 break;
105 }
106
107@@ -1660,9 +1692,16 @@ microblaze_elf_relocate_section (bfd *output_bfd,
108 else
109 {
110 if (r_type == R_MICROBLAZE_64_PCREL)
111+ {
112+ if (!input_section->output_section->vma &&
113+ !input_section->output_offset && !offset)
114+ relocation -= (input_section->output_section->vma
115+ + input_section->output_offset
116+ + offset);
117+ else
118 relocation -= (input_section->output_section->vma
119- + input_section->output_offset
120- + offset + INST_WORD_SIZE);
121+ + input_section->output_offset + offset + INST_WORD_SIZE);
122+ }
123 else if (r_type == R_MICROBLAZE_TEXTREL_64
124 || r_type == R_MICROBLAZE_TEXTREL_32_LO)
125 relocation -= input_section->output_section->vma;
126@@ -1681,14 +1720,11 @@ microblaze_elf_relocate_section (bfd *output_bfd,
127 contents + offset + endian);
128 }
129 else
130- {
131- bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
132- contents + offset + endian);
133- bfd_put_16 (input_bfd, relocation & 0xffff,
134- contents + offset + endian
135- + INST_WORD_SIZE);
136- }
137- }
138+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
139+ contents + offset + endian);
140+ bfd_put_16 (input_bfd, relocation & 0xffff,
141+ contents + offset + endian + INST_WORD_SIZE);
142+ }
143 break;
144 }
145 }
146@@ -1759,6 +1795,21 @@ microblaze_elf_relocate_section (bfd *output_bfd,
147
148 return ret;
149 }
150+
151+/* Merge backend specific data from an object file to the output
152+ object file when linking.
153+
154+ Note: We only use this hook to catch endian mismatches. */
155+static bool
156+microblaze_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
157+{
158+ /* Check if we have the same endianess. */
159+ if (! _bfd_generic_verify_endian_match (ibfd, obfd))
160+ return false;
161+
162+ return true;
163+}
164+
165
166 /* Calculate fixup value for reference. */
167
168@@ -2512,6 +2563,17 @@ microblaze_elf_gc_mark_hook (asection *sec,
169 return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
170 }
171
172+/* Update the got entry reference counts for the section being removed. */
173+
174+static bool
175+microblaze_elf_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED,
176+ struct bfd_link_info * info ATTRIBUTE_UNUSED,
177+ asection * sec ATTRIBUTE_UNUSED,
178+ const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
179+{
180+ return true;
181+}
182+
183 /* PIC support. */
184
185 #define PLT_ENTRY_SIZE 16
186@@ -2718,14 +2780,14 @@ microblaze_elf_check_relocs (bfd * abfd,
187 && (! info->symbolic
188 || h->root.type == bfd_link_hash_defweak
189 || !h->def_regular))))
190- || (!bfd_link_pic (info)
191- && (sec->flags & SEC_ALLOC) != 0
192- && h != NULL
193- && (h->root.type == bfd_link_hash_defweak
194- || !h->def_regular)))
195- {
196- struct elf_dyn_relocs *p;
197- struct elf_dyn_relocs **head;
198+ || (!bfd_link_pic (info)
199+ && (sec->flags & SEC_ALLOC) != 0
200+ && h != NULL
201+ && (h->root.type == bfd_link_hash_defweak
202+ || !h->def_regular)))
203+ {
204+ struct elf64_mb_dyn_relocs *p;
205+ struct elf64_mb_dyn_relocs **head;
206
207 /* When creating a shared object, we must copy these
208 relocs into the output file. We create a reloc
209@@ -2769,14 +2831,14 @@ microblaze_elf_check_relocs (bfd * abfd,
210 return false;
211
212 vpp = &elf_section_data (s)->local_dynrel;
213- head = (struct elf_dyn_relocs **) vpp;
214+ head = (struct elf64_mb_dyn_relocs **) vpp;
215 }
216
217 p = *head;
218 if (p == NULL || p->sec != sec)
219 {
220 size_t amt = sizeof *p;
221- p = ((struct elf_dyn_relocs *)
222+ p = ((struct elf64_mb_dyn_relocs *)
223 bfd_alloc (htab->elf.dynobj, amt));
224 if (p == NULL)
225 return false;
226@@ -2799,6 +2861,34 @@ microblaze_elf_check_relocs (bfd * abfd,
227 return true;
228 }
229
230+static bool
231+microblaze_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
232+{
233+ struct elf64_mb_link_hash_table *htab;
234+
235+ htab = elf64_mb_hash_table (info);
236+ if (htab == NULL)
237+ return false;
238+
239+ if (!htab->sgot && !_bfd_elf_create_got_section (dynobj, info))
240+ return false;
241+
242+ if (!_bfd_elf_create_dynamic_sections (dynobj, info))
243+ return false;
244+
245+ htab->splt = bfd_get_linker_section (dynobj, ".plt");
246+ htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
247+ htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
248+ if (!bfd_link_pic (info))
249+ htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
250+
251+ if (!htab->splt || !htab->srelplt || !htab->sdynbss
252+ || (!bfd_link_pic (info) && !htab->srelbss))
253+ abort ();
254+
255+ return true;
256+}
257+
258 /* Copy the extra info we tack onto an elf_link_hash_entry. */
259
260 static void
261@@ -2811,6 +2901,40 @@ microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info,
262 edir = (struct elf64_mb_link_hash_entry *) dir;
263 eind = (struct elf64_mb_link_hash_entry *) ind;
264
265+ if (eind->dyn_relocs != NULL)
266+ {
267+ if (edir->dyn_relocs != NULL)
268+ {
269+ struct elf64_mb_dyn_relocs **pp;
270+ struct elf64_mb_dyn_relocs *p;
271+
272+ if (ind->root.type == bfd_link_hash_indirect)
273+ abort ();
274+
275+ /* Add reloc counts against the weak sym to the strong sym
276+ list. Merge any entries against the same section. */
277+ for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
278+ {
279+ struct elf64_mb_dyn_relocs *q;
280+
281+ for (q = edir->dyn_relocs; q != NULL; q = q->next)
282+ if (q->sec == p->sec)
283+ {
284+ q->pc_count += p->pc_count;
285+ q->count += p->count;
286+ *pp = p->next;
287+ break;
288+ }
289+ if (q == NULL)
290+ pp = &p->next;
291+ }
292+ *pp = edir->dyn_relocs;
293+ }
294+
295+ edir->dyn_relocs = eind->dyn_relocs;
296+ eind->dyn_relocs = NULL;
297+ }
298+
299 edir->tls_mask |= eind->tls_mask;
300
301 _bfd_elf_link_hash_copy_indirect (info, dir, ind);
302@@ -2821,8 +2945,12 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
303 struct elf_link_hash_entry *h)
304 {
305 struct elf64_mb_link_hash_table *htab;
306+ struct elf64_mb_link_hash_entry * eh;
307+ struct elf64_mb_dyn_relocs *p;
308+ asection *sdynbss;
309 asection *s, *srel;
310 unsigned int power_of_two;
311+ bfd *dynobj;
312
313 htab = elf64_mb_hash_table (info);
314 if (htab == NULL)
315@@ -2892,9 +3020,17 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
316 return true;
317 }
318
319- /* If we don't find any dynamic relocs in read-only sections, then
320+ eh = (struct elf64_mb_link_hash_entry *) h;
321+ for (p = eh->dyn_relocs; p != NULL; p = p->next)
322+ {
323+ s = p->sec->output_section;
324+ if (s != NULL && (s->flags & SEC_READONLY) != 0)
325+ break;
326+ }
327+
328+ /* If we didn't find any dynamic relocs in read-only sections, then
329 we'll be keeping the dynamic relocs and avoiding the copy reloc. */
330- if (!_bfd_elf_readonly_dynrelocs (h))
331+ if (p == NULL)
332 {
333 h->non_got_ref = 0;
334 return true;
335@@ -2913,19 +3049,11 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
336 /* We must generate a R_MICROBLAZE_COPY reloc to tell the dynamic linker
337 to copy the initial value out of the dynamic object and into the
338 runtime process image. */
339- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
340- {
341- s = htab->elf.sdynrelro;
342- srel = htab->elf.sreldynrelro;
343- }
344- else
345- {
346- s = htab->elf.sdynbss;
347- srel = htab->elf.srelbss;
348- }
349+ dynobj = elf_hash_table (info)->dynobj;
350+ BFD_ASSERT (dynobj != NULL);
351 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
352 {
353- srel->size += sizeof (Elf64_External_Rela);
354+ htab->srelbss->size += sizeof (Elf64_External_Rela);
355 h->needs_copy = 1;
356 }
357
358@@ -2935,11 +3063,12 @@ microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
359 if (power_of_two > 3)
360 power_of_two = 3;
361
362+ sdynbss = htab->sdynbss;
363 /* Apply the required alignment. */
364- s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two));
365- if (power_of_two > s->alignment_power)
366+ sdynbss->size = BFD_ALIGN (sdynbss->size, (bfd_size_type) (1 << power_of_two));
367+ if (power_of_two > sdynbss->alignment_power)
368 {
369- if (!bfd_set_section_alignment (s, power_of_two))
370+ if (! bfd_set_section_alignment (sdynbss, power_of_two))
371 return false;
372 }
373
374@@ -2961,7 +3090,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
375 struct bfd_link_info *info;
376 struct elf64_mb_link_hash_table *htab;
377 struct elf64_mb_link_hash_entry *eh;
378- struct elf_dyn_relocs *p;
379+ struct elf64_mb_dyn_relocs *p;
380
381 if (h->root.type == bfd_link_hash_indirect)
382 return true;
383@@ -3013,7 +3142,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
384 htab->elf.sgotplt->size += 4;
385
386 /* We also need to make an entry in the .rel.plt section. */
387- htab->elf.srelplt->size += sizeof (Elf32_External_Rela);
388+ htab->elf.srelplt->size += sizeof (Elf64_External_Rela);
389 }
390 else
391 {
392@@ -3079,7 +3208,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
393 else
394 h->got.offset = (bfd_vma) -1;
395
396- if (h->dyn_relocs == NULL)
397+ if (eh->dyn_relocs == NULL)
398 return true;
399
400 /* In the shared -Bsymbolic case, discard space allocated for
401@@ -3094,9 +3223,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
402 && (h->forced_local
403 || info->symbolic))
404 {
405- struct elf_dyn_relocs **pp;
406+ struct elf64_mb_dyn_relocs **pp;
407
408- for (pp = &h->dyn_relocs; (p = *pp) != NULL; )
409+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
410 {
411 p->count -= p->pc_count;
412 p->pc_count = 0;
413@@ -3188,7 +3317,7 @@ microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
414 {
415 struct elf_dyn_relocs *p;
416
417- for (p = ((struct elf_dyn_relocs *)
418+ for (p = ((struct elf64_mb_dyn_relocs *)
419 elf_section_data (s)->local_dynrel);
420 p != NULL;
421 p = p->next)
422@@ -3666,13 +3795,14 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
423 #define bfd_elf64_new_section_hook microblaze_elf_new_section_hook
424 #define elf_backend_relocate_section microblaze_elf_relocate_section
425 #define bfd_elf64_bfd_relax_section microblaze_elf_relax_section
426-#define bfd_elf64_bfd_merge_private_bfd_data _bfd_generic_verify_endian_match
427+#define bfd_elf64_bfd_merge_private_bfd_data microblaze_elf_merge_private_bfd_data
428 #define bfd_elf64_bfd_reloc_name_lookup microblaze_elf_reloc_name_lookup
429
430 #define elf_backend_gc_mark_hook microblaze_elf_gc_mark_hook
431-#define elf_backend_check_relocs microblaze_elf_check_relocs
432-#define elf_backend_copy_indirect_symbol microblaze_elf_copy_indirect_symbol
433-#define bfd_elf64_bfd_link_hash_table_create microblaze_elf_link_hash_table_create
434+#define elf_backend_gc_sweep_hook microblaze_elf_gc_sweep_hook
435+#define elf_backend_check_relocs microblaze_elf_check_relocs
436+#define elf_backend_copy_indirect_symbol microblaze_elf_copy_indirect_symbol
437+#define bfd_elf64_bfd_link_hash_table_create microblaze_elf_link_hash_table_create
438 #define elf_backend_can_gc_sections 1
439 #define elf_backend_can_refcount 1
440 #define elf_backend_want_got_plt 1
441@@ -3682,11 +3812,11 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
442 #define elf_backend_rela_normal 1
443 #define elf_backend_dtrel_excludes_plt 1
444
445-#define elf_backend_adjust_dynamic_symbol microblaze_elf_adjust_dynamic_symbol
446-#define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
447-#define elf_backend_finish_dynamic_sections microblaze_elf_finish_dynamic_sections
448-#define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol
449-#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
450+#define elf_backend_adjust_dynamic_symbol microblaze_elf_adjust_dynamic_symbol
451+#define elf_backend_create_dynamic_sections microblaze_elf_create_dynamic_sections
452+#define elf_backend_finish_dynamic_sections microblaze_elf_finish_dynamic_sections
453+#define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol
454+#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
455 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
456
457 #include "elf64-target.h"
458diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
459index 6b398ab5605..c4a3817bf19 100644
460--- a/gas/config/tc-microblaze.c
461+++ b/gas/config/tc-microblaze.c
462@@ -433,7 +433,7 @@ const pseudo_typeS md_pseudo_table[] =
463 void
464 md_begin (void)
465 {
466- const struct op_code_struct * opcode;
467+ struct op_code_struct * opcode;
468 const char *prev_name = "";
469
470 opcode_hash_control = str_htab_create ();
471diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
472index b5a78dcfe09..b76a5935a34 100644
473--- a/opcodes/microblaze-dis.c
474+++ b/opcodes/microblaze-dis.c
475@@ -140,7 +140,7 @@ get_field_imm16 (struct string_buf *buf, long instr)
476
477 static char *
478 get_field_special (struct string_buf *buf, long instr,
479- const struct op_code_struct *op)
480+ struct op_code_struct *op)
481 {
482 char *p = strbuf (buf);
483 char *spr;
484@@ -213,11 +213,11 @@ get_field_special (struct string_buf *buf, long instr,
485 static unsigned long
486 read_insn_microblaze (bfd_vma memaddr,
487 struct disassemble_info *info,
488- const struct op_code_struct **opr)
489+ struct op_code_struct **opr)
490 {
491 unsigned char ibytes[4];
492 int status;
493- const struct op_code_struct *op;
494+ struct op_code_struct *op;
495 unsigned long inst;
496
497 status = info->read_memory_func (memaddr, ibytes, 4, info);
498@@ -253,7 +253,7 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
499 fprintf_ftype print_func = info->fprintf_func;
500 void *stream = info->stream;
501 unsigned long inst, prev_inst;
502- const struct op_code_struct *op, *pop;
503+ struct op_code_struct *op, *pop;
504 int immval = 0;
505 bool immfound = false;
506 static bfd_vma prev_insn_addr = -1; /* Init the prev insn addr. */
507@@ -497,7 +497,7 @@ get_insn_microblaze (long inst,
508 enum microblaze_instr_type *insn_type,
509 short *delay_slots)
510 {
511- const struct op_code_struct *op;
512+ struct op_code_struct *op;
513 *isunsignedimm = false;
514
515 /* Just a linear search of the table. */
516@@ -539,7 +539,7 @@ microblaze_get_target_address (long inst, bool immfound, int immval,
517 bool *targetvalid,
518 bool *unconditionalbranch)
519 {
520- const struct op_code_struct *op;
521+ struct op_code_struct *op;
522 long targetaddr = 0;
523
524 *unconditionalbranch = false;
525diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
526index e65f4b58233..4a415495113 100644
527--- a/opcodes/microblaze-opc.h
528+++ b/opcodes/microblaze-opc.h
529@@ -145,7 +145,7 @@
530
531 #define MAX_OPCODES 424
532
533-const struct op_code_struct
534+struct op_code_struct
535 {
536 const char * name;
537 short inst_type; /* Registers and immediate values involved. */
538--
5392.37.1 (Apple Git-137.1)
540