summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/binutils/binutils/0031-Patch-MicroBlaze-Invalid-data-offsets-pointer-after-.patch
blob: cb31c0d7fdf83a60ab245be83c00388c6d928ffa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
From 7bddfaf3ad574aa738ab903f63a345ebde134f9e Mon Sep 17 00:00:00 2001
From: Mahesh Bodapati <mbodapat@xilinx.com>
Date: Mon, 24 Jan 2022 16:04:07 +0530
Subject: [PATCH 31/34] [Patch,MicroBlaze] : Invalid data offsets (pointer)
 after relaxation. Proposed patch from community member (dednev@rambler.ru)
 against 2021.1 [CR-1115232]

---
 bfd/elf32-microblaze.c | 18 ++++++++++++++++++
 bfd/elf64-microblaze.c | 17 +++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index 88ac730582b..588367ebcbb 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -2095,6 +2095,9 @@ microblaze_elf_relax_section (bfd *abfd,
                 {
                   unsigned int val;
 
+	  	  if (ELF32_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+		    continue;
+
                   isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
 
                   /* hax: We only do the following fixup for debug location lists.  */
@@ -2136,6 +2139,9 @@ microblaze_elf_relax_section (bfd *abfd,
               }
               if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32)
                 {
+		  if (ELF32_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+		    continue;
+
 	          isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
 
                   /* Look at the reloc only if the value has been resolved.  */
@@ -2168,6 +2174,9 @@ microblaze_elf_relax_section (bfd *abfd,
 		    }
 		  else if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_SYM_OP_SYM)
 		    {
+		      if (ELF32_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+		        continue;
+
 		      isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
 
 		      /* Look at the reloc only if the value has been resolved.  */
@@ -2205,6 +2214,9 @@ microblaze_elf_relax_section (bfd *abfd,
 		       || (ELF32_R_TYPE (irelscan->r_info)
 				   == (int) R_MICROBLAZE_TEXTREL_32_LO))
 		{
+		  if (ELF32_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+		    continue;
+
 		  isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
 
 		  /* Look at the reloc only if the value has been resolved.  */
@@ -2251,6 +2263,9 @@ microblaze_elf_relax_section (bfd *abfd,
 		  || (ELF32_R_TYPE (irelscan->r_info)
 			      == (int) R_MICROBLAZE_TEXTREL_64))
 		{
+		  if (ELF32_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+		    continue;
+
 		  isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
 
 		  /* Look at the reloc only if the value has been resolved.  */
@@ -2285,6 +2300,9 @@ microblaze_elf_relax_section (bfd *abfd,
 		}
 	      else if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_PCREL)
 		{
+		  if (ELF32_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+		    continue;
+
 		  isym = isymbuf + ELF32_R_SYM (irelscan->r_info);
 
 		  /* Look at the reloc only if the value has been resolved.  */
diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
index 03fe9eba53a..76aec43ec7a 100644
--- a/bfd/elf64-microblaze.c
+++ b/bfd/elf64-microblaze.c
@@ -2132,6 +2132,8 @@ microblaze_elf_relax_section (bfd *abfd,
               if (1 && ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
                 {
                   unsigned int val;
+		  if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+		    continue;
 
                   isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
 
@@ -2174,6 +2176,9 @@ microblaze_elf_relax_section (bfd *abfd,
               if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32 
 		   || ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_IMML_64)
                 {
+		  if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+		    continue;
+
 	          isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
 
                   /* Look at the reloc only if the value has been resolved.  */
@@ -2206,6 +2211,9 @@ microblaze_elf_relax_section (bfd *abfd,
                     }
 		  else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_SYM_OP_SYM)
 		    {
+                      if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+                        continue;
+
 		      isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
 
 		      /* Look at the reloc only if the value has been resolved.  */
@@ -2243,6 +2251,9 @@ microblaze_elf_relax_section (bfd *abfd,
 		       || (ELF32_R_TYPE (irelscan->r_info)
 				   == (int) R_MICROBLAZE_TEXTREL_32_LO))
 		{
+                  if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+                    continue;
+
 		  isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
 
 		  /* Look at the reloc only if the value has been resolved.  */
@@ -2288,6 +2299,9 @@ microblaze_elf_relax_section (bfd *abfd,
 	      if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64
           || (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_TEXTREL_64))
 		{
+                  if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+                    continue;
+
 		  isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
 
 		  /* Look at the reloc only if the value has been resolved.  */
@@ -2336,6 +2350,9 @@ microblaze_elf_relax_section (bfd *abfd,
 		}
 	      else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_PCREL)
 		{
+                  if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
+                    continue;
+
 		  isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
 
 		  /* Look at the reloc only if the value has been resolved.  */
-- 
2.37.1 (Apple Git-137.1)