summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/binutils/binutils/0038-Invalid-data-offsets-pointer-after-relaxation.-Propo.patch
blob: a34478f20431ffb6cf0d151e1d95306ab47a250c (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
143
From 7eddc47ff5eecc2e383c96f4712185c42347105b Mon Sep 17 00:00:00 2001
From: Mahesh Bodapati <mbodapat@xilinx.com>
Date: Mon, 24 Jan 2022 16:04:07 +0530
Subject: [PATCH 38/38] Invalid data offsets (pointer) after relaxation.
 Proposed patch from community member (dednev@rambler.ru) against 2021.1
 [CR-1115232]

Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
---
 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 8b947a6ec79..0655d0fe975 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -2174,6 +2174,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.  */
@@ -2215,6 +2218,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.  */
@@ -2247,6 +2253,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.  */
@@ -2284,6 +2293,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.  */
@@ -2330,6 +2342,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.  */
@@ -2364,6 +2379,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 cecfb5506f8..c7bf5a71f08 100644
--- a/bfd/elf64-microblaze.c
+++ b/bfd/elf64-microblaze.c
@@ -2165,6 +2165,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);
 
@@ -2207,6 +2209,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.  */
@@ -2239,6 +2244,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.  */
@@ -2274,6 +2282,9 @@ microblaze_elf_relax_section (bfd *abfd,
 		       || (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_LO)
                || (ELF64_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.  */
@@ -2319,6 +2330,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.  */
@@ -2366,6 +2380,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.25.1