summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/gdb
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@amd.com>2022-11-04 15:08:58 -0500
committerMark Hatle <mark.hatle@amd.com>2022-11-08 12:53:00 -0600
commitb3bfe36ddeefad92655fc94055dacb3e098623cc (patch)
treed9fd3533036e6597a3a6f10e42423a46abcd77b2 /meta-microblaze/recipes-devtools/gdb
parent5a75cf75df6908101043a8c8aaf9c788c265429c (diff)
downloadmeta-xilinx-b3bfe36ddeefad92655fc94055dacb3e098623cc.tar.gz
gdb-microblaze: Update to new version of the port
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
Diffstat (limited to 'meta-microblaze/recipes-devtools/gdb')
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb-microblaze.inc25
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0001-Add-initial-port-of-linux-gdbserver.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0001-Patch-MicroBlaze.patch)690
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0002-Patch-MicroBlaze-Initial-port-of-core-reading-suppor.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0002-Initial-port-of-core-reading-support.patch)71
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0003-Fix-debug-message-when-register-is-unavailable.patch38
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0004-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0006-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch)61
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0004-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch32
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0005-Fixing-the-issues-related-to-GDB-7.12.patch201
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0005-Patch-microblaze-Adding-64-bit-MB-support.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-microblaze-Adding-64-bit-MB-support.patch)2295
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0006-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0008-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch)10
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0009-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch)79
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0008-Patch-MicroBlaze.patch (renamed from meta-microblaze/recipes-devtools/gdb/gdb/0011-Patch-Microblaze-Depth-Total-number.patch)26
-rw-r--r--meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Code-changes-for-gdbserver.patch401
12 files changed, 1738 insertions, 2191 deletions
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb-microblaze.inc b/meta-microblaze/recipes-devtools/gdb/gdb-microblaze.inc
index 9f86f19b..55f921f4 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb-microblaze.inc
+++ b/meta-microblaze/recipes-devtools/gdb/gdb-microblaze.inc
@@ -1,7 +1,7 @@
1# This does not currently work 1## This does not currently work
2python() { 2#python() {
3 raise bb.parse.SkipRecipe("GDB does not current support microblaze.") 3# raise bb.parse.SkipRecipe("GDB does not current support microblaze.")
4} 4#}
5 5
6# MicroBlaze does not support LTTng UST 6# MicroBlaze does not support LTTng UST
7LTTNGUST:microblaze = "" 7LTTNGUST:microblaze = ""
@@ -10,15 +10,12 @@ LTTNGUST:microblaze = ""
10FILESEXTRAPATHS:append := ":${THISDIR}/gdb" 10FILESEXTRAPATHS:append := ":${THISDIR}/gdb"
11 11
12SRC_URI:append:microblaze = " \ 12SRC_URI:append:microblaze = " \
13 file://0001-Patch-MicroBlaze.patch \ 13 file://0001-Add-initial-port-of-linux-gdbserver.patch \
14 file://0002-Initial-port-of-core-reading-support.patch \ 14 file://0002-Patch-MicroBlaze-Initial-port-of-core-reading-suppor.patch \
15 file://0003-Fix-debug-message-when-register-is-unavailable.patch \ 15 file://0003-Fix-debug-message-when-register-is-unavailable.patch \
16 file://0004-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch \ 16 file://0004-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch \
17 file://0005-Fixing-the-issues-related-to-GDB-7.12.patch \ 17 file://0005-Patch-microblaze-Adding-64-bit-MB-support.patch \
18 file://0006-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch \ 18 file://0006-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch \
19 file://0007-Patch-microblaze-Adding-64-bit-MB-support.patch \ 19 file://0007-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch \
20 file://0008-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch \ 20 file://0008-Patch-MicroBlaze.patch \
21 file://0009-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch \
22 file://0010-Patch-MicroBlaze-Code-changes-for-gdbserver.patch \
23 file://0011-Patch-Microblaze-Depth-Total-number.patch \
24 " 21 "
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0001-Patch-MicroBlaze.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0001-Add-initial-port-of-linux-gdbserver.patch
index b5a2726b..a5f3acd2 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0001-Patch-MicroBlaze.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0001-Add-initial-port-of-linux-gdbserver.patch
@@ -1,8 +1,8 @@
1From b7b3c1eb19b770b2d700dd3c9fa23a7ae225a72b Mon Sep 17 00:00:00 2001 1From baac387700a72407b3994bfd0a03825112c9745f Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 16 Jun 2022 09:50:14 +0530 3Date: Mon, 10 Oct 2022 15:07:22 +0530
4Subject: [PATCH 01/10] [Patch,MicroBlaze] : Add initial port of linux 4Subject: [PATCH 1/8] Add initial port of linux gdbserver add
5 gdbserver add gdb_proc_service_h to gdbserver microblaze-linux 5 gdb_proc_service_h to gdbserver microblaze-linux
6 6
7gdbserver needs to initialise the microblaze registers 7gdbserver needs to initialise the microblaze registers
8 8
@@ -19,51 +19,63 @@ architecture specific setup - may need to add in future
19 19
20Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com> 20Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
21Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com> 21Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
22 22Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
23Conflicts:
24 gdbserver/Makefile.in
25--- 23---
26 gdb/configure.host | 3 + 24 gdb/configure.host | 2 +
27 gdb/features/microblaze-linux.xml | 12 ++ 25 gdb/features/Makefile | 1 +
28 gdb/gdbserver/linux-microblaze-low.c | 189 +++++++++++++++++++++++++++ 26 gdb/features/microblaze-linux.xml | 13 ++
29 gdb/microblaze-linux-tdep.c | 29 +++- 27 gdb/microblaze-linux-tdep.c | 29 ++-
30 gdb/microblaze-tdep.c | 35 ++++- 28 gdb/microblaze-tdep.c | 35 +++-
31 gdb/microblaze-tdep.h | 4 +- 29 gdb/microblaze-tdep.h | 4 +-
32 gdb/regformats/reg-microblaze.dat | 41 ++++++ 30 gdb/regformats/microblaze-linux.dat | 64 +++++++
33 gdbserver/Makefile.in | 6 +- 31 gdb/regformats/reg-microblaze.dat | 41 +++++
34 gdbserver/configure.srv | 8 ++ 32 gdbserver/Makefile.in | 1 +
35 9 files changed, 323 insertions(+), 4 deletions(-) 33 gdbserver/configure.srv | 10 ++
34 gdbserver/linux-microblaze-low.cc | 269 ++++++++++++++++++++++++++++
35 11 files changed, 466 insertions(+), 3 deletions(-)
36 create mode 100644 gdb/features/microblaze-linux.xml 36 create mode 100644 gdb/features/microblaze-linux.xml
37 create mode 100644 gdb/gdbserver/linux-microblaze-low.c 37 create mode 100644 gdb/regformats/microblaze-linux.dat
38 create mode 100644 gdb/regformats/reg-microblaze.dat 38 create mode 100644 gdb/regformats/reg-microblaze.dat
39 create mode 100644 gdbserver/linux-microblaze-low.cc
39 40
40diff --git a/gdb/configure.host b/gdb/configure.host 41diff --git a/gdb/configure.host b/gdb/configure.host
41index ce528237291..cf1a08e8b28 100644 42index da71675b201..877537d06ef 100644
42--- a/gdb/configure.host 43--- a/gdb/configure.host
43+++ b/gdb/configure.host 44+++ b/gdb/configure.host
44@@ -65,6 +65,7 @@ hppa*) gdb_host_cpu=pa ;; 45@@ -61,6 +61,7 @@ i[34567]86*) gdb_host_cpu=i386 ;;
45 i[34567]86*) gdb_host_cpu=i386 ;; 46 loongarch*) gdb_host_cpu=loongarch ;;
46 m68*) gdb_host_cpu=m68k ;; 47 m68*) gdb_host_cpu=m68k ;;
47 mips*) gdb_host_cpu=mips ;; 48 mips*) gdb_host_cpu=mips ;;
48+microblaze*) gdb_host_cpu=microblaze ;; 49+microblaze*) gdb_host_cpu=microblaze ;;
49 powerpc* | rs6000) gdb_host_cpu=powerpc ;; 50 powerpc* | rs6000) gdb_host_cpu=powerpc ;;
50 sparcv9 | sparc64) gdb_host_cpu=sparc ;; 51 sparcv9 | sparc64) gdb_host_cpu=sparc ;;
51 s390*) gdb_host_cpu=s390 ;; 52 s390*) gdb_host_cpu=s390 ;;
52@@ -133,6 +134,8 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu) 53@@ -127,6 +128,7 @@ m68*-*-openbsd*) gdb_host=obsd ;;
53 mips*-*-freebsd*) gdb_host=fbsd ;;
54 mips64*-*-openbsd*) gdb_host=obsd64 ;;
55 54
56+microblaze*-*linux*) gdb_host=linux ;; 55 m88*-*-openbsd*) gdb_host=obsd ;;
57+ 56
58 powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*) 57+microblaze*-*linux*) gdb_host=linux ;;
59 gdb_host=aix ;; 58 mips*-*-linux*) gdb_host=linux ;;
60 powerpc*-*-freebsd*) gdb_host=fbsd ;; 59 mips*-*-netbsdaout* | mips*-*-knetbsd*-gnu)
60 gdb_host=nbsd ;;
61diff --git a/gdb/features/Makefile b/gdb/features/Makefile
62index 68e17d0085d..fc3196864c9 100644
63--- a/gdb/features/Makefile
64+++ b/gdb/features/Makefile
65@@ -46,6 +46,7 @@
66 # List of .dat files to create in ../regformats/
67 WHICH = mips-linux mips-dsp-linux \
68 mips64-linux mips64-dsp-linux \
69+ microblaze-linux \
70 nios2-linux \
71 or1k-linux \
72 rs6000/powerpc-32 \
61diff --git a/gdb/features/microblaze-linux.xml b/gdb/features/microblaze-linux.xml 73diff --git a/gdb/features/microblaze-linux.xml b/gdb/features/microblaze-linux.xml
62new file mode 100644 74new file mode 100644
63index 00000000000..8983e66eb3d 75index 00000000000..688a3f83d1e
64--- /dev/null 76--- /dev/null
65+++ b/gdb/features/microblaze-linux.xml 77+++ b/gdb/features/microblaze-linux.xml
66@@ -0,0 +1,12 @@ 78@@ -0,0 +1,13 @@
67+<?xml version="1.0"?> 79+<?xml version="1.0"?>
68+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc. 80+<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc.
69+ 81+
@@ -73,206 +85,12 @@ index 00000000000..8983e66eb3d
73+ 85+
74+<!DOCTYPE target SYSTEM "gdb-target.dtd"> 86+<!DOCTYPE target SYSTEM "gdb-target.dtd">
75+<target> 87+<target>
88+ <architecture>microblaze</architecture>
76+ <osabi>GNU/Linux</osabi> 89+ <osabi>GNU/Linux</osabi>
77+ <xi:include href="microblaze-core.xml"/> 90+ <xi:include href="microblaze-core.xml"/>
78+</target> 91+</target>
79diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdb/gdbserver/linux-microblaze-low.c
80new file mode 100644
81index 00000000000..cba5d6fc585
82--- /dev/null
83+++ b/gdb/gdbserver/linux-microblaze-low.c
84@@ -0,0 +1,189 @@
85+/* GNU/Linux/Microblaze specific low level interface, for the remote server for
86+ GDB.
87+ Copyright (C) 1995-2013 Free Software Foundation, Inc.
88+
89+ This file is part of GDB.
90+
91+ This program is free software; you can redistribute it and/or modify
92+ it under the terms of the GNU General Public License as published by
93+ the Free Software Foundation; either version 3 of the License, or
94+ (at your option) any later version.
95+
96+ This program is distributed in the hope that it will be useful,
97+ but WITHOUT ANY WARRANTY; without even the implied warranty of
98+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
99+ GNU General Public License for more details.
100+
101+ You should have received a copy of the GNU General Public License
102+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
103+
104+#include "server.h"
105+#include "linux-low.h"
106+
107+#include <asm/ptrace.h>
108+#include <sys/procfs.h>
109+#include <sys/ptrace.h>
110+
111+#include "gdb_proc_service.h"
112+
113+static int microblaze_regmap[] =
114+ {PT_GPR(0), PT_GPR(1), PT_GPR(2), PT_GPR(3),
115+ PT_GPR(4), PT_GPR(5), PT_GPR(6), PT_GPR(7),
116+ PT_GPR(8), PT_GPR(9), PT_GPR(10), PT_GPR(11),
117+ PT_GPR(12), PT_GPR(13), PT_GPR(14), PT_GPR(15),
118+ PT_GPR(16), PT_GPR(17), PT_GPR(18), PT_GPR(19),
119+ PT_GPR(20), PT_GPR(21), PT_GPR(22), PT_GPR(23),
120+ PT_GPR(24), PT_GPR(25), PT_GPR(26), PT_GPR(27),
121+ PT_GPR(28), PT_GPR(29), PT_GPR(30), PT_GPR(31),
122+ PT_PC, PT_MSR, PT_EAR, PT_ESR,
123+ PT_FSR
124+ };
125+
126+#define microblaze_num_regs (sizeof microblaze_regmap / sizeof microblaze_regmap[0])
127+
128+/* Defined in auto-generated file microblaze-linux.c. */
129+void init_registers_microblaze (void);
130+
131+static int
132+microblaze_cannot_store_register (int regno)
133+{
134+ if (microblaze_regmap[regno] == -1 || regno == 0)
135+ return 1;
136+
137+ return 0;
138+}
139+
140+static int
141+microblaze_cannot_fetch_register (int regno)
142+{
143+ return 0;
144+}
145+
146+static CORE_ADDR
147+microblaze_get_pc (struct regcache *regcache)
148+{
149+ unsigned long pc;
150+
151+ collect_register_by_name (regcache, "pc", &pc);
152+ return (CORE_ADDR) pc;
153+}
154+
155+static void
156+microblaze_set_pc (struct regcache *regcache, CORE_ADDR pc)
157+{
158+ unsigned long newpc = pc;
159+
160+ supply_register_by_name (regcache, "pc", &newpc);
161+}
162+
163+/* dbtrap insn */
164+/* brki r16, 0x18; */
165+static const unsigned long microblaze_breakpoint = 0xba0c0018;
166+#define microblaze_breakpoint_len 4
167+
168+static int
169+microblaze_breakpoint_at (CORE_ADDR where)
170+{
171+ unsigned long insn;
172+
173+ (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
174+ if (insn == microblaze_breakpoint)
175+ return 1;
176+ /* If necessary, recognize more trap instructions here. GDB only uses the
177+ one. */
178+ return 0;
179+}
180+
181+static CORE_ADDR
182+microblaze_reinsert_addr (struct regcache *regcache)
183+{
184+ unsigned long pc;
185+ collect_register_by_name (regcache, "r15", &pc);
186+ return pc;
187+}
188+
189+#ifdef HAVE_PTRACE_GETREGS
190+
191+static void
192+microblaze_collect_ptrace_register (struct regcache *regcache, int regno, char *buf)
193+{
194+ int size = register_size (regno);
195+
196+ memset (buf, 0, sizeof (long));
197+
198+ if (size < sizeof (long))
199+ collect_register (regcache, regno, buf + sizeof (long) - size);
200+ else
201+ collect_register (regcache, regno, buf);
202+}
203+
204+static void
205+microblaze_supply_ptrace_register (struct regcache *regcache,
206+ int regno, const char *buf)
207+{
208+ int size = register_size (regno);
209+
210+ if (regno == 0) {
211+ unsigned long regbuf_0 = 0;
212+ /* clobbering r0 so that it is always 0 as enforced by hardware */
213+ supply_register (regcache, regno, (const char*)&regbuf_0);
214+ } else {
215+ if (size < sizeof (long))
216+ supply_register (regcache, regno, buf + sizeof (long) - size);
217+ else
218+ supply_register (regcache, regno, buf);
219+ }
220+}
221+
222+/* Provide only a fill function for the general register set. ps_lgetregs
223+ will use this for NPTL support. */
224+
225+static void microblaze_fill_gregset (struct regcache *regcache, void *buf)
226+{
227+ int i;
228+
229+ for (i = 0; i < 32; i++)
230+ microblaze_collect_ptrace_register (regcache, i, (char *) buf + microblaze_regmap[i]);
231+}
232+
233+static void
234+microblaze_store_gregset (struct regcache *regcache, const void *buf)
235+{
236+ int i;
237+
238+ for (i = 0; i < 32; i++)
239+ supply_register (regcache, i, (char *) buf + microblaze_regmap[i]);
240+}
241+
242+#endif /* HAVE_PTRACE_GETREGS */
243+
244+struct regset_info target_regsets[] = {
245+#ifdef HAVE_PTRACE_GETREGS
246+ { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset },
247+ { 0, 0, 0, -1, -1, NULL, NULL },
248+#endif /* HAVE_PTRACE_GETREGS */
249+ { 0, 0, 0, -1, -1, NULL, NULL }
250+};
251+
252+struct linux_target_ops the_low_target = {
253+ init_registers_microblaze,
254+ microblaze_num_regs,
255+ microblaze_regmap,
256+ NULL,
257+ microblaze_cannot_fetch_register,
258+ microblaze_cannot_store_register,
259+ NULL, /* fetch_register */
260+ microblaze_get_pc,
261+ microblaze_set_pc,
262+ (const unsigned char *) &microblaze_breakpoint,
263+ microblaze_breakpoint_len,
264+ microblaze_reinsert_addr,
265+ 0,
266+ microblaze_breakpoint_at,
267+ NULL,
268+ NULL,
269+ NULL,
270+ NULL,
271+ microblaze_collect_ptrace_register,
272+ microblaze_supply_ptrace_register,
273+};
274diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c 92diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
275index 3fc5e768120..0322b4ea813 100644 93index daa7ddf7e4d..5748556a556 100644
276--- a/gdb/microblaze-linux-tdep.c 94--- a/gdb/microblaze-linux-tdep.c
277+++ b/gdb/microblaze-linux-tdep.c 95+++ b/gdb/microblaze-linux-tdep.c
278@@ -37,6 +37,22 @@ 96@@ -37,6 +37,22 @@
@@ -332,10 +150,10 @@ index 3fc5e768120..0322b4ea813 100644
332 150
333 void _initialize_microblaze_linux_tdep (); 151 void _initialize_microblaze_linux_tdep ();
334diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c 152diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
335index c263228856f..28c2ed9a74c 100644 153index 3d5dd669341..3e8e8fe35b9 100644
336--- a/gdb/microblaze-tdep.c 154--- a/gdb/microblaze-tdep.c
337+++ b/gdb/microblaze-tdep.c 155+++ b/gdb/microblaze-tdep.c
338@@ -137,7 +137,38 @@ microblaze_fetch_instruction (CORE_ADDR pc) 156@@ -128,7 +128,38 @@ microblaze_fetch_instruction (CORE_ADDR pc)
339 constexpr gdb_byte microblaze_break_insn[] = MICROBLAZE_BREAKPOINT; 157 constexpr gdb_byte microblaze_break_insn[] = MICROBLAZE_BREAKPOINT;
340 158
341 typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint; 159 typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint;
@@ -375,7 +193,7 @@ index c263228856f..28c2ed9a74c 100644
375 193
376 /* Allocate and initialize a frame cache. */ 194 /* Allocate and initialize a frame cache. */
377 195
378@@ -731,6 +762,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 196@@ -716,6 +747,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
379 microblaze_breakpoint::kind_from_pc); 197 microblaze_breakpoint::kind_from_pc);
380 set_gdbarch_sw_breakpoint_from_kind (gdbarch, 198 set_gdbarch_sw_breakpoint_from_kind (gdbarch,
381 microblaze_breakpoint::bp_from_kind); 199 microblaze_breakpoint::bp_from_kind);
@@ -383,17 +201,17 @@ index c263228856f..28c2ed9a74c 100644
383 201
384 set_gdbarch_frame_args_skip (gdbarch, 8); 202 set_gdbarch_frame_args_skip (gdbarch, 8);
385 203
386@@ -771,4 +803,5 @@ When non-zero, microblaze specific debugging is enabled."), 204@@ -756,4 +788,5 @@ When non-zero, microblaze specific debugging is enabled."),
387 NULL, 205 NULL,
388 &setdebuglist, &showdebuglist); 206 &setdebuglist, &showdebuglist);
389 207
390+ 208+
391 } 209 }
392diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h 210diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
393index 08af0d191c5..8a429cbf001 100644 211index 4d90e8785dc..53fcb2297e6 100644
394--- a/gdb/microblaze-tdep.h 212--- a/gdb/microblaze-tdep.h
395+++ b/gdb/microblaze-tdep.h 213+++ b/gdb/microblaze-tdep.h
396@@ -117,6 +117,8 @@ struct microblaze_frame_cache 214@@ -118,6 +118,8 @@ struct microblaze_frame_cache
397 215
398 /* MICROBLAZE_BREAKPOINT defines the breakpoint that should be used. 216 /* MICROBLAZE_BREAKPOINT defines the breakpoint that should be used.
399 Only used for native debugging. */ 217 Only used for native debugging. */
@@ -403,6 +221,76 @@ index 08af0d191c5..8a429cbf001 100644
403+ 221+
404 222
405 #endif /* microblaze-tdep.h */ 223 #endif /* microblaze-tdep.h */
224diff --git a/gdb/regformats/microblaze-linux.dat b/gdb/regformats/microblaze-linux.dat
225new file mode 100644
226index 00000000000..b5b49f485cd
227--- /dev/null
228+++ b/gdb/regformats/microblaze-linux.dat
229@@ -0,0 +1,64 @@
230+# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro:
231+# Generated from: microblaze-linux.xml
232+name:microblaze_linux
233+xmltarget:microblaze-linux.xml
234+expedite:r1,rpc
235+32:r0
236+32:r1
237+32:r2
238+32:r3
239+32:r4
240+32:r5
241+32:r6
242+32:r7
243+32:r8
244+32:r9
245+32:r10
246+32:r11
247+32:r12
248+32:r13
249+32:r14
250+32:r15
251+32:r16
252+32:r17
253+32:r18
254+32:r19
255+32:r20
256+32:r21
257+32:r22
258+32:r23
259+32:r24
260+32:r25
261+32:r26
262+32:r27
263+32:r28
264+32:r29
265+32:r30
266+32:r31
267+32:rpc
268+32:rmsr
269+32:rear
270+32:resr
271+32:rfsr
272+32:rbtr
273+32:rpvr0
274+32:rpvr1
275+32:rpvr2
276+32:rpvr3
277+32:rpvr4
278+32:rpvr5
279+32:rpvr6
280+32:rpvr7
281+32:rpvr8
282+32:rpvr9
283+32:rpvr10
284+32:rpvr11
285+32:redr
286+32:rpid
287+32:rzpr
288+32:rtlbx
289+32:rtlbsx
290+32:rtlblo
291+32:rtlbhi
292+32:slr
293+32:shr
406diff --git a/gdb/regformats/reg-microblaze.dat b/gdb/regformats/reg-microblaze.dat 294diff --git a/gdb/regformats/reg-microblaze.dat b/gdb/regformats/reg-microblaze.dat
407new file mode 100644 295new file mode 100644
408index 00000000000..bd8a4384424 296index 00000000000..bd8a4384424
@@ -451,55 +339,313 @@ index 00000000000..bd8a4384424
451+32:slr 339+32:slr
452+32:shr 340+32:shr
453diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in 341diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
454index 2bd3a578932..46b5a0c7c60 100644 342index 47648b8d962..55a5f5b81ae 100644
455--- a/gdbserver/Makefile.in 343--- a/gdbserver/Makefile.in
456+++ b/gdbserver/Makefile.in 344+++ b/gdbserver/Makefile.in
457@@ -184,7 +184,8 @@ SFILES = \ 345@@ -178,6 +178,7 @@ SFILES = \
458 $(srcdir)/linux-ia64-low.cc \ 346 $(srcdir)/linux-ia64-low.cc \
459 $(srcdir)/linux-low.cc \ 347 $(srcdir)/linux-low.cc \
460 $(srcdir)/linux-m68k-low.cc \ 348 $(srcdir)/linux-m68k-low.cc \
461- $(srcdir)/linux-mips-low.cc \ 349+ $(srcdir)/linux-microblaze-low.cc \
462+ $(srcdir)/linux-microblaze-low.c \ 350 $(srcdir)/linux-mips-low.cc \
463+ $(srcdir)/linux-mips-low.cc \
464 $(srcdir)/linux-nios2-low.cc \ 351 $(srcdir)/linux-nios2-low.cc \
465 $(srcdir)/linux-ppc-low.cc \ 352 $(srcdir)/linux-or1k-low.cc \
466 $(srcdir)/linux-riscv-low.cc \
467@@ -221,6 +222,7 @@ SFILES = \
468 $(srcdir)/../gdb/nat/linux-namespaces.c \
469 $(srcdir)/../gdb/nat/linux-osdata.c \
470 $(srcdir)/../gdb/nat/linux-personality.c \
471+ $(srcdir)/../gdb/nat/microblaze-linux.c \
472 $(srcdir)/../gdb/nat/mips-linux-watch.c \
473 $(srcdir)/../gdb/nat/ppc-linux.c \
474 $(srcdir)/../gdb/nat/riscv-linux-tdesc.c \
475@@ -562,6 +564,8 @@ target/%.o: ../gdb/target/%.c
476
477 %-generated.cc: ../gdb/regformats/rs6000/%.dat $(regdat_sh)
478 $(ECHO_REGDAT) $(SHELL) $(regdat_sh) $< $@
479+microblaze-linux.c : $(srcdir)/../regformats/reg-microblaze.dat $(regdat_sh)
480+ $(ECHO_REGDAT) $(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-microblaze.dat microblaze-linux.c
481
482 #
483 # Dependency tracking.
484diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv 353diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
485index 0cb5072c8ab..9d68c24a92d 100644 354index 6e09b0eeb79..1817f1f04fb 100644
486--- a/gdbserver/configure.srv 355--- a/gdbserver/configure.srv
487+++ b/gdbserver/configure.srv 356+++ b/gdbserver/configure.srv
488@@ -166,6 +166,14 @@ case "${gdbserver_host}" in 357@@ -145,6 +145,16 @@ case "${gdbserver_host}" in
489 srv_linux_usrregs=yes 358 srv_linux_regsets=yes
490 srv_linux_thread_db=yes 359 srv_linux_thread_db=yes
491 ;; 360 ;;
492+ microblaze*-*-linux*) srv_regobj="microblaze-linux.o" 361+
493+ srv_tgtobj="linux-low.o linux-osdata.o linux-microblaze-low.o " 362+microblaze*-*-linux*) srv_regobj="microblaze-linux.o"
494+ srv_tgtobj="${srv_tgtobj} linux-procfs.o linux-ptrace.o" 363+ srv_tgtobj="$srv_linux_obj linux-microblaze-low.o"
495+ srv_xmlfiles="microblaze-linux.xml" 364+ srv_xmlfiles="microblaze-linux.xml"
496+ srv_linux_regsets=yes 365+ srv_xmlfiles="${srv_xmlfiles} microblaze-core.xml"
497+ srv_linux_usrregs=yes 366+ srv_linux_usrregs=yes
498+ srv_linux_thread_db=yes 367+ srv_linux_regsets=yes
499+ ;; 368+ srv_linux_thread_db=yes
500 powerpc*-*-linux*) srv_regobj="powerpc-32l.o" 369+ ;;
501 srv_regobj="${srv_regobj} powerpc-altivec32l.o" 370+
502 srv_regobj="${srv_regobj} powerpc-vsx32l.o" 371 mips*-*-linux*) srv_regobj="mips-linux.o"
372 srv_regobj="${srv_regobj} mips-dsp-linux.o"
373 srv_regobj="${srv_regobj} mips64-linux.o"
374diff --git a/gdbserver/linux-microblaze-low.cc b/gdbserver/linux-microblaze-low.cc
375new file mode 100644
376index 00000000000..bf9eecc41ab
377--- /dev/null
378+++ b/gdbserver/linux-microblaze-low.cc
379@@ -0,0 +1,269 @@
380+/* GNU/Linux/Microblaze specific low level interface, for the remote server for
381+ GDB.
382+ Copyright (C) 1995-2013 Free Software Foundation, Inc.
383+
384+ This file is part of GDB.
385+
386+ This program is free software; you can redistribute it and/or modify
387+ it under the terms of the GNU General Public License as published by
388+ the Free Software Foundation; either version 3 of the License, or
389+ (at your option) any later version.
390+
391+ This program is distributed in the hope that it will be useful,
392+ but WITHOUT ANY WARRANTY; without even the implied warranty of
393+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
394+ GNU General Public License for more details.
395+
396+ You should have received a copy of the GNU General Public License
397+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
398+
399+#include "server.h"
400+#include "linux-low.h"
401+
402+#include "elf/common.h"
403+#include "nat/gdb_ptrace.h"
404+#include <endian.h>
405+
406+#include <asm/ptrace.h>
407+#include <sys/procfs.h>
408+#include <sys/ptrace.h>
409+
410+#include "gdb_proc_service.h"
411+
412+
413+static int microblaze_regmap[] =
414+ {PT_GPR(0), PT_GPR(1), PT_GPR(2), PT_GPR(3),
415+ PT_GPR(4), PT_GPR(5), PT_GPR(6), PT_GPR(7),
416+ PT_GPR(8), PT_GPR(9), PT_GPR(10), PT_GPR(11),
417+ PT_GPR(12), PT_GPR(13), PT_GPR(14), PT_GPR(15),
418+ PT_GPR(16), PT_GPR(17), PT_GPR(18), PT_GPR(19),
419+ PT_GPR(20), PT_GPR(21), PT_GPR(22), PT_GPR(23),
420+ PT_GPR(24), PT_GPR(25), PT_GPR(26), PT_GPR(27),
421+ PT_GPR(28), PT_GPR(29), PT_GPR(30), PT_GPR(31),
422+ PT_PC, PT_MSR, PT_EAR, PT_ESR,
423+ PT_FSR
424+ };
425+
426+
427+
428+class microblaze_target : public linux_process_target
429+{
430+public:
431+
432+ const regs_info *get_regs_info () override;
433+
434+ const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
435+ // CORE_ADDR microblaze_reinsert_addr (regcache *regcache);
436+
437+protected:
438+
439+ void low_arch_setup () override;
440+
441+ bool low_cannot_fetch_register (int regno) override;
442+
443+ bool low_cannot_store_register (int regno) override;
444+
445+ // bool low_supports_breakpoints () override;
446+
447+ CORE_ADDR low_get_pc (regcache *regcache) override;
448+
449+ void low_set_pc (regcache *regcache, CORE_ADDR newpc) override;
450+
451+ bool low_breakpoint_at (CORE_ADDR pc) override;
452+};
453+
454+/* The singleton target ops object. */
455+
456+static microblaze_target the_microblaze_target;
457+
458+#define microblaze_num_regs (sizeof (microblaze_regmap) / sizeof (microblaze_regmap[0]))
459+
460+/* Defined in auto-generated file microblaze-linux.c. */
461+void init_registers_microblaze_linux (void);
462+extern const struct target_desc *tdesc_microblaze_linux;
463+
464+bool
465+microblaze_target::low_cannot_store_register (int regno)
466+{
467+ if (microblaze_regmap[regno] == -1 || regno == 0)
468+ return 1;
469+
470+ return 0;
471+}
472+
473+bool
474+microblaze_target::low_cannot_fetch_register (int regno)
475+{
476+ return 0;
477+}
478+
479+CORE_ADDR
480+microblaze_target::low_get_pc (struct regcache *regcache)
481+{
482+ unsigned long pc;
483+
484+ collect_register_by_name (regcache, "pc", &pc);
485+ return (CORE_ADDR) pc;
486+}
487+
488+void
489+microblaze_target::low_set_pc (struct regcache *regcache, CORE_ADDR pc)
490+{
491+ unsigned long newpc = pc;
492+
493+ supply_register_by_name (regcache, "pc", &newpc);
494+}
495+
496+/* dbtrap insn */
497+/* brki r16, 0x18; */
498+static const unsigned long microblaze_breakpoint = 0xba0c0018;
499+#define microblaze_breakpoint_len 4
500+
501+/* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
502+
503+const gdb_byte *
504+microblaze_target::sw_breakpoint_from_kind (int kind, int *size)
505+{
506+ *size = microblaze_breakpoint_len;
507+ return (const gdb_byte *) &microblaze_breakpoint;
508+}
509+
510+bool
511+microblaze_target::low_breakpoint_at (CORE_ADDR where)
512+{
513+ unsigned long insn;
514+
515+ read_memory (where, (unsigned char *) &insn, 4);
516+ if (insn == microblaze_breakpoint)
517+ return 1;
518+ /* If necessary, recognize more trap instructions here. GDB only uses the
519+ one. */
520+ return 0;
521+}
522+#if 0
523+CORE_ADDR
524+microblaze_target::microblaze_reinsert_addr (struct regcache *regcache)
525+{
526+ unsigned long pc;
527+ collect_register_by_name (regcache, "r15", &pc);
528+ return pc;
529+}
530+#endif
531+#if 0
532+#ifdef HAVE_PTRACE_GETREGS
533+
534+static void
535+microblaze_collect_ptrace_register (struct regcache *regcache, int regno, char *buf)
536+{
537+ int size = register_size (regcache->tdesc, regno);
538+
539+ memset (buf, 0, sizeof (long));
540+
541+ if (size < sizeof (long))
542+ collect_register (regcache, regno, buf + sizeof (long) - size);
543+ else
544+ collect_register (regcache, regno, buf);
545+}
546+
547+static void
548+microblaze_supply_ptrace_register (struct regcache *regcache,
549+ int regno, const char *buf)
550+{
551+ int size = register_size (regcache->tdesc, regno);
552+
553+ if (regno == 0) {
554+ unsigned long regbuf_0 = 0;
555+ /* clobbering r0 so that it is always 0 as enforced by hardware */
556+ supply_register (regcache, regno, (const char*)&regbuf_0);
557+ } else {
558+ if (size < sizeof (long))
559+ supply_register (regcache, regno, buf + sizeof (long) - size);
560+ else
561+ supply_register (regcache, regno, buf);
562+ }
563+}
564+
565+/* Provide only a fill function for the general register set. ps_lgetregs
566+ will use this for NPTL support. */
567+
568+static void microblaze_fill_gregset (struct regcache *regcache, void *buf)
569+{
570+ int i;
571+
572+ for (i = 0; i < 32; i++)
573+ microblaze_collect_ptrace_register (regcache, i, (char *) buf + microblaze_regmap[i]);
574+}
575+
576+static void
577+microblaze_store_gregset (struct regcache *regcache, const void *buf)
578+{
579+ int i;
580+
581+ for (i = 0; i < 32; i++)
582+ supply_register (regcache, i, (char *) buf + microblaze_regmap[i]);
583+}
584+
585+#endif /* HAVE_PTRACE_GETREGS */
586+#endif
587+
588+static struct regset_info microblaze_regsets[] = {
589+#if 0
590+#ifdef HAVE_PTRACE_GETREGS
591+ { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset },
592+ { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
593+#endif /* HAVE_PTRACE_GETREGS */
594+#endif
595+ { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
596+ NULL_REGSET
597+};
598+
599+static struct usrregs_info microblaze_usrregs_info =
600+ {
601+ microblaze_num_regs,
602+ microblaze_regmap,
603+ };
604+
605+static struct regsets_info microblaze_regsets_info =
606+ {
607+ microblaze_regsets, /* regsets */
608+ 0, /* num_regsets */
609+ NULL, /* disabled_regsets */
610+ };
611+
612+static struct regs_info microblaze_regs_info =
613+ {
614+ NULL, /* regset_bitmap */
615+ &microblaze_usrregs_info,
616+ &microblaze_regsets_info
617+ };
618+
619+const regs_info *
620+microblaze_target::get_regs_info (void)
621+{
622+ return &microblaze_regs_info;
623+}
624+
625+/* Support for hardware single step. */
626+
627+static int
628+microblaze_supports_hardware_single_step (void)
629+{
630+ return 1;
631+}
632+
633+
634+void
635+microblaze_target::low_arch_setup (void)
636+{
637+ current_process ()->tdesc = tdesc_microblaze_linux;
638+}
639+
640+linux_process_target *the_linux_target = &the_microblaze_target;
641+
642+void
643+initialize_low_arch (void)
644+{
645+ init_registers_microblaze_linux ();
646+ initialize_regsets_info (&microblaze_regsets_info);
647+}
648+
503-- 649--
5042.17.1 6502.37.1 (Apple Git-137.1)
505 651
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0002-Initial-port-of-core-reading-support.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0002-Patch-MicroBlaze-Initial-port-of-core-reading-suppor.patch
index 352ed92e..a871b582 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0002-Initial-port-of-core-reading-support.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0002-Patch-MicroBlaze-Initial-port-of-core-reading-suppor.patch
@@ -1,30 +1,32 @@
1From da36639f95d23083088a27c27f631d304ae316f1 Mon Sep 17 00:00:00 2001 1From 7da397cae8c0f8826184d6e12fda9ccd11f92753 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 24 Jan 2017 14:55:56 +0530 3Date: Mon, 10 Oct 2022 16:37:53 +0530
4Subject: [PATCH 02/10] Initial port of core reading support Added support for 4Subject: [PATCH 2/8] [Patch,MicroBlaze]: Initial port of core reading support
5 reading notes in linux core dumps Support for reading of PRSTATUS and PSINFO 5 Added support for reading notes in linux core dumps Support for reading of
6 information for rebuilding ".reg" sections of core dumps at run time. 6 PRSTATUS and PSINFO information for rebuilding ".reg" sections of core dumps
7 at run time.
7 8
8Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com> 9Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
9Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com> 10Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
11Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
10--- 12---
11 bfd/elf32-microblaze.c | 84 +++++++++++++++++++++++++++++++++++++ 13 bfd/elf32-microblaze.c | 84 +++++++++++++++++++++++++++++++++++++
12 gdb/configure.tgt | 2 +- 14 gdb/configure.tgt | 2 +-
13 gdb/microblaze-linux-tdep.c | 17 +++++++- 15 gdb/microblaze-linux-tdep.c | 17 +++++++-
14 gdb/microblaze-tdep.c | 48 +++++++++++++++++++++ 16 gdb/microblaze-tdep.c | 48 +++++++++++++++++++++
15 gdb/microblaze-tdep.h | 27 ++++++++++++ 17 gdb/microblaze-tdep.h | 28 +++++++++++++
16 5 files changed, 176 insertions(+), 2 deletions(-) 18 5 files changed, 177 insertions(+), 2 deletions(-)
17 19
18diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c 20diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
19index 1b5c2efcd6e..cfd70ae9178 100644 21index d09b3f7095d..d3b3c66cf00 100644
20--- a/bfd/elf32-microblaze.c 22--- a/bfd/elf32-microblaze.c
21+++ b/bfd/elf32-microblaze.c 23+++ b/bfd/elf32-microblaze.c
22@@ -715,6 +715,87 @@ microblaze_elf_is_local_label_name (bfd *abfd, const char *name) 24@@ -713,6 +713,87 @@ microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
23 return _bfd_elf_is_local_label_name (abfd, name); 25 return _bfd_elf_is_local_label_name (abfd, name);
24 } 26 }
25 27
26+/* Support for core dump NOTE sections. */ 28+/* Support for core dump NOTE sections. */
27+static bfd_boolean 29+static bool
28+microblaze_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) 30+microblaze_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
29+{ 31+{
30+ int offset; 32+ int offset;
@@ -33,7 +35,7 @@ index 1b5c2efcd6e..cfd70ae9178 100644
33+ switch (note->descsz) 35+ switch (note->descsz)
34+ { 36+ {
35+ default: 37+ default:
36+ return FALSE; 38+ return false;
37+ 39+
38+ case 228: /* Linux/MicroBlaze */ 40+ case 228: /* Linux/MicroBlaze */
39+ /* pr_cursig */ 41+ /* pr_cursig */
@@ -54,13 +56,13 @@ index 1b5c2efcd6e..cfd70ae9178 100644
54+ size, note->descpos + offset); 56+ size, note->descpos + offset);
55+} 57+}
56+ 58+
57+static bfd_boolean 59+static bool
58+microblaze_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) 60+microblaze_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
59+{ 61+{
60+ switch (note->descsz) 62+ switch (note->descsz)
61+ { 63+ {
62+ default: 64+ default:
63+ return FALSE; 65+ return false;
64+ 66+
65+ case 128: /* Linux/MicroBlaze elf_prpsinfo */ 67+ case 128: /* Linux/MicroBlaze elf_prpsinfo */
66+ elf_tdata (abfd)->core->program 68+ elf_tdata (abfd)->core->program
@@ -81,7 +83,7 @@ index 1b5c2efcd6e..cfd70ae9178 100644
81+ command[n - 1] = '\0'; 83+ command[n - 1] = '\0';
82+ } 84+ }
83+ 85+
84+ return TRUE; 86+ return true;
85+} 87+}
86+ 88+
87+/* The microblaze linker (like many others) needs to keep track of 89+/* The microblaze linker (like many others) needs to keep track of
@@ -107,7 +109,7 @@ index 1b5c2efcd6e..cfd70ae9178 100644
107 /* ELF linker hash entry. */ 109 /* ELF linker hash entry. */
108 110
109 struct elf32_mb_link_hash_entry 111 struct elf32_mb_link_hash_entry
110@@ -3450,4 +3531,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd, 112@@ -3434,4 +3515,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
111 #define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections 113 #define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
112 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook 114 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
113 115
@@ -116,7 +118,7 @@ index 1b5c2efcd6e..cfd70ae9178 100644
116+ 118+
117 #include "elf32-target.h" 119 #include "elf32-target.h"
118diff --git a/gdb/configure.tgt b/gdb/configure.tgt 120diff --git a/gdb/configure.tgt b/gdb/configure.tgt
119index a3e11c4b9b8..b8378440b23 100644 121index 0705ccf32b8..7ea186481f3 100644
120--- a/gdb/configure.tgt 122--- a/gdb/configure.tgt
121+++ b/gdb/configure.tgt 123+++ b/gdb/configure.tgt
122@@ -400,7 +400,7 @@ mep-*-*) 124@@ -400,7 +400,7 @@ mep-*-*)
@@ -126,10 +128,10 @@ index a3e11c4b9b8..b8378440b23 100644
126- gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o solib-svr4.o \ 128- gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o solib-svr4.o \
127+ gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o solib-svr4.o glibc-tdep.o \ 129+ gdb_target_obs="microblaze-tdep.o microblaze-linux-tdep.o solib-svr4.o glibc-tdep.o \
128 symfile-mem.o linux-tdep.o" 130 symfile-mem.o linux-tdep.o"
129 gdb_sim=../sim/microblaze/libsim.a
130 ;; 131 ;;
132 microblaze*-*-*)
131diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c 133diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
132index 0322b4ea813..b8277dfd735 100644 134index 5748556a556..d6197c49dfd 100644
133--- a/gdb/microblaze-linux-tdep.c 135--- a/gdb/microblaze-linux-tdep.c
134+++ b/gdb/microblaze-linux-tdep.c 136+++ b/gdb/microblaze-linux-tdep.c
135@@ -36,6 +36,7 @@ 137@@ -36,6 +36,7 @@
@@ -149,11 +151,11 @@ index 0322b4ea813..b8277dfd735 100644
149 microblaze_linux_init_abi (struct gdbarch_info info, 151 microblaze_linux_init_abi (struct gdbarch_info info,
150 struct gdbarch *gdbarch) 152 struct gdbarch *gdbarch)
151 { 153 {
152+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); 154+ struct microblaze_gdbarch_tdep *tdep =(microblaze_gdbarch_tdep *) gdbarch_tdep (gdbarch);
153+ 155+
154+ tdep->sizeof_gregset = 200; 156+ tdep->sizeof_gregset = 200;
155+ 157+
156 linux_init_abi (info, gdbarch); 158 linux_init_abi (info, gdbarch, 0);
157 159
158 set_gdbarch_memory_remove_breakpoint (gdbarch, 160 set_gdbarch_memory_remove_breakpoint (gdbarch,
159@@ -153,6 +157,17 @@ microblaze_linux_init_abi (struct gdbarch_info info, 161@@ -153,6 +157,17 @@ microblaze_linux_init_abi (struct gdbarch_info info,
@@ -175,11 +177,11 @@ index 0322b4ea813..b8277dfd735 100644
175 set_gdbarch_fetch_tls_load_module_address (gdbarch, 177 set_gdbarch_fetch_tls_load_module_address (gdbarch,
176 svr4_fetch_objfile_link_map); 178 svr4_fetch_objfile_link_map);
177diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c 179diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
178index 28c2ed9a74c..399fa0e3dca 100644 180index 3e8e8fe35b9..ccd37d085d6 100644
179--- a/gdb/microblaze-tdep.c 181--- a/gdb/microblaze-tdep.c
180+++ b/gdb/microblaze-tdep.c 182+++ b/gdb/microblaze-tdep.c
181@@ -677,6 +677,43 @@ microblaze_register_g_packet_guesses (struct gdbarch *gdbarch) 183@@ -666,6 +666,43 @@ microblaze_register_g_packet_guesses (struct gdbarch *gdbarch)
182 tdesc_microblaze_with_stack_protect); 184 tdesc_microblaze_with_stack_protect);
183 } 185 }
184 186
185+void 187+void
@@ -210,7 +212,7 @@ index 28c2ed9a74c..399fa0e3dca 100644
210+ void *cb_data, 212+ void *cb_data,
211+ const struct regcache *regcache) 213+ const struct regcache *regcache)
212+{ 214+{
213+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); 215+ struct microblaze_gdbarch_tdep *tdep =(microblaze_gdbarch_tdep *) gdbarch_tdep (gdbarch);
214+ 216+
215+ cb(".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, tdep->gregset, NULL, cb_data); 217+ cb(".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, tdep->gregset, NULL, cb_data);
216+ 218+
@@ -222,8 +224,8 @@ index 28c2ed9a74c..399fa0e3dca 100644
222 static struct gdbarch * 224 static struct gdbarch *
223 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 225 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
224 { 226 {
225@@ -733,6 +770,10 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 227@@ -718,6 +755,10 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
226 tdep = XCNEW (struct gdbarch_tdep); 228 microblaze_gdbarch_tdep *tdep = new microblaze_gdbarch_tdep;
227 gdbarch = gdbarch_alloc (&info, tdep); 229 gdbarch = gdbarch_alloc (&info, tdep);
228 230
229+ tdep->gregset = NULL; 231+ tdep->gregset = NULL;
@@ -233,10 +235,10 @@ index 28c2ed9a74c..399fa0e3dca 100644
233 set_gdbarch_long_double_bit (gdbarch, 128); 235 set_gdbarch_long_double_bit (gdbarch, 128);
234 236
235 set_gdbarch_num_regs (gdbarch, MICROBLAZE_NUM_REGS); 237 set_gdbarch_num_regs (gdbarch, MICROBLAZE_NUM_REGS);
236@@ -781,6 +822,13 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 238@@ -766,6 +807,13 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
237 frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer); 239 frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
238 if (tdesc_data != NULL) 240 if (tdesc_data != NULL)
239 tdesc_use_registers (gdbarch, tdesc, tdesc_data); 241 tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));
240+ //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer); 242+ //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer);
241+ 243+
242+ /* If we have register sets, enable the generic core file support. */ 244+ /* If we have register sets, enable the generic core file support. */
@@ -248,21 +250,22 @@ index 28c2ed9a74c..399fa0e3dca 100644
248 return gdbarch; 250 return gdbarch;
249 } 251 }
250diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h 252diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
251index 8a429cbf001..e91991b8dba 100644 253index 53fcb2297e6..2e853d84d72 100644
252--- a/gdb/microblaze-tdep.h 254--- a/gdb/microblaze-tdep.h
253+++ b/gdb/microblaze-tdep.h 255+++ b/gdb/microblaze-tdep.h
254@@ -22,8 +22,22 @@ 256@@ -23,8 +23,23 @@
255 257 #include "gdbarch.h"
256 258
257 /* Microblaze architecture-specific information. */ 259 /* Microblaze architecture-specific information. */
258+struct microblaze_gregset 260+struct microblaze_gregset
259+{ 261+{
262+ microblaze_gregset() {}
260+ unsigned int gregs[32]; 263+ unsigned int gregs[32];
261+ unsigned int fpregs[32]; 264+ unsigned int fpregs[32];
262+ unsigned int pregs[16]; 265+ unsigned int pregs[16];
263+}; 266+};
264+ 267+
265 struct gdbarch_tdep 268 struct microblaze_gdbarch_tdep : gdbarch_tdep
266 { 269 {
267+ int dummy; // declare something. 270+ int dummy; // declare something.
268+ 271+
@@ -274,7 +277,7 @@ index 8a429cbf001..e91991b8dba 100644
274 }; 277 };
275 278
276 /* Register numbers. */ 279 /* Register numbers. */
277@@ -120,5 +134,18 @@ struct microblaze_frame_cache 280@@ -121,5 +136,18 @@ struct microblaze_frame_cache
278 #define MICROBLAZE_BREAKPOINT {0xba, 0x0c, 0x00, 0x18} 281 #define MICROBLAZE_BREAKPOINT {0xba, 0x0c, 0x00, 0x18}
279 #define MICROBLAZE_BREAKPOINT_LE {0x18, 0x00, 0x0c, 0xba} 282 #define MICROBLAZE_BREAKPOINT_LE {0x18, 0x00, 0x0c, 0xba}
280 283
@@ -294,5 +297,5 @@ index 8a429cbf001..e91991b8dba 100644
294 297
295 #endif /* microblaze-tdep.h */ 298 #endif /* microblaze-tdep.h */
296-- 299--
2972.17.1 3002.37.1 (Apple Git-137.1)
298 301
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0003-Fix-debug-message-when-register-is-unavailable.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0003-Fix-debug-message-when-register-is-unavailable.patch
index 255bb9b5..d2d06b54 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0003-Fix-debug-message-when-register-is-unavailable.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0003-Fix-debug-message-when-register-is-unavailable.patch
@@ -1,40 +1,48 @@
1From da93f5715ff333ac4807b73fe678dde21fb3bd6c Mon Sep 17 00:00:00 2001 1From 6ecb1de66a6a5f55e69c9b108a3d5a85b0ebf315 Mon Sep 17 00:00:00 2001
2From: Nathan Rossi <nathan.rossi@petalogix.com> 2From: Nathan Rossi <nathan.rossi@petalogix.com>
3Date: Tue, 8 May 2012 18:11:17 +1000 3Date: Tue, 8 May 2012 18:11:17 +1000
4Subject: [PATCH 03/10] Fix debug message when register is unavailable 4Subject: [PATCH 3/8] Fix debug message when register is unavailable
5 5
6Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com> 6Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
7
8Conflicts:
9 gdb/frame.c
7--- 10---
8 gdb/frame.c | 13 ++++++++++--- 11 gdb/frame.c | 21 ++++++++++++++-------
9 1 file changed, 10 insertions(+), 3 deletions(-) 12 1 file changed, 14 insertions(+), 7 deletions(-)
10 13
11diff --git a/gdb/frame.c b/gdb/frame.c 14diff --git a/gdb/frame.c b/gdb/frame.c
12index c1eba5848af..fe4a0dc0dd0 100644 15index ce95cf8343b..c49ab9feab2 100644
13--- a/gdb/frame.c 16--- a/gdb/frame.c
14+++ b/gdb/frame.c 17+++ b/gdb/frame.c
15@@ -1305,12 +1305,19 @@ frame_unwind_register_value (frame_info *next_frame, int regnum) 18@@ -1261,13 +1261,20 @@ frame_unwind_register_value (frame_info *next_frame, int regnum)
16 else 19 else
17 { 20 {
18 int i; 21 int i;
19- const gdb_byte *buf = value_contents (value); 22- gdb::array_view<const gdb_byte> buf = value_contents (value);
23-
24- fprintf_unfiltered (&debug_file, " bytes=");
25- fprintf_unfiltered (&debug_file, "[");
26- for (i = 0; i < register_size (gdbarch, regnum); i++)
27- fprintf_unfiltered (&debug_file, "%02x", buf[i]);
28- fprintf_unfiltered (&debug_file, "]");
20+ const gdb_byte *buf = NULL; 29+ const gdb_byte *buf = NULL;
21+ if (value_entirely_available(value)) { 30+ if (value_entirely_available(value)) {
22+ buf = value_contents (value); 31+ gdb::array_view<const gdb_byte> buf = value_contents (value);
23+ } 32+ }
24 33+
25 fprintf_unfiltered (gdb_stdlog, " bytes="); 34+ fprintf_unfiltered (gdb_stdlog, " bytes=");
26 fprintf_unfiltered (gdb_stdlog, "["); 35+ fprintf_unfiltered (gdb_stdlog, "[");
27- for (i = 0; i < register_size (gdbarch, regnum); i++)
28- fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
29+ if (buf != NULL) { 36+ if (buf != NULL) {
30+ for (i = 0; i < register_size (gdbarch, regnum); i++) 37+ for (i = 0; i < register_size (gdbarch, regnum); i++)
31+ fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]); 38+ fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
32+ } else { 39+ } else {
33+ fprintf_unfiltered (gdb_stdlog, "unavailable"); 40+ fprintf_unfiltered (gdb_stdlog, "unavailable");
34+ } 41+ }
35 fprintf_unfiltered (gdb_stdlog, "]"); 42+ fprintf_unfiltered (gdb_stdlog, "]");
36 } 43 }
37 } 44 }
45
38-- 46--
392.17.1 472.37.1 (Apple Git-137.1)
40 48
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0006-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0004-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch
index 9498e8f7..90944525 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0006-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0004-Patch-MicroBlaze-MicroBlaze-native-gdb-port.patch
@@ -1,8 +1,9 @@
1From b37df6ced77898e8cb7e1c343af005d5bfe1272f Mon Sep 17 00:00:00 2001 1From 8d05b79cda7617f228fa4bb6e5147689b662699e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Wed, 15 Jun 2022 10:29:09 +0530 3Date: Mon, 10 Oct 2022 18:53:46 +0530
4Subject: [PATCH 06/10] [Patch,MicroBlaze] : MicroBlaze native gdb port. 4Subject: [PATCH 4/8] [Patch,MicroBlaze] : MicroBlaze native gdb port.
5 5
6signed-off-by : Mahesh Bodapati <mbodapat@amd.com>
6--- 7---
7 gdb/Makefile.in | 2 + 8 gdb/Makefile.in | 2 +
8 gdb/configure.nat | 4 + 9 gdb/configure.nat | 4 +
@@ -18,18 +19,18 @@ Subject: [PATCH 06/10] [Patch,MicroBlaze] : MicroBlaze native gdb port.
18 create mode 100644 gdb/microblaze-linux-tdep.h 19 create mode 100644 gdb/microblaze-linux-tdep.h
19 20
20diff --git a/gdb/Makefile.in b/gdb/Makefile.in 21diff --git a/gdb/Makefile.in b/gdb/Makefile.in
21index ec371fc7e52..0449b8e4c2b 100644 22index aecab41eeb8..fb63e1662c1 100644
22--- a/gdb/Makefile.in 23--- a/gdb/Makefile.in
23+++ b/gdb/Makefile.in 24+++ b/gdb/Makefile.in
24@@ -1336,6 +1336,7 @@ HFILES_NO_SRCDIR = \ 25@@ -1374,6 +1374,7 @@ HFILES_NO_SRCDIR = \
25 memory-map.h \ 26 memory-map.h \
26 memrange.h \ 27 memrange.h \
27 microblaze-tdep.h \ 28 microblaze-tdep.h \
28+ microblaze-linux-tdep.h \ 29+ microblaze-linux-tdep.h \
29 mips-linux-tdep.h \ 30 mips-linux-tdep.h \
30 mips-nbsd-tdep.h \ 31 mips-netbsd-tdep.h \
31 mips-tdep.h \ 32 mips-tdep.h \
32@@ -2214,6 +2215,7 @@ ALLDEPFILES = \ 33@@ -2249,6 +2250,7 @@ ALLDEPFILES = \
33 m68k-linux-nat.c \ 34 m68k-linux-nat.c \
34 m68k-linux-tdep.c \ 35 m68k-linux-tdep.c \
35 m68k-tdep.c \ 36 m68k-tdep.c \
@@ -38,10 +39,10 @@ index ec371fc7e52..0449b8e4c2b 100644
38 microblaze-tdep.c \ 39 microblaze-tdep.c \
39 mingw-hdep.c \ 40 mingw-hdep.c \
40diff --git a/gdb/configure.nat b/gdb/configure.nat 41diff --git a/gdb/configure.nat b/gdb/configure.nat
41index bb70e303384..53f19a3d263 100644 42index b45519fd116..256c666e760 100644
42--- a/gdb/configure.nat 43--- a/gdb/configure.nat
43+++ b/gdb/configure.nat 44+++ b/gdb/configure.nat
44@@ -261,6 +261,10 @@ case ${gdb_host} in 45@@ -270,6 +270,10 @@ case ${gdb_host} in
45 # Host: Motorola m68k running GNU/Linux. 46 # Host: Motorola m68k running GNU/Linux.
46 NATDEPFILES="${NATDEPFILES} m68k-linux-nat.o" 47 NATDEPFILES="${NATDEPFILES} m68k-linux-nat.o"
47 ;; 48 ;;
@@ -54,7 +55,7 @@ index bb70e303384..53f19a3d263 100644
54 NATDEPFILES="${NATDEPFILES} linux-nat-trad.o \ 55 NATDEPFILES="${NATDEPFILES} linux-nat-trad.o \
55diff --git a/gdb/features/microblaze-linux.c b/gdb/features/microblaze-linux.c 56diff --git a/gdb/features/microblaze-linux.c b/gdb/features/microblaze-linux.c
56new file mode 100755 57new file mode 100755
57index 00000000000..29f681bf2ac 58index 00000000000..267e12f6d59
58--- /dev/null 59--- /dev/null
59+++ b/gdb/features/microblaze-linux.c 60+++ b/gdb/features/microblaze-linux.c
60@@ -0,0 +1,79 @@ 61@@ -0,0 +1,79 @@
@@ -69,12 +70,12 @@ index 00000000000..29f681bf2ac
69+static void 70+static void
70+initialize_tdesc_microblaze_linux (void) 71+initialize_tdesc_microblaze_linux (void)
71+{ 72+{
72+ struct target_desc *result = allocate_target_description (); 73+ target_desc_up result = allocate_target_description ();
73+ struct tdesc_feature *feature; 74+ struct tdesc_feature *feature;
74+ set_tdesc_architecture (result, bfd_scan_arch ("microblaze")); 75+ set_tdesc_architecture (result.get(), bfd_scan_arch ("microblaze"));
75+ set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux")); 76+ set_tdesc_osabi (result.get(), osabi_from_tdesc_string ("GNU/Linux"));
76+ 77+
77+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.core"); 78+ feature = tdesc_create_feature (result.get(), "org.gnu.gdb.microblaze.core");
78+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int"); 79+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
79+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int"); 80+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
80+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int"); 81+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int");
@@ -135,7 +136,7 @@ index 00000000000..29f681bf2ac
135+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64"); 136+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
136+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64"); 137+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
137+ 138+
138+ tdesc_microblaze_linux = result; 139+ tdesc_microblaze_linux = result.release();
139+} 140+}
140diff --git a/gdb/microblaze-linux-nat.c b/gdb/microblaze-linux-nat.c 141diff --git a/gdb/microblaze-linux-nat.c b/gdb/microblaze-linux-nat.c
141new file mode 100755 142new file mode 100755
@@ -510,7 +511,7 @@ index 00000000000..6b9daa23120
510+ add_inf_child_target (linux_target); 511+ add_inf_child_target (linux_target);
511+} 512+}
512diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c 513diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
513index b8277dfd735..b77acc9dc61 100644 514index d6197c49dfd..fc52adffb72 100644
514--- a/gdb/microblaze-linux-tdep.c 515--- a/gdb/microblaze-linux-tdep.c
515+++ b/gdb/microblaze-linux-tdep.c 516+++ b/gdb/microblaze-linux-tdep.c
516@@ -37,6 +37,7 @@ 517@@ -37,6 +37,7 @@
@@ -558,10 +559,10 @@ index 00000000000..a2c744e2961
558+ 559+
559+#endif /* MICROBLAZE_LINUX_TDEP_H */ 560+#endif /* MICROBLAZE_LINUX_TDEP_H */
560diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c 561diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
561index 399fa0e3dca..0a5b5ab59cc 100644 562index ccd37d085d6..ccb6b730d64 100644
562--- a/gdb/microblaze-tdep.c 563--- a/gdb/microblaze-tdep.c
563+++ b/gdb/microblaze-tdep.c 564+++ b/gdb/microblaze-tdep.c
564@@ -295,6 +295,7 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, 565@@ -285,6 +285,7 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
565 cache->frameless_p = 0; /* Frame found. */ 566 cache->frameless_p = 0; /* Frame found. */
566 save_hidden_pointer_found = 0; 567 save_hidden_pointer_found = 0;
567 non_stack_instruction_found = 0; 568 non_stack_instruction_found = 0;
@@ -569,7 +570,7 @@ index 399fa0e3dca..0a5b5ab59cc 100644
569 continue; 570 continue;
570 } 571 }
571 else if (IS_SPILL_SP(op, rd, ra)) 572 else if (IS_SPILL_SP(op, rd, ra))
572@@ -443,15 +444,17 @@ microblaze_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) 573@@ -431,15 +432,17 @@ microblaze_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
573 if (find_pc_partial_function (start_pc, NULL, &func_start, &func_end)) 574 if (find_pc_partial_function (start_pc, NULL, &func_start, &func_end))
574 { 575 {
575 sal = find_pc_line (func_start, 0); 576 sal = find_pc_line (func_start, 0);
@@ -590,7 +591,7 @@ index 399fa0e3dca..0a5b5ab59cc 100644
590 if (ostart_pc > start_pc) 591 if (ostart_pc > start_pc)
591 return ostart_pc; 592 return ostart_pc;
592 return start_pc; 593 return start_pc;
593@@ -465,6 +468,7 @@ microblaze_frame_cache (struct frame_info *next_frame, void **this_cache) 594@@ -453,6 +456,7 @@ microblaze_frame_cache (struct frame_info *next_frame, void **this_cache)
594 struct microblaze_frame_cache *cache; 595 struct microblaze_frame_cache *cache;
595 struct gdbarch *gdbarch = get_frame_arch (next_frame); 596 struct gdbarch *gdbarch = get_frame_arch (next_frame);
596 int rn; 597 int rn;
@@ -598,7 +599,7 @@ index 399fa0e3dca..0a5b5ab59cc 100644
598 599
599 if (*this_cache) 600 if (*this_cache)
600 return (struct microblaze_frame_cache *) *this_cache; 601 return (struct microblaze_frame_cache *) *this_cache;
601@@ -478,10 +482,17 @@ microblaze_frame_cache (struct frame_info *next_frame, void **this_cache) 602@@ -466,10 +470,17 @@ microblaze_frame_cache (struct frame_info *next_frame, void **this_cache)
602 cache->register_offsets[rn] = -1; 603 cache->register_offsets[rn] = -1;
603 604
604 /* Call for side effects. */ 605 /* Call for side effects. */
@@ -620,7 +621,7 @@ index 399fa0e3dca..0a5b5ab59cc 100644
620 return cache; 621 return cache;
621 } 622 }
622 623
623@@ -506,6 +517,25 @@ microblaze_frame_prev_register (struct frame_info *this_frame, 624@@ -494,6 +505,25 @@ microblaze_frame_prev_register (struct frame_info *this_frame,
624 struct microblaze_frame_cache *cache = 625 struct microblaze_frame_cache *cache =
625 microblaze_frame_cache (this_frame, this_cache); 626 microblaze_frame_cache (this_frame, this_cache);
626 627
@@ -646,7 +647,7 @@ index 399fa0e3dca..0a5b5ab59cc 100644
646 if (cache->frameless_p) 647 if (cache->frameless_p)
647 { 648 {
648 if (regnum == MICROBLAZE_PC_REGNUM) 649 if (regnum == MICROBLAZE_PC_REGNUM)
649@@ -518,7 +548,9 @@ microblaze_frame_prev_register (struct frame_info *this_frame, 650@@ -506,7 +536,9 @@ microblaze_frame_prev_register (struct frame_info *this_frame,
650 else 651 else
651 return trad_frame_get_prev_register (this_frame, cache->saved_regs, 652 return trad_frame_get_prev_register (this_frame, cache->saved_regs,
652 regnum); 653 regnum);
@@ -657,7 +658,7 @@ index 399fa0e3dca..0a5b5ab59cc 100644
657 } 658 }
658 659
659 static const struct frame_unwind microblaze_frame_unwind = 660 static const struct frame_unwind microblaze_frame_unwind =
660@@ -633,7 +665,106 @@ microblaze_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type) 661@@ -622,7 +654,106 @@ microblaze_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
661 return (TYPE_LENGTH (type) == 16); 662 return (TYPE_LENGTH (type) == 16);
662 } 663 }
663 664
@@ -765,7 +766,7 @@ index 399fa0e3dca..0a5b5ab59cc 100644
765 static int dwarf2_to_reg_map[78] = 766 static int dwarf2_to_reg_map[78] =
766 { 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */ 767 { 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */
767 4 /* r4 */, 5 /* r5 */, 6 /* r6 */, 7 /* r7 */, /* 4- 7 */ 768 4 /* r4 */, 5 /* r5 */, 6 /* r6 */, 7 /* r7 */, /* 4- 7 */
768@@ -805,6 +936,8 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 769@@ -790,6 +921,8 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
769 microblaze_breakpoint::bp_from_kind); 770 microblaze_breakpoint::bp_from_kind);
770 set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint); 771 set_gdbarch_memory_remove_breakpoint (gdbarch, microblaze_linux_memory_remove_breakpoint);
771 772
@@ -775,10 +776,10 @@ index 399fa0e3dca..0a5b5ab59cc 100644
775 776
776 set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc); 777 set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc);
777diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h 778diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
778index 872a3931f20..7f75c693b74 100644 779index 2e853d84d72..2415acfe7b6 100644
779--- a/gdb/microblaze-tdep.h 780--- a/gdb/microblaze-tdep.h
780+++ b/gdb/microblaze-tdep.h 781+++ b/gdb/microblaze-tdep.h
781@@ -59,11 +59,11 @@ enum microblaze_regnum 782@@ -60,11 +60,11 @@ enum microblaze_regnum
782 MICROBLAZE_R12_REGNUM, 783 MICROBLAZE_R12_REGNUM,
783 MICROBLAZE_R13_REGNUM, 784 MICROBLAZE_R13_REGNUM,
784 MICROBLAZE_R14_REGNUM, 785 MICROBLAZE_R14_REGNUM,
@@ -792,7 +793,7 @@ index 872a3931f20..7f75c693b74 100644
792 MICROBLAZE_R20_REGNUM, 793 MICROBLAZE_R20_REGNUM,
793 MICROBLAZE_R21_REGNUM, 794 MICROBLAZE_R21_REGNUM,
794 MICROBLAZE_R22_REGNUM, 795 MICROBLAZE_R22_REGNUM,
795@@ -76,7 +76,8 @@ enum microblaze_regnum 796@@ -77,7 +77,8 @@ enum microblaze_regnum
796 MICROBLAZE_R29_REGNUM, 797 MICROBLAZE_R29_REGNUM,
797 MICROBLAZE_R30_REGNUM, 798 MICROBLAZE_R30_REGNUM,
798 MICROBLAZE_R31_REGNUM, 799 MICROBLAZE_R31_REGNUM,
@@ -802,7 +803,7 @@ index 872a3931f20..7f75c693b74 100644
802 MICROBLAZE_MSR_REGNUM, 803 MICROBLAZE_MSR_REGNUM,
803 MICROBLAZE_EAR_REGNUM, 804 MICROBLAZE_EAR_REGNUM,
804 MICROBLAZE_ESR_REGNUM, 805 MICROBLAZE_ESR_REGNUM,
805@@ -101,17 +102,21 @@ enum microblaze_regnum 806@@ -102,17 +103,21 @@ enum microblaze_regnum
806 MICROBLAZE_RTLBSX_REGNUM, 807 MICROBLAZE_RTLBSX_REGNUM,
807 MICROBLAZE_RTLBLO_REGNUM, 808 MICROBLAZE_RTLBLO_REGNUM,
808 MICROBLAZE_RTLBHI_REGNUM, 809 MICROBLAZE_RTLBHI_REGNUM,
@@ -827,5 +828,5 @@ index 872a3931f20..7f75c693b74 100644
827 int frameless_p; 828 int frameless_p;
828 829
829-- 830--
8302.17.1 8312.37.1 (Apple Git-137.1)
831 832
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0004-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0004-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch
deleted file mode 100644
index f1555b8a..00000000
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0004-microblaze-Add-build_gdbserver-yes-to-top-level-conf.patch
+++ /dev/null
@@ -1,32 +0,0 @@
1From 82ee589db2c1191fb274f4a76e217df318f8d6b2 Mon Sep 17 00:00:00 2001
2From: David Holsgrove <david.holsgrove@xilinx.com>
3Date: Mon, 16 Dec 2013 16:37:32 +1000
4Subject: [PATCH 04/10] microblaze: Add build_gdbserver=yes to top level
5 configure.tgt
6
7For Microblaze linux toolchains, set the build_gdbserver=yes
8to allow driving gdbserver configuration from the upper level
9
10This patch has been absorbed into the original patch to add
11linux gdbserver support for Microblaze.
12
13Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
14---
15 gdb/configure.tgt | 1 +
16 1 file changed, 1 insertion(+)
17
18diff --git a/gdb/configure.tgt b/gdb/configure.tgt
19index b8378440b23..8ca2042c7cb 100644
20--- a/gdb/configure.tgt
21+++ b/gdb/configure.tgt
22@@ -408,6 +408,7 @@ microblaze*-*-*)
23 # Target: Xilinx MicroBlaze running standalone
24 gdb_target_obs="microblaze-tdep.o"
25 gdb_sim=../sim/microblaze/libsim.a
26+ build_gdbserver=yes
27 ;;
28
29 mips*-*-linux*)
30--
312.17.1
32
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0005-Fixing-the-issues-related-to-GDB-7.12.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0005-Fixing-the-issues-related-to-GDB-7.12.patch
deleted file mode 100644
index 48e203a9..00000000
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0005-Fixing-the-issues-related-to-GDB-7.12.patch
+++ /dev/null
@@ -1,201 +0,0 @@
1From ca1158d19ab9879167ca9fbe2fdf8d19094cc53f Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Fri, 17 Feb 2017 14:09:40 +0530
4Subject: [PATCH 05/10] Fixing the issues related to GDB-7.12
5
6added all the required function which are new in 7.12 and removed
7few deprecated functions from 7.6
8
9Conflicts:
10 gdb/config/microblaze/linux.mh
11---
12 gdb/gdbserver/linux-microblaze-low.c | 97 ++++++++++++++++++++++++----
13 gdb/microblaze-tdep.h | 1 +
14 gdbserver/configure.srv | 3 +-
15 3 files changed, 86 insertions(+), 15 deletions(-)
16
17diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdb/gdbserver/linux-microblaze-low.c
18index cba5d6fc585..a2733f3c21c 100644
19--- a/gdb/gdbserver/linux-microblaze-low.c
20+++ b/gdb/gdbserver/linux-microblaze-low.c
21@@ -39,10 +39,11 @@ static int microblaze_regmap[] =
22 PT_FSR
23 };
24
25-#define microblaze_num_regs (sizeof microblaze_regmap / sizeof microblaze_regmap[0])
26+#define microblaze_num_regs (sizeof (microblaze_regmap) / sizeof (microblaze_regmap[0]))
27
28 /* Defined in auto-generated file microblaze-linux.c. */
29 void init_registers_microblaze (void);
30+extern const struct target_desc *tdesc_microblaze;
31
32 static int
33 microblaze_cannot_store_register (int regno)
34@@ -81,6 +82,15 @@ microblaze_set_pc (struct regcache *regcache, CORE_ADDR pc)
35 static const unsigned long microblaze_breakpoint = 0xba0c0018;
36 #define microblaze_breakpoint_len 4
37
38+/* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
39+
40+static const gdb_byte *
41+microblaze_sw_breakpoint_from_kind (int kind, int *size)
42+{
43+ *size = microblaze_breakpoint_len;
44+ return (const gdb_byte *) &microblaze_breakpoint;
45+}
46+
47 static int
48 microblaze_breakpoint_at (CORE_ADDR where)
49 {
50@@ -107,7 +117,7 @@ microblaze_reinsert_addr (struct regcache *regcache)
51 static void
52 microblaze_collect_ptrace_register (struct regcache *regcache, int regno, char *buf)
53 {
54- int size = register_size (regno);
55+ int size = register_size (regcache->tdesc, regno);
56
57 memset (buf, 0, sizeof (long));
58
59@@ -121,7 +131,7 @@ static void
60 microblaze_supply_ptrace_register (struct regcache *regcache,
61 int regno, const char *buf)
62 {
63- int size = register_size (regno);
64+ int size = register_size (regcache->tdesc, regno);
65
66 if (regno == 0) {
67 unsigned long regbuf_0 = 0;
68@@ -157,33 +167,94 @@ microblaze_store_gregset (struct regcache *regcache, const void *buf)
69
70 #endif /* HAVE_PTRACE_GETREGS */
71
72-struct regset_info target_regsets[] = {
73+static struct regset_info microblaze_regsets[] = {
74 #ifdef HAVE_PTRACE_GETREGS
75 { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset },
76- { 0, 0, 0, -1, -1, NULL, NULL },
77+ { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
78 #endif /* HAVE_PTRACE_GETREGS */
79- { 0, 0, 0, -1, -1, NULL, NULL }
80+ { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
81+ NULL_REGSET
82 };
83
84+static struct usrregs_info microblaze_usrregs_info =
85+ {
86+ microblaze_num_regs,
87+ microblaze_regmap,
88+ };
89+
90+static struct regsets_info microblaze_regsets_info =
91+ {
92+ microblaze_regsets, /* regsets */
93+ 0, /* num_regsets */
94+ NULL, /* disabled_regsets */
95+ };
96+
97+static struct regs_info regs_info =
98+ {
99+ NULL, /* regset_bitmap */
100+ &microblaze_usrregs_info,
101+ &microblaze_regsets_info
102+ };
103+
104+static const struct regs_info *
105+microblaze_regs_info (void)
106+{
107+ return &regs_info;
108+}
109+
110+/* Support for hardware single step. */
111+
112+static int
113+microblaze_supports_hardware_single_step (void)
114+{
115+ return 1;
116+}
117+
118+
119+static void
120+microblaze_arch_setup (void)
121+{
122+ current_process ()->tdesc = tdesc_microblaze;
123+}
124+
125 struct linux_target_ops the_low_target = {
126- init_registers_microblaze,
127- microblaze_num_regs,
128- microblaze_regmap,
129- NULL,
130+ microblaze_arch_setup,
131+ microblaze_regs_info,
132 microblaze_cannot_fetch_register,
133 microblaze_cannot_store_register,
134 NULL, /* fetch_register */
135 microblaze_get_pc,
136 microblaze_set_pc,
137- (const unsigned char *) &microblaze_breakpoint,
138- microblaze_breakpoint_len,
139- microblaze_reinsert_addr,
140+ NULL,
141+ microblaze_sw_breakpoint_from_kind,
142+ NULL,
143 0,
144 microblaze_breakpoint_at,
145 NULL,
146 NULL,
147 NULL,
148 NULL,
149+ NULL,
150 microblaze_collect_ptrace_register,
151 microblaze_supply_ptrace_register,
152+ NULL, /* siginfo_fixup */
153+ NULL, /* new_process */
154+ NULL, /* new_thread */
155+ NULL, /* new_fork */
156+ NULL, /* prepare_to_resume */
157+ NULL, /* process_qsupported */
158+ NULL, /* supports_tracepoints */
159+ NULL, /* get_thread_area */
160+ NULL, /* install_fast_tracepoint_jump_pad */
161+ NULL, /* emit_ops */
162+ NULL, /* get_min_fast_tracepoint_insn_len */
163+ NULL, /* supports_range_stepping */
164+ NULL, /* breakpoint_kind_from_current_state */
165+ microblaze_supports_hardware_single_step,
166 };
167+
168+void
169+initialize_low_arch (void)
170+{
171+ init_registers_microblaze ();
172+}
173diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
174index e91991b8dba..872a3931f20 100644
175--- a/gdb/microblaze-tdep.h
176+++ b/gdb/microblaze-tdep.h
177@@ -24,6 +24,7 @@
178 /* Microblaze architecture-specific information. */
179 struct microblaze_gregset
180 {
181+ microblaze_gregset() {}
182 unsigned int gregs[32];
183 unsigned int fpregs[32];
184 unsigned int pregs[16];
185diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
186index 9d68c24a92d..af10cb05683 100644
187--- a/gdbserver/configure.srv
188+++ b/gdbserver/configure.srv
189@@ -167,8 +167,7 @@ case "${gdbserver_host}" in
190 srv_linux_thread_db=yes
191 ;;
192 microblaze*-*-linux*) srv_regobj="microblaze-linux.o"
193- srv_tgtobj="linux-low.o linux-osdata.o linux-microblaze-low.o "
194- srv_tgtobj="${srv_tgtobj} linux-procfs.o linux-ptrace.o"
195+ srv_tgtobj="$srv_linux_obj linux-microblaze-low.o "
196 srv_xmlfiles="microblaze-linux.xml"
197 srv_linux_regsets=yes
198 srv_linux_usrregs=yes
199--
2002.17.1
201
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-microblaze-Adding-64-bit-MB-support.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0005-Patch-microblaze-Adding-64-bit-MB-support.patch
index 564562da..caf20303 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-microblaze-Adding-64-bit-MB-support.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0005-Patch-microblaze-Adding-64-bit-MB-support.patch
@@ -1,9 +1,10 @@
1From 0eea9a3f068837d4792719a8f9ba15736938eea4 Mon Sep 17 00:00:00 2001 1From 6aadc445a00275c37112e431c6a29f5a331e6e16 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com> 2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Thu, 31 Jan 2019 14:36:00 +0530 3Date: Thu, 31 Jan 2019 14:36:00 +0530
4Subject: [PATCH 07/10] [Patch, microblaze]: Adding 64 bit MB support Added new 4Subject: [PATCH 5/8] [Patch, microblaze]: Adding 64 bit MB support Added new
5 architecture to Microblaze 64-bit support to GDB Signed-off-by :Nagaraju 5 architecture to Microblaze 64-bit support to GDB Signed-off-by :Nagaraju
6 Mekala <nmekala@xilix.com> 6 Mekala <nmekala@xilix.com> Signed-off-by :Mahesh Bodapati
7 <mbodapat@xilinx.com>
7 8
8Conflicts: 9Conflicts:
9 gdb/Makefile.in 10 gdb/Makefile.in
@@ -11,14 +12,28 @@ Conflicts:
11Conflicts: 12Conflicts:
12 bfd/cpu-microblaze.c 13 bfd/cpu-microblaze.c
13 gdb/microblaze-tdep.c 14 gdb/microblaze-tdep.c
15 ld/Makefile.am
16 ld/Makefile.in
14 opcodes/microblaze-dis.c 17 opcodes/microblaze-dis.c
15 18
16Conflicts: 19Conflicts:
17 bfd/configure 20 bfd/configure
21 gas/config/tc-microblaze.c
22 ld/Makefile.in
18 opcodes/microblaze-opcm.h 23 opcodes/microblaze-opcm.h
19 24
20Conflicts: 25Conflicts:
21 gdb/microblaze-tdep.c 26 gdb/microblaze-tdep.c
27
28Conflicts:
29 bfd/elf32-microblaze.c
30 gas/config/tc-microblaze.c
31 gdb/features/Makefile
32 gdb/features/microblaze-with-stack-protect.c
33 gdb/microblaze-tdep.c
34 gdb/regformats/microblaze-with-stack-protect.dat
35 gdbserver/linux-microblaze-low.c
36 include/elf/common.h
22--- 37---
23 bfd/Makefile.am | 2 + 38 bfd/Makefile.am | 2 +
24 bfd/Makefile.in | 3 + 39 bfd/Makefile.in | 3 +
@@ -27,12 +42,12 @@ Conflicts:
27 bfd/config.bfd | 4 + 42 bfd/config.bfd | 4 +
28 bfd/configure | 2 + 43 bfd/configure | 2 +
29 bfd/cpu-microblaze.c | 55 +- 44 bfd/cpu-microblaze.c | 55 +-
30 bfd/elf32-microblaze.c | 243 +- 45 bfd/elf32-microblaze.c | 162 +-
31 bfd/elf64-microblaze.c | 3711 +++++++++++++++++ 46 bfd/elf64-microblaze.c | 3810 +++++++++++++++++
32 bfd/libbfd.h | 3 + 47 bfd/libbfd.h | 3 +
33 bfd/reloc.c | 20 + 48 bfd/reloc.c | 20 +
34 bfd/targets.c | 6 + 49 bfd/targets.c | 6 +
35 gdb/features/Makefile | 3 + 50 gdb/features/Makefile | 2 +
36 gdb/features/microblaze-core.xml | 6 +- 51 gdb/features/microblaze-core.xml | 6 +-
37 gdb/features/microblaze-stack-protect.xml | 4 +- 52 gdb/features/microblaze-stack-protect.xml | 4 +-
38 gdb/features/microblaze-with-stack-protect.c | 8 +- 53 gdb/features/microblaze-with-stack-protect.c | 8 +-
@@ -44,16 +59,14 @@ Conflicts:
44 gdb/features/microblaze64.c | 77 + 59 gdb/features/microblaze64.c | 77 +
45 gdb/features/microblaze64.xml | 11 + 60 gdb/features/microblaze64.xml | 11 +
46 gdb/microblaze-linux-tdep.c | 36 +- 61 gdb/microblaze-linux-tdep.c | 36 +-
47 gdb/microblaze-tdep.c | 102 +- 62 gdb/microblaze-tdep.c | 126 +-
48 gdb/microblaze-tdep.h | 4 +- 63 gdb/microblaze-tdep.h | 4 +-
49 .../microblaze-with-stack-protect.dat | 4 +-
50 .../linux-microblaze-low.c | 0
51 include/elf/common.h | 1 + 64 include/elf/common.h | 1 +
52 include/elf/microblaze.h | 4 + 65 include/elf/microblaze.h | 4 +
53 opcodes/microblaze-dis.c | 51 +- 66 opcodes/microblaze-dis.c | 51 +-
54 opcodes/microblaze-opc.h | 180 +- 67 opcodes/microblaze-opc.h | 180 +-
55 opcodes/microblaze-opcm.h | 36 +- 68 opcodes/microblaze-opcm.h | 36 +-
56 41 files changed, 5345 insertions(+), 245 deletions(-) 69 31 files changed, 4729 insertions(+), 95 deletions(-)
57 create mode 100755 bfd/elf64-microblaze.c 70 create mode 100755 bfd/elf64-microblaze.c
58 create mode 100644 gdb/features/microblaze64-core.xml 71 create mode 100644 gdb/features/microblaze64-core.xml
59 create mode 100644 gdb/features/microblaze64-stack-protect.xml 72 create mode 100644 gdb/features/microblaze64-stack-protect.xml
@@ -61,13 +74,12 @@ Conflicts:
61 create mode 100644 gdb/features/microblaze64-with-stack-protect.xml 74 create mode 100644 gdb/features/microblaze64-with-stack-protect.xml
62 create mode 100644 gdb/features/microblaze64.c 75 create mode 100644 gdb/features/microblaze64.c
63 create mode 100644 gdb/features/microblaze64.xml 76 create mode 100644 gdb/features/microblaze64.xml
64 rename {gdb/gdbserver => gdbserver}/linux-microblaze-low.c (100%)
65 77
66diff --git a/bfd/Makefile.am b/bfd/Makefile.am 78diff --git a/bfd/Makefile.am b/bfd/Makefile.am
67index d07c9605b6f..11bbf9a4e0d 100644 79index b9a3f8207ac..2ddd7891661 100644
68--- a/bfd/Makefile.am 80--- a/bfd/Makefile.am
69+++ b/bfd/Makefile.am 81+++ b/bfd/Makefile.am
70@@ -558,6 +558,7 @@ BFD64_BACKENDS = \ 82@@ -571,6 +571,7 @@ BFD64_BACKENDS = \
71 elf64-riscv.lo \ 83 elf64-riscv.lo \
72 elfxx-riscv.lo \ 84 elfxx-riscv.lo \
73 elf64-s390.lo \ 85 elf64-s390.lo \
@@ -75,7 +87,7 @@ index d07c9605b6f..11bbf9a4e0d 100644
75 elf64-sparc.lo \ 87 elf64-sparc.lo \
76 elf64-tilegx.lo \ 88 elf64-tilegx.lo \
77 elf64-x86-64.lo \ 89 elf64-x86-64.lo \
78@@ -592,6 +593,7 @@ BFD64_BACKENDS_CFILES = \ 90@@ -608,6 +609,7 @@ BFD64_BACKENDS_CFILES = \
79 elf64-nfp.c \ 91 elf64-nfp.c \
80 elf64-ppc.c \ 92 elf64-ppc.c \
81 elf64-s390.c \ 93 elf64-s390.c \
@@ -84,10 +96,10 @@ index d07c9605b6f..11bbf9a4e0d 100644
84 elf64-tilegx.c \ 96 elf64-tilegx.c \
85 elf64-x86-64.c \ 97 elf64-x86-64.c \
86diff --git a/bfd/Makefile.in b/bfd/Makefile.in 98diff --git a/bfd/Makefile.in b/bfd/Makefile.in
87index 9cad4da6f8f..72745bb62b1 100644 99index 934dd4bc066..7efb10f111d 100644
88--- a/bfd/Makefile.in 100--- a/bfd/Makefile.in
89+++ b/bfd/Makefile.in 101+++ b/bfd/Makefile.in
90@@ -985,6 +985,7 @@ BFD64_BACKENDS = \ 102@@ -1040,6 +1040,7 @@ BFD64_BACKENDS = \
91 elf64-riscv.lo \ 103 elf64-riscv.lo \
92 elfxx-riscv.lo \ 104 elfxx-riscv.lo \
93 elf64-s390.lo \ 105 elf64-s390.lo \
@@ -95,7 +107,7 @@ index 9cad4da6f8f..72745bb62b1 100644
95 elf64-sparc.lo \ 107 elf64-sparc.lo \
96 elf64-tilegx.lo \ 108 elf64-tilegx.lo \
97 elf64-x86-64.lo \ 109 elf64-x86-64.lo \
98@@ -1019,6 +1020,7 @@ BFD64_BACKENDS_CFILES = \ 110@@ -1077,6 +1078,7 @@ BFD64_BACKENDS_CFILES = \
99 elf64-nfp.c \ 111 elf64-nfp.c \
100 elf64-ppc.c \ 112 elf64-ppc.c \
101 elf64-s390.c \ 113 elf64-s390.c \
@@ -103,7 +115,7 @@ index 9cad4da6f8f..72745bb62b1 100644
103 elf64-sparc.c \ 115 elf64-sparc.c \
104 elf64-tilegx.c \ 116 elf64-tilegx.c \
105 elf64-x86-64.c \ 117 elf64-x86-64.c \
106@@ -1498,6 +1500,7 @@ distclean-compile: 118@@ -1664,6 +1666,7 @@ distclean-compile:
107 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-ppc.Plo@am__quote@ 119 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-ppc.Plo@am__quote@
108 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-riscv.Plo@am__quote@ 120 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-riscv.Plo@am__quote@
109 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-s390.Plo@am__quote@ 121 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-s390.Plo@am__quote@
@@ -112,10 +124,10 @@ index 9cad4da6f8f..72745bb62b1 100644
112 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-tilegx.Plo@am__quote@ 124 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-tilegx.Plo@am__quote@
113 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-x86-64.Plo@am__quote@ 125 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-x86-64.Plo@am__quote@
114diff --git a/bfd/archures.c b/bfd/archures.c 126diff --git a/bfd/archures.c b/bfd/archures.c
115index 50698648d6a..7ebae017347 100644 127index fac9fe82a08..1790c741c58 100644
116--- a/bfd/archures.c 128--- a/bfd/archures.c
117+++ b/bfd/archures.c 129+++ b/bfd/archures.c
118@@ -523,6 +523,8 @@ DESCRIPTION 130@@ -524,6 +524,8 @@ DESCRIPTION
119 . bfd_arch_lm32, {* Lattice Mico32. *} 131 . bfd_arch_lm32, {* Lattice Mico32. *}
120 .#define bfd_mach_lm32 1 132 .#define bfd_mach_lm32 1
121 . bfd_arch_microblaze,{* Xilinx MicroBlaze. *} 133 . bfd_arch_microblaze,{* Xilinx MicroBlaze. *}
@@ -125,10 +137,10 @@ index 50698648d6a..7ebae017347 100644
125 . bfd_arch_tilegx, {* Tilera TILE-Gx. *} 137 . bfd_arch_tilegx, {* Tilera TILE-Gx. *}
126 .#define bfd_mach_tilepro 1 138 .#define bfd_mach_tilepro 1
127diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h 139diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
128index 935ba535b54..b9f98fb5f40 100644 140index c0b563aec02..ccaeecb9476 100644
129--- a/bfd/bfd-in2.h 141--- a/bfd/bfd-in2.h
130+++ b/bfd/bfd-in2.h 142+++ b/bfd/bfd-in2.h
131@@ -1923,6 +1923,8 @@ enum bfd_architecture 143@@ -1903,6 +1903,8 @@ enum bfd_architecture
132 bfd_arch_lm32, /* Lattice Mico32. */ 144 bfd_arch_lm32, /* Lattice Mico32. */
133 #define bfd_mach_lm32 1 145 #define bfd_mach_lm32 1
134 bfd_arch_microblaze,/* Xilinx MicroBlaze. */ 146 bfd_arch_microblaze,/* Xilinx MicroBlaze. */
@@ -137,7 +149,7 @@ index 935ba535b54..b9f98fb5f40 100644
137 bfd_arch_tilepro, /* Tilera TILEPro. */ 149 bfd_arch_tilepro, /* Tilera TILEPro. */
138 bfd_arch_tilegx, /* Tilera TILE-Gx. */ 150 bfd_arch_tilegx, /* Tilera TILE-Gx. */
139 #define bfd_mach_tilepro 1 151 #define bfd_mach_tilepro 1
140@@ -5433,16 +5435,41 @@ value relative to the read-write small data area anchor */ 152@@ -5443,16 +5445,41 @@ value relative to the read-write small data area anchor */
141 expressions of the form "Symbol Op Symbol" */ 153 expressions of the form "Symbol Op Symbol" */
142 BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM, 154 BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM,
143 155
@@ -182,10 +194,10 @@ index 935ba535b54..b9f98fb5f40 100644
182 value in two words (with an imm instruction). The relocation is 194 value in two words (with an imm instruction). The relocation is
183 GOT offset */ 195 GOT offset */
184diff --git a/bfd/config.bfd b/bfd/config.bfd 196diff --git a/bfd/config.bfd b/bfd/config.bfd
185index 6c2919e47eb..0f752de267b 100644 197index 872685cfb72..5e9ba3d9805 100644
186--- a/bfd/config.bfd 198--- a/bfd/config.bfd
187+++ b/bfd/config.bfd 199+++ b/bfd/config.bfd
188@@ -827,11 +827,15 @@ case "${targ}" in 200@@ -860,11 +860,15 @@ case "${targ}" in
189 microblazeel*-*) 201 microblazeel*-*)
190 targ_defvec=microblaze_elf32_le_vec 202 targ_defvec=microblaze_elf32_le_vec
191 targ_selvecs=microblaze_elf32_vec 203 targ_selvecs=microblaze_elf32_vec
@@ -202,10 +214,10 @@ index 6c2919e47eb..0f752de267b 100644
202 214
203 #ifdef BFD64 215 #ifdef BFD64
204diff --git a/bfd/configure b/bfd/configure 216diff --git a/bfd/configure b/bfd/configure
205index a9c4fd93669..ea697865179 100755 217index 0ef4c206fb0..b7547c6777c 100755
206--- a/bfd/configure 218--- a/bfd/configure
207+++ b/bfd/configure 219+++ b/bfd/configure
208@@ -14928,6 +14928,8 @@ do 220@@ -13547,6 +13547,8 @@ do
209 rx_elf32_linux_le_vec) tb="$tb elf32-rx.lo elf32.lo $elf" ;; 221 rx_elf32_linux_le_vec) tb="$tb elf32-rx.lo elf32.lo $elf" ;;
210 s390_elf32_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;; 222 s390_elf32_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
211 s390_elf64_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;; 223 s390_elf64_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
@@ -215,7 +227,7 @@ index a9c4fd93669..ea697865179 100755
215 score_elf32_le_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo elf64.lo $elf"; want64=true; target_size=64 ;; 227 score_elf32_le_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo elf64.lo $elf"; want64=true; target_size=64 ;;
216 sh_coff_vec) tb="$tb coff-sh.lo $coff" ;; 228 sh_coff_vec) tb="$tb coff-sh.lo $coff" ;;
217diff --git a/bfd/cpu-microblaze.c b/bfd/cpu-microblaze.c 229diff --git a/bfd/cpu-microblaze.c b/bfd/cpu-microblaze.c
218index 05a3f767e22..749d4352c5b 100644 230index 0c1d2b1aa69..106f78229b5 100644
219--- a/bfd/cpu-microblaze.c 231--- a/bfd/cpu-microblaze.c
220+++ b/bfd/cpu-microblaze.c 232+++ b/bfd/cpu-microblaze.c
221@@ -23,13 +23,30 @@ 233@@ -23,13 +23,30 @@
@@ -235,7 +247,7 @@ index 05a3f767e22..749d4352c5b 100644
235+ "microblaze", /* Architecture name. */ 247+ "microblaze", /* Architecture name. */
236+ "MicroBlaze", /* Printable name. */ 248+ "MicroBlaze", /* Printable name. */
237+ 3, /* Section align power. */ 249+ 3, /* Section align power. */
238+ FALSE, /* Is this the default architecture ? */ 250+ false, /* Is this the default architecture ? */
239+ bfd_default_compatible, /* Architecture comparison function. */ 251+ bfd_default_compatible, /* Architecture comparison function. */
240+ bfd_default_scan, /* String to architecture conversion. */ 252+ bfd_default_scan, /* String to architecture conversion. */
241+ bfd_arch_default_fill, /* Default fill. */ 253+ bfd_arch_default_fill, /* Default fill. */
@@ -266,7 +278,7 @@ index 05a3f767e22..749d4352c5b 100644
266+ "microblaze", /* Architecture name. */ 278+ "microblaze", /* Architecture name. */
267+ "MicroBlaze", /* Printable name. */ 279+ "MicroBlaze", /* Printable name. */
268+ 3, /* Section align power. */ 280+ 3, /* Section align power. */
269+ TRUE, /* Is this the default architecture ? */ 281+ true, /* Is this the default architecture ? */
270+ bfd_default_compatible, /* Architecture comparison function. */ 282+ bfd_default_compatible, /* Architecture comparison function. */
271+ bfd_default_scan, /* String to architecture conversion. */ 283+ bfd_default_scan, /* String to architecture conversion. */
272+ bfd_arch_default_fill, /* Default fill. */ 284+ bfd_arch_default_fill, /* Default fill. */
@@ -281,7 +293,7 @@ index 05a3f767e22..749d4352c5b 100644
281+ "microblaze", /* Architecture name. */ 293+ "microblaze", /* Architecture name. */
282+ "MicroBlaze", /* Printable name. */ 294+ "MicroBlaze", /* Printable name. */
283+ 3, /* Section align power. */ 295+ 3, /* Section align power. */
284+ FALSE, /* Is this the default architecture ? */ 296+ false, /* Is this the default architecture ? */
285+ bfd_default_compatible, /* Architecture comparison function. */ 297+ bfd_default_compatible, /* Architecture comparison function. */
286+ bfd_default_scan, /* String to architecture conversion. */ 298+ bfd_default_scan, /* String to architecture conversion. */
287+ bfd_arch_default_fill, /* Default fill. */ 299+ bfd_arch_default_fill, /* Default fill. */
@@ -291,76 +303,76 @@ index 05a3f767e22..749d4352c5b 100644
291+#endif 303+#endif
292 }; 304 };
293diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c 305diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
294index cfd70ae9178..9f9e13467d2 100644 306index d3b3c66cf00..053c1b432f9 100644
295--- a/bfd/elf32-microblaze.c 307--- a/bfd/elf32-microblaze.c
296+++ b/bfd/elf32-microblaze.c 308+++ b/bfd/elf32-microblaze.c
297@@ -116,6 +116,20 @@ static reloc_howto_type microblaze_elf_howto_raw[] = 309@@ -114,6 +114,20 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
298 0x0000ffff, /* Dest Mask. */ 310 0x0000ffff, /* Dest Mask. */
299 TRUE), /* PC relative offset? */ 311 true), /* PC relative offset? */
300 312
301+ HOWTO (R_MICROBLAZE_IMML_64, /* Type. */ 313+ HOWTO (R_MICROBLAZE_IMML_64, /* Type. */
302+ 0, /* Rightshift. */ 314+ 0, /* Rightshift. */
303+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 315+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
304+ 16, /* Bitsize. */ 316+ 16, /* Bitsize. */
305+ TRUE, /* PC_relative. */ 317+ true, /* PC_relative. */
306+ 0, /* Bitpos. */ 318+ 0, /* Bitpos. */
307+ complain_overflow_dont, /* Complain on overflow. */ 319+ complain_overflow_dont, /* Complain on overflow. */
308+ bfd_elf_generic_reloc,/* Special Function. */ 320+ bfd_elf_generic_reloc,/* Special Function. */
309+ "R_MICROBLAZE_IMML_64", /* Name. */ 321+ "R_MICROBLAZE_IMML_64", /* Name. */
310+ FALSE, /* Partial Inplace. */ 322+ false, /* Partial Inplace. */
311+ 0, /* Source Mask. */ 323+ 0, /* Source Mask. */
312+ 0x0000ffff, /* Dest Mask. */ 324+ 0x0000ffff, /* Dest Mask. */
313+ FALSE), /* PC relative offset? */ 325+ false), /* PC relative offset? */
314+ 326+
315 /* A 64 bit relocation. Table entry not really used. */ 327 /* A 64 bit relocation. Table entry not really used. */
316 HOWTO (R_MICROBLAZE_64, /* Type. */ 328 HOWTO (R_MICROBLAZE_64, /* Type. */
317 0, /* Rightshift. */ 329 0, /* Rightshift. */
318@@ -176,7 +190,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] = 330@@ -174,7 +188,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
319 0x0000ffff, /* Dest Mask. */ 331 0x0000ffff, /* Dest Mask. */
320 FALSE), /* PC relative offset? */ 332 false), /* PC relative offset? */
321 333
322- /* This reloc does nothing. Used for relaxation. */ 334- /* This reloc does nothing. Used for relaxation. */
323+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */ 335+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
324+ 0, /* Rightshift. */ 336+ 0, /* Rightshift. */
325+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 337+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
326+ 32, /* Bitsize. */ 338+ 32, /* Bitsize. */
327+ TRUE, /* PC_relative. */ 339+ true, /* PC_relative. */
328+ 0, /* Bitpos. */ 340+ 0, /* Bitpos. */
329+ complain_overflow_bitfield, /* Complain on overflow. */ 341+ complain_overflow_bitfield, /* Complain on overflow. */
330+ NULL, /* Special Function. */ 342+ NULL, /* Special Function. */
331+ "R_MICROBLAZE_32_NONE",/* Name. */ 343+ "R_MICROBLAZE_32_NONE",/* Name. */
332+ FALSE, /* Partial Inplace. */ 344+ false, /* Partial Inplace. */
333+ 0, /* Source Mask. */ 345+ 0, /* Source Mask. */
334+ 0, /* Dest Mask. */ 346+ 0, /* Dest Mask. */
335+ FALSE), /* PC relative offset? */ 347+ false), /* PC relative offset? */
336+ 348+
337+ /* This reloc does nothing. Used for relaxation. */ 349+ /* This reloc does nothing. Used for relaxation. */
338 HOWTO (R_MICROBLAZE_64_NONE, /* Type. */ 350 HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
339 0, /* Rightshift. */ 351 0, /* Rightshift. */
340 3, /* Size (0 = byte, 1 = short, 2 = long). */ 352 3, /* Size (0 = byte, 1 = short, 2 = long). */
341@@ -266,6 +294,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] = 353@@ -264,6 +292,21 @@ static reloc_howto_type microblaze_elf_howto_raw[] =
342 0x0000ffff, /* Dest Mask. */ 354 0x0000ffff, /* Dest Mask. */
343 TRUE), /* PC relative offset? */ 355 true), /* PC relative offset? */
344 356
345+ /* A 64 bit GOTPC relocation. Table-entry not really used. */ 357+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
346+ HOWTO (R_MICROBLAZE_GPC_64, /* Type. */ 358+ HOWTO (R_MICROBLAZE_GPC_64, /* Type. */
347+ 0, /* Rightshift. */ 359+ 0, /* Rightshift. */
348+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 360+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
349+ 16, /* Bitsize. */ 361+ 16, /* Bitsize. */
350+ TRUE, /* PC_relative. */ 362+ true, /* PC_relative. */
351+ 0, /* Bitpos. */ 363+ 0, /* Bitpos. */
352+ complain_overflow_dont, /* Complain on overflow. */ 364+ complain_overflow_dont, /* Complain on overflow. */
353+ bfd_elf_generic_reloc, /* Special Function. */ 365+ bfd_elf_generic_reloc, /* Special Function. */
354+ "R_MICROBLAZE_GPC_64", /* Name. */ 366+ "R_MICROBLAZE_GPC_64", /* Name. */
355+ FALSE, /* Partial Inplace. */ 367+ false, /* Partial Inplace. */
356+ 0, /* Source Mask. */ 368+ 0, /* Source Mask. */
357+ 0x0000ffff, /* Dest Mask. */ 369+ 0x0000ffff, /* Dest Mask. */
358+ TRUE), /* PC relative offset? */ 370+ true), /* PC relative offset? */
359+ 371+
360 /* A 64 bit GOT relocation. Table-entry not really used. */ 372 /* A 64 bit GOT relocation. Table-entry not really used. */
361 HOWTO (R_MICROBLAZE_GOT_64, /* Type. */ 373 HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
362 0, /* Rightshift. */ 374 0, /* Rightshift. */
363@@ -562,6 +605,9 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, 375@@ -560,6 +603,9 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
364 case BFD_RELOC_NONE: 376 case BFD_RELOC_NONE:
365 microblaze_reloc = R_MICROBLAZE_NONE; 377 microblaze_reloc = R_MICROBLAZE_NONE;
366 break; 378 break;
@@ -370,7 +382,7 @@ index cfd70ae9178..9f9e13467d2 100644
370 case BFD_RELOC_MICROBLAZE_64_NONE: 382 case BFD_RELOC_MICROBLAZE_64_NONE:
371 microblaze_reloc = R_MICROBLAZE_64_NONE; 383 microblaze_reloc = R_MICROBLAZE_64_NONE;
372 break; 384 break;
373@@ -602,9 +648,15 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, 385@@ -600,9 +646,15 @@ microblaze_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
374 case BFD_RELOC_VTABLE_ENTRY: 386 case BFD_RELOC_VTABLE_ENTRY:
375 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY; 387 microblaze_reloc = R_MICROBLAZE_GNU_VTENTRY;
376 break; 388 break;
@@ -386,95 +398,7 @@ index cfd70ae9178..9f9e13467d2 100644
386 case BFD_RELOC_MICROBLAZE_64_GOT: 398 case BFD_RELOC_MICROBLAZE_64_GOT:
387 microblaze_reloc = R_MICROBLAZE_GOT_64; 399 microblaze_reloc = R_MICROBLAZE_GOT_64;
388 break; 400 break;
389@@ -715,87 +767,6 @@ microblaze_elf_is_local_label_name (bfd *abfd, const char *name) 401@@ -1507,9 +1559,9 @@ microblaze_elf_relocate_section (bfd *output_bfd,
390 return _bfd_elf_is_local_label_name (abfd, name);
391 }
392
393-/* Support for core dump NOTE sections. */
394-static bfd_boolean
395-microblaze_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
396-{
397- int offset;
398- unsigned int size;
399-
400- switch (note->descsz)
401- {
402- default:
403- return FALSE;
404-
405- case 228: /* Linux/MicroBlaze */
406- /* pr_cursig */
407- elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
408-
409- /* pr_pid */
410- elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
411-
412- /* pr_reg */
413- offset = 72;
414- size = 50 * 4;
415-
416- break;
417- }
418-
419- /* Make a ".reg/999" section. */
420- return _bfd_elfcore_make_pseudosection (abfd, ".reg",
421- size, note->descpos + offset);
422-}
423-
424-static bfd_boolean
425-microblaze_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
426-{
427- switch (note->descsz)
428- {
429- default:
430- return FALSE;
431-
432- case 128: /* Linux/MicroBlaze elf_prpsinfo */
433- elf_tdata (abfd)->core->program
434- = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
435- elf_tdata (abfd)->core->command
436- = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
437- }
438-
439- /* Note that for some reason, a spurious space is tacked
440- onto the end of the args in some (at least one anyway)
441- implementations, so strip it off if it exists. */
442-
443- {
444- char *command = elf_tdata (abfd)->core->command;
445- int n = strlen (command);
446-
447- if (0 < n && command[n - 1] == ' ')
448- command[n - 1] = '\0';
449- }
450-
451- return TRUE;
452-}
453-
454-/* The microblaze linker (like many others) needs to keep track of
455- the number of relocs that it decides to copy as dynamic relocs in
456- check_relocs for each symbol. This is so that it can later discard
457- them if they are found to be unnecessary. We store the information
458- in a field extending the regular ELF linker hash table. */
459-
460-struct elf32_mb_dyn_relocs
461-{
462- struct elf32_mb_dyn_relocs *next;
463-
464- /* The input section of the reloc. */
465- asection *sec;
466-
467- /* Total number of relocs copied for the input section. */
468- bfd_size_type count;
469-
470- /* Number of pc-relative relocs copied for the input section. */
471- bfd_size_type pc_count;
472-};
473-
474 /* ELF linker hash entry. */
475
476 struct elf32_mb_link_hash_entry
477@@ -1509,9 +1480,9 @@ microblaze_elf_relocate_section (bfd *output_bfd,
478 relocation += addend; 402 relocation += addend;
479 relocation -= dtprel_base(info); 403 relocation -= dtprel_base(info);
480 bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff, 404 bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
@@ -486,7 +410,7 @@ index cfd70ae9178..9f9e13467d2 100644
486 break; 410 break;
487 case (int) R_MICROBLAZE_TEXTREL_64: 411 case (int) R_MICROBLAZE_TEXTREL_64:
488 case (int) R_MICROBLAZE_TEXTREL_32_LO: 412 case (int) R_MICROBLAZE_TEXTREL_32_LO:
489@@ -1525,7 +1496,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, 413@@ -1523,7 +1575,7 @@ microblaze_elf_relocate_section (bfd *output_bfd,
490 if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0) 414 if (r_symndx == STN_UNDEF || (input_section->flags & SEC_ALLOC) == 0)
491 { 415 {
492 relocation += addend; 416 relocation += addend;
@@ -495,7 +419,7 @@ index cfd70ae9178..9f9e13467d2 100644
495 bfd_put_32 (input_bfd, relocation, contents + offset); 419 bfd_put_32 (input_bfd, relocation, contents + offset);
496 else 420 else
497 { 421 {
498@@ -1927,8 +1898,7 @@ microblaze_elf_relax_section (bfd *abfd, 422@@ -1925,8 +1977,7 @@ microblaze_elf_relax_section (bfd *abfd,
499 else 423 else
500 symval += irel->r_addend; 424 symval += irel->r_addend;
501 425
@@ -505,7 +429,7 @@ index cfd70ae9178..9f9e13467d2 100644
505 { 429 {
506 /* We can delete this instruction. */ 430 /* We can delete this instruction. */
507 sec->relax[sec->relax_count].addr = irel->r_offset; 431 sec->relax[sec->relax_count].addr = irel->r_offset;
508@@ -1992,21 +1962,51 @@ microblaze_elf_relax_section (bfd *abfd, 432@@ -1990,21 +2041,51 @@ microblaze_elf_relax_section (bfd *abfd,
509 irel->r_addend -= calc_fixup (irel->r_addend, 0, sec); 433 irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
510 } 434 }
511 break; 435 break;
@@ -559,7 +483,7 @@ index cfd70ae9178..9f9e13467d2 100644
559 case R_MICROBLAZE_64_NONE: 483 case R_MICROBLAZE_64_NONE:
560 { 484 {
561 /* This was a PC-relative 64-bit instruction that was 485 /* This was a PC-relative 64-bit instruction that was
562@@ -2017,8 +2017,8 @@ microblaze_elf_relax_section (bfd *abfd, 486@@ -2015,8 +2096,8 @@ microblaze_elf_relax_section (bfd *abfd,
563 sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec); 487 sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
564 efix = calc_fixup (target_address, 0, sec); 488 efix = calc_fixup (target_address, 0, sec);
565 irel->r_addend -= (efix - sfix); 489 irel->r_addend -= (efix - sfix);
@@ -570,7 +494,7 @@ index cfd70ae9178..9f9e13467d2 100644
570 } 494 }
571 break; 495 break;
572 } 496 }
573@@ -2048,9 +2048,50 @@ microblaze_elf_relax_section (bfd *abfd, 497@@ -2046,9 +2127,50 @@ microblaze_elf_relax_section (bfd *abfd,
574 irelscanend = irelocs + o->reloc_count; 498 irelscanend = irelocs + o->reloc_count;
575 for (irelscan = irelocs; irelscan < irelscanend; irelscan++) 499 for (irelscan = irelocs; irelscan < irelscanend; irelscan++)
576 { 500 {
@@ -624,7 +548,7 @@ index cfd70ae9178..9f9e13467d2 100644
624 548
625 /* Look at the reloc only if the value has been resolved. */ 549 /* Look at the reloc only if the value has been resolved. */
626 if (isym->st_shndx == shndx 550 if (isym->st_shndx == shndx
627@@ -2107,7 +2148,7 @@ microblaze_elf_relax_section (bfd *abfd, 551@@ -2105,7 +2227,7 @@ microblaze_elf_relax_section (bfd *abfd,
628 elf_section_data (o)->this_hdr.contents = ocontents; 552 elf_section_data (o)->this_hdr.contents = ocontents;
629 } 553 }
630 } 554 }
@@ -633,12 +557,12 @@ index cfd70ae9178..9f9e13467d2 100644
633 + isym->st_value, 557 + isym->st_value,
634 0, 558 0,
635 sec); 559 sec);
636@@ -3461,6 +3502,14 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd, 560@@ -3445,6 +3567,14 @@ microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
637 return TRUE; 561 return true;
638 } 562 }
639 563
640+ 564+
641+static bfd_boolean 565+static bool
642+elf_microblaze_object_p (bfd *abfd) 566+elf_microblaze_object_p (bfd *abfd)
643+{ 567+{
644+ /* Set the right machine number for an s390 elf32 file. */ 568+ /* Set the right machine number for an s390 elf32 file. */
@@ -648,7 +572,7 @@ index cfd70ae9178..9f9e13467d2 100644
648 /* Hook called by the linker routine which adds symbols from an object 572 /* Hook called by the linker routine which adds symbols from an object
649 file. We use it to put .comm items in .sbss, and not .bss. */ 573 file. We use it to put .comm items in .sbss, and not .bss. */
650 574
651@@ -3530,8 +3579,6 @@ microblaze_elf_add_symbol_hook (bfd *abfd, 575@@ -3514,8 +3644,6 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
652 #define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol 576 #define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol
653 #define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections 577 #define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
654 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook 578 #define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
@@ -660,13 +584,13 @@ index cfd70ae9178..9f9e13467d2 100644
660 #include "elf32-target.h" 584 #include "elf32-target.h"
661diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c 585diff --git a/bfd/elf64-microblaze.c b/bfd/elf64-microblaze.c
662new file mode 100755 586new file mode 100755
663index 00000000000..bf58b4b0a67 587index 00000000000..6cd9753a592
664--- /dev/null 588--- /dev/null
665+++ b/bfd/elf64-microblaze.c 589+++ b/bfd/elf64-microblaze.c
666@@ -0,0 +1,3711 @@ 590@@ -0,0 +1,3810 @@
667+/* Xilinx MicroBlaze-specific support for 32-bit ELF 591+/* Xilinx MicroBlaze-specific support for 32-bit ELF
668+ 592+
669+ Copyright (C) 2009-2016 Free Software Foundation, Inc. 593+ Copyright (C) 2009-2021 Free Software Foundation, Inc.
670+ 594+
671+ This file is part of BFD, the Binary File Descriptor library. 595+ This file is part of BFD, the Binary File Descriptor library.
672+ 596+
@@ -686,8 +610,6 @@ index 00000000000..bf58b4b0a67
686+ Boston, MA 02110-1301, USA. */ 610+ Boston, MA 02110-1301, USA. */
687+ 611+
688+ 612+
689+int dbg1 = 0;
690+
691+#include "sysdep.h" 613+#include "sysdep.h"
692+#include "bfd.h" 614+#include "bfd.h"
693+#include "bfdlink.h" 615+#include "bfdlink.h"
@@ -709,420 +631,450 @@ index 00000000000..bf58b4b0a67
709+{ 631+{
710+ /* This reloc does nothing. */ 632+ /* This reloc does nothing. */
711+ HOWTO (R_MICROBLAZE_NONE, /* Type. */ 633+ HOWTO (R_MICROBLAZE_NONE, /* Type. */
712+ 0, /* Rightshift. */ 634+ 0, /* Rightshift. */
713+ 3, /* Size (0 = byte, 1 = short, 2 = long). */ 635+ 0, /* Size. */
714+ 0, /* Bitsize. */ 636+ 0, /* Bitsize. */
715+ FALSE, /* PC_relative. */ 637+ false, /* PC_relative. */
716+ 0, /* Bitpos. */ 638+ 0, /* Bitpos. */
717+ complain_overflow_dont, /* Complain on overflow. */ 639+ complain_overflow_dont, /* Complain on overflow. */
718+ NULL, /* Special Function. */ 640+ NULL, /* Special Function. */
719+ "R_MICROBLAZE_NONE", /* Name. */ 641+ "R_MICROBLAZE_NONE", /* Name. */
720+ FALSE, /* Partial Inplace. */ 642+ false, /* Partial Inplace. */
721+ 0, /* Source Mask. */ 643+ 0, /* Source Mask. */
722+ 0, /* Dest Mask. */ 644+ 0, /* Dest Mask. */
723+ FALSE), /* PC relative offset? */ 645+ false), /* PC relative offset? */
724+ 646+
725+ /* A standard 32 bit relocation. */ 647+ /* A standard 32 bit relocation. */
726+ HOWTO (R_MICROBLAZE_32, /* Type. */ 648+ HOWTO (R_MICROBLAZE_32, /* Type. */
727+ 0, /* Rightshift. */ 649+ 0, /* Rightshift. */
728+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 650+ 4, /* Size. */
729+ 32, /* Bitsize. */ 651+ 32, /* Bitsize. */
730+ FALSE, /* PC_relative. */ 652+ false, /* PC_relative. */
731+ 0, /* Bitpos. */ 653+ 0, /* Bitpos. */
732+ complain_overflow_bitfield, /* Complain on overflow. */ 654+ complain_overflow_bitfield, /* Complain on overflow. */
733+ bfd_elf_generic_reloc,/* Special Function. */ 655+ bfd_elf_generic_reloc,/* Special Function. */
734+ "R_MICROBLAZE_32", /* Name. */ 656+ "R_MICROBLAZE_32", /* Name. */
735+ FALSE, /* Partial Inplace. */ 657+ false, /* Partial Inplace. */
736+ 0, /* Source Mask. */ 658+ 0, /* Source Mask. */
737+ 0xffffffff, /* Dest Mask. */ 659+ 0xffffffff, /* Dest Mask. */
738+ FALSE), /* PC relative offset? */ 660+ false), /* PC relative offset? */
739+ 661+
740+ /* A standard PCREL 32 bit relocation. */ 662+ /* A standard PCREL 32 bit relocation. */
741+ HOWTO (R_MICROBLAZE_32_PCREL,/* Type. */ 663+ HOWTO (R_MICROBLAZE_32_PCREL,/* Type. */
742+ 0, /* Rightshift. */ 664+ 0, /* Rightshift. */
743+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 665+ 4, /* Size. */
744+ 32, /* Bitsize. */ 666+ 32, /* Bitsize. */
745+ TRUE, /* PC_relative. */ 667+ true, /* PC_relative. */
746+ 0, /* Bitpos. */ 668+ 0, /* Bitpos. */
747+ complain_overflow_bitfield, /* Complain on overflow. */ 669+ complain_overflow_bitfield, /* Complain on overflow. */
748+ bfd_elf_generic_reloc,/* Special Function. */ 670+ bfd_elf_generic_reloc,/* Special Function. */
749+ "R_MICROBLAZE_32_PCREL", /* Name. */ 671+ "R_MICROBLAZE_32_PCREL", /* Name. */
750+ TRUE, /* Partial Inplace. */ 672+ true, /* Partial Inplace. */
751+ 0, /* Source Mask. */ 673+ 0, /* Source Mask. */
752+ 0xffffffff, /* Dest Mask. */ 674+ 0xffffffff, /* Dest Mask. */
753+ TRUE), /* PC relative offset? */ 675+ true), /* PC relative offset? */
754+ 676+
755+ /* A 64 bit PCREL relocation. Table-entry not really used. */ 677+ /* A 64 bit PCREL relocation. Table-entry not really used. */
756+ HOWTO (R_MICROBLAZE_64_PCREL,/* Type. */ 678+ HOWTO (R_MICROBLAZE_64_PCREL,/* Type. */
757+ 0, /* Rightshift. */ 679+ 0, /* Rightshift. */
758+ 4, /* Size (0 = byte, 1 = short, 2 = long). */ 680+ 4, /* Size. */
759+ 64, /* Bitsize. */ 681+ 16, /* Bitsize. */
760+ TRUE, /* PC_relative. */ 682+ true, /* PC_relative. */
761+ 0, /* Bitpos. */ 683+ 0, /* Bitpos. */
762+ complain_overflow_dont, /* Complain on overflow. */ 684+ complain_overflow_dont, /* Complain on overflow. */
763+ bfd_elf_generic_reloc,/* Special Function. */ 685+ bfd_elf_generic_reloc,/* Special Function. */
764+ "R_MICROBLAZE_64_PCREL", /* Name. */ 686+ "R_MICROBLAZE_64_PCREL", /* Name. */
765+ FALSE, /* Partial Inplace. */ 687+ false, /* Partial Inplace. */
766+ 0, /* Source Mask. */ 688+ 0, /* Source Mask. */
767+ 0x0000ffff, /* Dest Mask. */ 689+ 0x0000ffff, /* Dest Mask. */
768+ TRUE), /* PC relative offset? */ 690+ true), /* PC relative offset? */
769+ 691+
770+ /* The low half of a PCREL 32 bit relocation. */ 692+ /* The low half of a PCREL 32 bit relocation. */
771+ HOWTO (R_MICROBLAZE_32_PCREL_LO, /* Type. */ 693+ HOWTO (R_MICROBLAZE_32_PCREL_LO, /* Type. */
772+ 0, /* Rightshift. */ 694+ 0, /* Rightshift. */
773+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 695+ 4, /* Size. */
774+ 16, /* Bitsize. */ 696+ 16, /* Bitsize. */
775+ TRUE, /* PC_relative. */ 697+ true, /* PC_relative. */
776+ 0, /* Bitpos. */ 698+ 0, /* Bitpos. */
777+ complain_overflow_signed, /* Complain on overflow. */ 699+ complain_overflow_signed, /* Complain on overflow. */
778+ bfd_elf_generic_reloc, /* Special Function. */ 700+ bfd_elf_generic_reloc, /* Special Function. */
779+ "R_MICROBLAZE_32_PCREL_LO", /* Name. */ 701+ "R_MICROBLAZE_32_PCREL_LO", /* Name. */
780+ FALSE, /* Partial Inplace. */ 702+ false, /* Partial Inplace. */
781+ 0, /* Source Mask. */ 703+ 0, /* Source Mask. */
782+ 0x0000ffff, /* Dest Mask. */ 704+ 0x0000ffff, /* Dest Mask. */
783+ TRUE), /* PC relative offset? */ 705+ true), /* PC relative offset? */
784+ 706+
785+ /* A 64 bit relocation. Table entry not really used. */
786+ HOWTO (R_MICROBLAZE_IMML_64, /* Type. */ 707+ HOWTO (R_MICROBLAZE_IMML_64, /* Type. */
787+ 0, /* Rightshift. */ 708+ 0, /* Rightshift. */
788+ 4, /* Size (0 = byte, 1 = short, 2 = long). */ 709+ 4, /* Size (0 = byte, 1 = short, 2 = long). */
789+ 64, /* Bitsize. */ 710+ 64, /* Bitsize. */
790+ FALSE, /* PC_relative. */ 711+ false, /* PC_relative. */
791+ 0, /* Bitpos. */ 712+ 0, /* Bitpos. */
792+ complain_overflow_dont, /* Complain on overflow. */ 713+ complain_overflow_dont, /* Complain on overflow. */
793+ bfd_elf_generic_reloc,/* Special Function. */ 714+ bfd_elf_generic_reloc,/* Special Function. */
794+ "R_MICROBLAZE_IMML_64", /* Name. */ 715+ "R_MICROBLAZE_IMML_64", /* Name. */
795+ FALSE, /* Partial Inplace. */ 716+ false, /* Partial Inplace. */
796+ 0, /* Source Mask. */ 717+ 0, /* Source Mask. */
797+ 0xffffffffffffff, /* Dest Mask. */ 718+ 0xffffffffffffff, /* Dest Mask. */
798+ FALSE), /* PC relative offset? */ 719+ false), /* PC relative offset? */
799+ 720+
800+ /* A 64 bit relocation. Table entry not really used. */ 721+ /* A 64 bit relocation. Table entry not really used. */
801+ HOWTO (R_MICROBLAZE_64, /* Type. */ 722+ HOWTO (R_MICROBLAZE_64, /* Type. */
802+ 0, /* Rightshift. */ 723+ 0, /* Rightshift. */
803+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 724+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
804+ 16, /* Bitsize. */ 725+ 16, /* Bitsize. */
805+ FALSE, /* PC_relative. */ 726+ false, /* PC_relative. */
806+ 0, /* Bitpos. */ 727+ 0, /* Bitpos. */
807+ complain_overflow_dont, /* Complain on overflow. */ 728+ complain_overflow_dont, /* Complain on overflow. */
808+ bfd_elf_generic_reloc,/* Special Function. */ 729+ bfd_elf_generic_reloc,/* Special Function. */
809+ "R_MICROBLAZE_64", /* Name. */ 730+ "R_MICROBLAZE_64", /* Name. */
810+ FALSE, /* Partial Inplace. */ 731+ false, /* Partial Inplace. */
811+ 0, /* Source Mask. */ 732+ 0, /* Source Mask. */
812+ 0x0000ffff, /* Dest Mask. */ 733+ 0x0000ffff, /* Dest Mask. */
813+ FALSE), /* PC relative offset? */ 734+ false), /* PC relative offset? */
814+ 735+
815+ /* The low half of a 32 bit relocation. */ 736+ /* The low half of a 32 bit relocation. */
816+ HOWTO (R_MICROBLAZE_32_LO, /* Type. */ 737+ HOWTO (R_MICROBLAZE_32_LO, /* Type. */
817+ 0, /* Rightshift. */ 738+ 0, /* Rightshift. */
818+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 739+ 4, /* Size. */
819+ 16, /* Bitsize. */ 740+ 16, /* Bitsize. */
820+ FALSE, /* PC_relative. */ 741+ false, /* PC_relative. */
821+ 0, /* Bitpos. */ 742+ 0, /* Bitpos. */
822+ complain_overflow_signed, /* Complain on overflow. */ 743+ complain_overflow_signed, /* Complain on overflow. */
823+ bfd_elf_generic_reloc,/* Special Function. */ 744+ bfd_elf_generic_reloc,/* Special Function. */
824+ "R_MICROBLAZE_32_LO", /* Name. */ 745+ "R_MICROBLAZE_32_LO", /* Name. */
825+ FALSE, /* Partial Inplace. */ 746+ false, /* Partial Inplace. */
826+ 0, /* Source Mask. */ 747+ 0, /* Source Mask. */
827+ 0x0000ffff, /* Dest Mask. */ 748+ 0x0000ffff, /* Dest Mask. */
828+ FALSE), /* PC relative offset? */ 749+ false), /* PC relative offset? */
829+ 750+
830+ /* Read-only small data section relocation. */ 751+ /* Read-only small data section relocation. */
831+ HOWTO (R_MICROBLAZE_SRO32, /* Type. */ 752+ HOWTO (R_MICROBLAZE_SRO32, /* Type. */
832+ 0, /* Rightshift. */ 753+ 0, /* Rightshift. */
833+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 754+ 4, /* Size. */
834+ 16, /* Bitsize. */ 755+ 16, /* Bitsize. */
835+ FALSE, /* PC_relative. */ 756+ false, /* PC_relative. */
836+ 0, /* Bitpos. */ 757+ 0, /* Bitpos. */
837+ complain_overflow_bitfield, /* Complain on overflow. */ 758+ complain_overflow_bitfield, /* Complain on overflow. */
838+ bfd_elf_generic_reloc,/* Special Function. */ 759+ bfd_elf_generic_reloc,/* Special Function. */
839+ "R_MICROBLAZE_SRO32", /* Name. */ 760+ "R_MICROBLAZE_SRO32", /* Name. */
840+ FALSE, /* Partial Inplace. */ 761+ false, /* Partial Inplace. */
841+ 0, /* Source Mask. */ 762+ 0, /* Source Mask. */
842+ 0x0000ffff, /* Dest Mask. */ 763+ 0x0000ffff, /* Dest Mask. */
843+ FALSE), /* PC relative offset? */ 764+ false), /* PC relative offset? */
844+ 765+
845+ /* Read-write small data area relocation. */ 766+ /* Read-write small data area relocation. */
846+ HOWTO (R_MICROBLAZE_SRW32, /* Type. */ 767+ HOWTO (R_MICROBLAZE_SRW32, /* Type. */
768+ 0, /* Rightshift. */
769+ 4, /* Size. */
770+ 16, /* Bitsize. */
771+ false, /* PC_relative. */
772+ 0, /* Bitpos. */
773+ complain_overflow_bitfield, /* Complain on overflow. */
774+ bfd_elf_generic_reloc,/* Special Function. */
775+ "R_MICROBLAZE_SRW32", /* Name. */
776+ false, /* Partial Inplace. */
777+ 0, /* Source Mask. */
778+ 0x0000ffff, /* Dest Mask. */
779+ false), /* PC relative offset? */
780+
781+ /* This reloc does nothing. Used for relaxation. */
782+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
847+ 0, /* Rightshift. */ 783+ 0, /* Rightshift. */
848+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 784+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
849+ 16, /* Bitsize. */ 785+ 32, /* Bitsize. */
850+ FALSE, /* PC_relative. */ 786+ true, /* PC_relative. */
851+ 0, /* Bitpos. */ 787+ 0, /* Bitpos. */
852+ complain_overflow_bitfield, /* Complain on overflow. */
853+ bfd_elf_generic_reloc,/* Special Function. */
854+ "R_MICROBLAZE_SRW32", /* Name. */
855+ FALSE, /* Partial Inplace. */
856+ 0, /* Source Mask. */
857+ 0x0000ffff, /* Dest Mask. */
858+ FALSE), /* PC relative offset? */
859+
860+ HOWTO (R_MICROBLAZE_32_NONE, /* Type. */
861+ 0, /* Rightshift. */
862+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
863+ 32, /* Bitsize. */
864+ TRUE, /* PC_relative. */
865+ 0, /* Bitpos. */
866+ complain_overflow_bitfield, /* Complain on overflow. */ 788+ complain_overflow_bitfield, /* Complain on overflow. */
867+ NULL, /* Special Function. */ 789+ NULL, /* Special Function. */
868+ "R_MICROBLAZE_32_NONE",/* Name. */ 790+ "R_MICROBLAZE_32_NONE",/* Name. */
869+ FALSE, /* Partial Inplace. */ 791+ false, /* Partial Inplace. */
870+ 0, /* Source Mask. */ 792+ 0, /* Source Mask. */
871+ 0, /* Dest Mask. */ 793+ 0, /* Dest Mask. */
872+ FALSE), /* PC relative offset? */ 794+ false), /* PC relative offset? */
873+ 795+
874+ /* This reloc does nothing. Used for relaxation. */ 796+ /* This reloc does nothing. Used for relaxation. */
875+ HOWTO (R_MICROBLAZE_64_NONE, /* Type. */ 797+ HOWTO (R_MICROBLAZE_64_NONE, /* Type. */
876+ 0, /* Rightshift. */ 798+ 0, /* Rightshift. */
877+ 3, /* Size (0 = byte, 1 = short, 2 = long). */ 799+ 0, /* Size. */
878+ 0, /* Bitsize. */ 800+ 0, /* Bitsize. */
879+ TRUE, /* PC_relative. */ 801+ true, /* PC_relative. */
880+ 0, /* Bitpos. */ 802+ 0, /* Bitpos. */
881+ complain_overflow_dont, /* Complain on overflow. */ 803+ complain_overflow_dont, /* Complain on overflow. */
882+ NULL, /* Special Function. */ 804+ NULL, /* Special Function. */
883+ "R_MICROBLAZE_64_NONE",/* Name. */ 805+ "R_MICROBLAZE_64_NONE",/* Name. */
884+ FALSE, /* Partial Inplace. */ 806+ false, /* Partial Inplace. */
885+ 0, /* Source Mask. */ 807+ 0, /* Source Mask. */
886+ 0, /* Dest Mask. */ 808+ 0, /* Dest Mask. */
887+ FALSE), /* PC relative offset? */ 809+ false), /* PC relative offset? */
888+ 810+
889+ /* Symbol Op Symbol relocation. */ 811+ /* Symbol Op Symbol relocation. */
890+ HOWTO (R_MICROBLAZE_32_SYM_OP_SYM, /* Type. */ 812+ HOWTO (R_MICROBLAZE_32_SYM_OP_SYM, /* Type. */
891+ 0, /* Rightshift. */ 813+ 0, /* Rightshift. */
892+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 814+ 4, /* Size. */
893+ 32, /* Bitsize. */ 815+ 32, /* Bitsize. */
894+ FALSE, /* PC_relative. */ 816+ false, /* PC_relative. */
895+ 0, /* Bitpos. */ 817+ 0, /* Bitpos. */
896+ complain_overflow_bitfield, /* Complain on overflow. */ 818+ complain_overflow_bitfield, /* Complain on overflow. */
897+ bfd_elf_generic_reloc,/* Special Function. */ 819+ bfd_elf_generic_reloc,/* Special Function. */
898+ "R_MICROBLAZE_32_SYM_OP_SYM", /* Name. */ 820+ "R_MICROBLAZE_32_SYM_OP_SYM", /* Name. */
899+ FALSE, /* Partial Inplace. */ 821+ false, /* Partial Inplace. */
900+ 0, /* Source Mask. */ 822+ 0, /* Source Mask. */
901+ 0xffffffff, /* Dest Mask. */ 823+ 0xffffffff, /* Dest Mask. */
902+ FALSE), /* PC relative offset? */ 824+ false), /* PC relative offset? */
903+ 825+
904+ /* GNU extension to record C++ vtable hierarchy. */ 826+ /* GNU extension to record C++ vtable hierarchy. */
905+ HOWTO (R_MICROBLAZE_GNU_VTINHERIT, /* Type. */ 827+ HOWTO (R_MICROBLAZE_GNU_VTINHERIT, /* Type. */
906+ 0, /* Rightshift. */ 828+ 0, /* Rightshift. */
907+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 829+ 4, /* Size. */
908+ 0, /* Bitsize. */ 830+ 0, /* Bitsize. */
909+ FALSE, /* PC_relative. */ 831+ false, /* PC_relative. */
910+ 0, /* Bitpos. */ 832+ 0, /* Bitpos. */
911+ complain_overflow_dont,/* Complain on overflow. */ 833+ complain_overflow_dont,/* Complain on overflow. */
912+ NULL, /* Special Function. */ 834+ NULL, /* Special Function. */
913+ "R_MICROBLAZE_GNU_VTINHERIT", /* Name. */ 835+ "R_MICROBLAZE_GNU_VTINHERIT", /* Name. */
914+ FALSE, /* Partial Inplace. */ 836+ false, /* Partial Inplace. */
915+ 0, /* Source Mask. */ 837+ 0, /* Source Mask. */
916+ 0, /* Dest Mask. */ 838+ 0, /* Dest Mask. */
917+ FALSE), /* PC relative offset? */ 839+ false), /* PC relative offset? */
918+ 840+
919+ /* GNU extension to record C++ vtable member usage. */ 841+ /* GNU extension to record C++ vtable member usage. */
920+ HOWTO (R_MICROBLAZE_GNU_VTENTRY, /* Type. */ 842+ HOWTO (R_MICROBLAZE_GNU_VTENTRY, /* Type. */
921+ 0, /* Rightshift. */ 843+ 0, /* Rightshift. */
922+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 844+ 4, /* Size. */
923+ 0, /* Bitsize. */ 845+ 0, /* Bitsize. */
924+ FALSE, /* PC_relative. */ 846+ false, /* PC_relative. */
925+ 0, /* Bitpos. */ 847+ 0, /* Bitpos. */
926+ complain_overflow_dont,/* Complain on overflow. */ 848+ complain_overflow_dont,/* Complain on overflow. */
927+ _bfd_elf_rel_vtable_reloc_fn, /* Special Function. */ 849+ _bfd_elf_rel_vtable_reloc_fn, /* Special Function. */
928+ "R_MICROBLAZE_GNU_VTENTRY", /* Name. */ 850+ "R_MICROBLAZE_GNU_VTENTRY", /* Name. */
929+ FALSE, /* Partial Inplace. */ 851+ false, /* Partial Inplace. */
930+ 0, /* Source Mask. */ 852+ 0, /* Source Mask. */
931+ 0, /* Dest Mask. */ 853+ 0, /* Dest Mask. */
932+ FALSE), /* PC relative offset? */ 854+ false), /* PC relative offset? */
933+ 855+
934+ /* A 64 bit GOTPC relocation. Table-entry not really used. */ 856+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
935+ HOWTO (R_MICROBLAZE_GOTPC_64, /* Type. */ 857+ HOWTO (R_MICROBLAZE_GOTPC_64, /* Type. */
936+ 0, /* Rightshift. */ 858+ 0, /* Rightshift. */
937+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 859+ 4, /* Size. */
938+ 16, /* Bitsize. */ 860+ 16, /* Bitsize. */
939+ TRUE, /* PC_relative. */ 861+ true, /* PC_relative. */
940+ 0, /* Bitpos. */ 862+ 0, /* Bitpos. */
941+ complain_overflow_dont, /* Complain on overflow. */ 863+ complain_overflow_dont, /* Complain on overflow. */
942+ bfd_elf_generic_reloc, /* Special Function. */ 864+ bfd_elf_generic_reloc, /* Special Function. */
943+ "R_MICROBLAZE_GOTPC_64", /* Name. */ 865+ "R_MICROBLAZE_GOTPC_64", /* Name. */
944+ FALSE, /* Partial Inplace. */ 866+ false, /* Partial Inplace. */
945+ 0, /* Source Mask. */ 867+ 0, /* Source Mask. */
946+ 0x0000ffff, /* Dest Mask. */ 868+ 0x0000ffff, /* Dest Mask. */
947+ TRUE), /* PC relative offset? */ 869+ true), /* PC relative offset? */
870+
871+ /* A 64 bit TEXTPCREL relocation. Table-entry not really used. */
872+ HOWTO (R_MICROBLAZE_TEXTPCREL_64, /* Type. */
873+ 0, /* Rightshift. */
874+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
875+ 16, /* Bitsize. */
876+ true, /* PC_relative. */
877+ 0, /* Bitpos. */
878+ complain_overflow_dont, /* Complain on overflow. */
879+ bfd_elf_generic_reloc, /* Special Function. */
880+ "R_MICROBLAZE_TEXTPCREL_64", /* Name. */
881+ false, /* Partial Inplace. */
882+ 0, /* Source Mask. */
883+ 0x0000ffff, /* Dest Mask. */
884+ true), /* PC relative offset? */
948+ 885+
949+ /* A 64 bit GOTPC relocation. Table-entry not really used. */ 886+ /* A 64 bit GOTPC relocation. Table-entry not really used. */
950+ HOWTO (R_MICROBLAZE_GPC_64, /* Type. */ 887+ HOWTO (R_MICROBLAZE_GPC_64, /* Type. */
951+ 0, /* Rightshift. */ 888+ 0, /* Rightshift. */
952+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 889+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
953+ 16, /* Bitsize. */ 890+ 16, /* Bitsize. */
954+ TRUE, /* PC_relative. */ 891+ true, /* PC_relative. */
955+ 0, /* Bitpos. */ 892+ 0, /* Bitpos. */
956+ complain_overflow_dont, /* Complain on overflow. */ 893+ complain_overflow_dont, /* Complain on overflow. */
957+ bfd_elf_generic_reloc, /* Special Function. */ 894+ bfd_elf_generic_reloc, /* Special Function. */
958+ "R_MICROBLAZE_GPC_64", /* Name. */ 895+ "R_MICROBLAZE_GPC_64", /* Name. */
959+ FALSE, /* Partial Inplace. */ 896+ false, /* Partial Inplace. */
960+ 0, /* Source Mask. */ 897+ 0, /* Source Mask. */
961+ 0x0000ffff, /* Dest Mask. */ 898+ 0x0000ffff, /* Dest Mask. */
962+ TRUE), /* PC relative offset? */ 899+ true), /* PC relative offset? */
963+ 900+
964+ /* A 64 bit GOT relocation. Table-entry not really used. */ 901+ /* A 64 bit GOT relocation. Table-entry not really used. */
965+ HOWTO (R_MICROBLAZE_GOT_64, /* Type. */ 902+ HOWTO (R_MICROBLAZE_GOT_64, /* Type. */
966+ 0, /* Rightshift. */ 903+ 0, /* Rightshift. */
967+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 904+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
968+ 16, /* Bitsize. */ 905+ 16, /* Bitsize. */
969+ FALSE, /* PC_relative. */ 906+ false, /* PC_relative. */
970+ 0, /* Bitpos. */ 907+ 0, /* Bitpos. */
971+ complain_overflow_dont, /* Complain on overflow. */ 908+ complain_overflow_dont, /* Complain on overflow. */
972+ bfd_elf_generic_reloc,/* Special Function. */ 909+ bfd_elf_generic_reloc,/* Special Function. */
973+ "R_MICROBLAZE_GOT_64",/* Name. */ 910+ "R_MICROBLAZE_GOT_64",/* Name. */
974+ FALSE, /* Partial Inplace. */ 911+ false, /* Partial Inplace. */
975+ 0, /* Source Mask. */ 912+ 0, /* Source Mask. */
976+ 0x0000ffff, /* Dest Mask. */ 913+ 0x0000ffff, /* Dest Mask. */
977+ FALSE), /* PC relative offset? */ 914+ false), /* PC relative offset? */
915+
916+ /* A 64 bit TEXTREL relocation. Table-entry not really used. */
917+ HOWTO (R_MICROBLAZE_TEXTREL_64, /* Type. */
918+ 0, /* Rightshift. */
919+ 2, /* Size (0 = byte, 1 = short, 2 = long). */
920+ 16, /* Bitsize. */
921+ false, /* PC_relative. */
922+ 0, /* Bitpos. */
923+ complain_overflow_dont, /* Complain on overflow. */
924+ bfd_elf_generic_reloc,/* Special Function. */
925+ "R_MICROBLAZE_TEXTREL_64",/* Name. */
926+ false, /* Partial Inplace. */
927+ 0, /* Source Mask. */
928+ 0x0000ffff, /* Dest Mask. */
929+ false), /* PC relative offset? */
978+ 930+
979+ /* A 64 bit PLT relocation. Table-entry not really used. */ 931+ /* A 64 bit PLT relocation. Table-entry not really used. */
980+ HOWTO (R_MICROBLAZE_PLT_64, /* Type. */ 932+ HOWTO (R_MICROBLAZE_PLT_64, /* Type. */
981+ 0, /* Rightshift. */ 933+ 0, /* Rightshift. */
982+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 934+ 4, /* Size. */
983+ 16, /* Bitsize. */ 935+ 16, /* Bitsize. */
984+ TRUE, /* PC_relative. */ 936+ true, /* PC_relative. */
985+ 0, /* Bitpos. */ 937+ 0, /* Bitpos. */
986+ complain_overflow_dont, /* Complain on overflow. */ 938+ complain_overflow_dont, /* Complain on overflow. */
987+ bfd_elf_generic_reloc,/* Special Function. */ 939+ bfd_elf_generic_reloc,/* Special Function. */
988+ "R_MICROBLAZE_PLT_64",/* Name. */ 940+ "R_MICROBLAZE_PLT_64",/* Name. */
989+ FALSE, /* Partial Inplace. */ 941+ false, /* Partial Inplace. */
990+ 0, /* Source Mask. */ 942+ 0, /* Source Mask. */
991+ 0x0000ffff, /* Dest Mask. */ 943+ 0x0000ffff, /* Dest Mask. */
992+ TRUE), /* PC relative offset? */ 944+ true), /* PC relative offset? */
993+ 945+
994+ /* Table-entry not really used. */ 946+ /* Table-entry not really used. */
995+ HOWTO (R_MICROBLAZE_REL, /* Type. */ 947+ HOWTO (R_MICROBLAZE_REL, /* Type. */
996+ 0, /* Rightshift. */ 948+ 0, /* Rightshift. */
997+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 949+ 4, /* Size. */
998+ 16, /* Bitsize. */ 950+ 16, /* Bitsize. */
999+ TRUE, /* PC_relative. */ 951+ true, /* PC_relative. */
1000+ 0, /* Bitpos. */ 952+ 0, /* Bitpos. */
1001+ complain_overflow_dont, /* Complain on overflow. */ 953+ complain_overflow_dont, /* Complain on overflow. */
1002+ bfd_elf_generic_reloc,/* Special Function. */ 954+ bfd_elf_generic_reloc,/* Special Function. */
1003+ "R_MICROBLAZE_REL", /* Name. */ 955+ "R_MICROBLAZE_REL", /* Name. */
1004+ FALSE, /* Partial Inplace. */ 956+ false, /* Partial Inplace. */
1005+ 0, /* Source Mask. */ 957+ 0, /* Source Mask. */
1006+ 0x0000ffff, /* Dest Mask. */ 958+ 0x0000ffff, /* Dest Mask. */
1007+ TRUE), /* PC relative offset? */ 959+ true), /* PC relative offset? */
1008+ 960+
1009+ /* Table-entry not really used. */ 961+ /* Table-entry not really used. */
1010+ HOWTO (R_MICROBLAZE_JUMP_SLOT,/* Type. */ 962+ HOWTO (R_MICROBLAZE_JUMP_SLOT,/* Type. */
1011+ 0, /* Rightshift. */ 963+ 0, /* Rightshift. */
1012+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 964+ 4, /* Size. */
1013+ 16, /* Bitsize. */ 965+ 16, /* Bitsize. */
1014+ TRUE, /* PC_relative. */ 966+ true, /* PC_relative. */
1015+ 0, /* Bitpos. */ 967+ 0, /* Bitpos. */
1016+ complain_overflow_dont, /* Complain on overflow. */ 968+ complain_overflow_dont, /* Complain on overflow. */
1017+ bfd_elf_generic_reloc,/* Special Function. */ 969+ bfd_elf_generic_reloc,/* Special Function. */
1018+ "R_MICROBLAZE_JUMP_SLOT", /* Name. */ 970+ "R_MICROBLAZE_JUMP_SLOT", /* Name. */
1019+ FALSE, /* Partial Inplace. */ 971+ false, /* Partial Inplace. */
1020+ 0, /* Source Mask. */ 972+ 0, /* Source Mask. */
1021+ 0x0000ffff, /* Dest Mask. */ 973+ 0x0000ffff, /* Dest Mask. */
1022+ TRUE), /* PC relative offset? */ 974+ true), /* PC relative offset? */
1023+ 975+
1024+ /* Table-entry not really used. */ 976+ /* Table-entry not really used. */
1025+ HOWTO (R_MICROBLAZE_GLOB_DAT,/* Type. */ 977+ HOWTO (R_MICROBLAZE_GLOB_DAT,/* Type. */
1026+ 0, /* Rightshift. */ 978+ 0, /* Rightshift. */
1027+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 979+ 4, /* Size. */
1028+ 16, /* Bitsize. */ 980+ 16, /* Bitsize. */
1029+ TRUE, /* PC_relative. */ 981+ true, /* PC_relative. */
1030+ 0, /* Bitpos. */ 982+ 0, /* Bitpos. */
1031+ complain_overflow_dont, /* Complain on overflow. */ 983+ complain_overflow_dont, /* Complain on overflow. */
1032+ bfd_elf_generic_reloc,/* Special Function. */ 984+ bfd_elf_generic_reloc,/* Special Function. */
1033+ "R_MICROBLAZE_GLOB_DAT", /* Name. */ 985+ "R_MICROBLAZE_GLOB_DAT", /* Name. */
1034+ FALSE, /* Partial Inplace. */ 986+ false, /* Partial Inplace. */
1035+ 0, /* Source Mask. */ 987+ 0, /* Source Mask. */
1036+ 0x0000ffff, /* Dest Mask. */ 988+ 0x0000ffff, /* Dest Mask. */
1037+ TRUE), /* PC relative offset? */ 989+ true), /* PC relative offset? */
1038+ 990+
1039+ /* A 64 bit GOT relative relocation. Table-entry not really used. */ 991+ /* A 64 bit GOT relative relocation. Table-entry not really used. */
1040+ HOWTO (R_MICROBLAZE_GOTOFF_64, /* Type. */ 992+ HOWTO (R_MICROBLAZE_GOTOFF_64, /* Type. */
1041+ 0, /* Rightshift. */ 993+ 0, /* Rightshift. */
1042+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 994+ 4, /* Size. */
1043+ 16, /* Bitsize. */ 995+ 16, /* Bitsize. */
1044+ FALSE, /* PC_relative. */ 996+ false, /* PC_relative. */
1045+ 0, /* Bitpos. */ 997+ 0, /* Bitpos. */
1046+ complain_overflow_dont, /* Complain on overflow. */ 998+ complain_overflow_dont, /* Complain on overflow. */
1047+ bfd_elf_generic_reloc,/* Special Function. */ 999+ bfd_elf_generic_reloc,/* Special Function. */
1048+ "R_MICROBLAZE_GOTOFF_64", /* Name. */ 1000+ "R_MICROBLAZE_GOTOFF_64", /* Name. */
1049+ FALSE, /* Partial Inplace. */ 1001+ false, /* Partial Inplace. */
1050+ 0, /* Source Mask. */ 1002+ 0, /* Source Mask. */
1051+ 0x0000ffff, /* Dest Mask. */ 1003+ 0x0000ffff, /* Dest Mask. */
1052+ FALSE), /* PC relative offset? */ 1004+ false), /* PC relative offset? */
1053+ 1005+
1054+ /* A 32 bit GOT relative relocation. Table-entry not really used. */ 1006+ /* A 32 bit GOT relative relocation. Table-entry not really used. */
1055+ HOWTO (R_MICROBLAZE_GOTOFF_32, /* Type. */ 1007+ HOWTO (R_MICROBLAZE_GOTOFF_32, /* Type. */
1056+ 0, /* Rightshift. */ 1008+ 0, /* Rightshift. */
1057+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 1009+ 4, /* Size. */
1058+ 16, /* Bitsize. */ 1010+ 16, /* Bitsize. */
1059+ FALSE, /* PC_relative. */ 1011+ false, /* PC_relative. */
1060+ 0, /* Bitpos. */ 1012+ 0, /* Bitpos. */
1061+ complain_overflow_dont, /* Complain on overflow. */ 1013+ complain_overflow_dont, /* Complain on overflow. */
1062+ bfd_elf_generic_reloc, /* Special Function. */ 1014+ bfd_elf_generic_reloc, /* Special Function. */
1063+ "R_MICROBLAZE_GOTOFF_32", /* Name. */ 1015+ "R_MICROBLAZE_GOTOFF_32", /* Name. */
1064+ FALSE, /* Partial Inplace. */ 1016+ false, /* Partial Inplace. */
1065+ 0, /* Source Mask. */ 1017+ 0, /* Source Mask. */
1066+ 0x0000ffff, /* Dest Mask. */ 1018+ 0x0000ffff, /* Dest Mask. */
1067+ FALSE), /* PC relative offset? */ 1019+ false), /* PC relative offset? */
1068+ 1020+
1069+ /* COPY relocation. Table-entry not really used. */ 1021+ /* COPY relocation. Table-entry not really used. */
1070+ HOWTO (R_MICROBLAZE_COPY, /* Type. */ 1022+ HOWTO (R_MICROBLAZE_COPY, /* Type. */
1071+ 0, /* Rightshift. */ 1023+ 0, /* Rightshift. */
1072+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ 1024+ 4, /* Size. */
1073+ 16, /* Bitsize. */ 1025+ 16, /* Bitsize. */
1074+ FALSE, /* PC_relative. */ 1026+ false, /* PC_relative. */
1075+ 0, /* Bitpos. */ 1027+ 0, /* Bitpos. */
1076+ complain_overflow_dont, /* Complain on overflow. */ 1028+ complain_overflow_dont, /* Complain on overflow. */
1077+ bfd_elf_generic_reloc,/* Special Function. */ 1029+ bfd_elf_generic_reloc,/* Special Function. */
1078+ "R_MICROBLAZE_COPY", /* Name. */ 1030+ "R_MICROBLAZE_COPY", /* Name. */
1079+ FALSE, /* Partial Inplace. */ 1031+ false, /* Partial Inplace. */
1080+ 0, /* Source Mask. */ 1032+ 0, /* Source Mask. */
1081+ 0x0000ffff, /* Dest Mask. */ 1033+ 0x0000ffff, /* Dest Mask. */
1082+ FALSE), /* PC relative offset? */ 1034+ false), /* PC relative offset? */
1083+ 1035+
1084+ /* Marker relocs for TLS. */ 1036+ /* Marker relocs for TLS. */
1085+ HOWTO (R_MICROBLAZE_TLS, 1037+ HOWTO (R_MICROBLAZE_TLS,
1086+ 0, /* rightshift */ 1038+ 0, /* rightshift */
1087+ 2, /* size (0 = byte, 1 = short, 2 = long) */ 1039+ 2, /* size (0 = byte, 1 = short, 2 = long) */
1088+ 32, /* bitsize */ 1040+ 32, /* bitsize */
1089+ FALSE, /* pc_relative */ 1041+ false, /* pc_relative */
1090+ 0, /* bitpos */ 1042+ 0, /* bitpos */
1091+ complain_overflow_dont, /* complain_on_overflow */ 1043+ complain_overflow_dont, /* complain_on_overflow */
1092+ bfd_elf_generic_reloc, /* special_function */ 1044+ bfd_elf_generic_reloc, /* special_function */
1093+ "R_MICROBLAZE_TLS", /* name */ 1045+ "R_MICROBLAZE_TLS", /* name */
1094+ FALSE, /* partial_inplace */ 1046+ false, /* partial_inplace */
1095+ 0, /* src_mask */ 1047+ 0, /* src_mask */
1096+ 0x0000ffff, /* dst_mask */ 1048+ 0x0000ffff, /* dst_mask */
1097+ FALSE), /* pcrel_offset */ 1049+ false), /* pcrel_offset */
1098+ 1050+
1099+ HOWTO (R_MICROBLAZE_TLSGD, 1051+ HOWTO (R_MICROBLAZE_TLSGD,
1100+ 0, /* rightshift */ 1052+ 0, /* rightshift */
1101+ 2, /* size (0 = byte, 1 = short, 2 = long) */ 1053+ 4, /* size */
1102+ 32, /* bitsize */ 1054+ 32, /* bitsize */
1103+ FALSE, /* pc_relative */ 1055+ false, /* pc_relative */
1104+ 0, /* bitpos */ 1056+ 0, /* bitpos */
1105+ complain_overflow_dont, /* complain_on_overflow */ 1057+ complain_overflow_dont, /* complain_on_overflow */
1106+ bfd_elf_generic_reloc, /* special_function */ 1058+ bfd_elf_generic_reloc, /* special_function */
1107+ "R_MICROBLAZE_TLSGD", /* name */ 1059+ "R_MICROBLAZE_TLSGD", /* name */
1108+ FALSE, /* partial_inplace */ 1060+ false, /* partial_inplace */
1109+ 0, /* src_mask */ 1061+ 0, /* src_mask */
1110+ 0x0000ffff, /* dst_mask */ 1062+ 0x0000ffff, /* dst_mask */
1111+ FALSE), /* pcrel_offset */ 1063+ false), /* pcrel_offset */
1112+ 1064+
1113+ HOWTO (R_MICROBLAZE_TLSLD, 1065+ HOWTO (R_MICROBLAZE_TLSLD,
1114+ 0, /* rightshift */ 1066+ 0, /* rightshift */
1115+ 2, /* size (0 = byte, 1 = short, 2 = long) */ 1067+ 2, /* size (0 = byte, 1 = short, 2 = long) */
1116+ 32, /* bitsize */ 1068+ 32, /* bitsize */
1117+ FALSE, /* pc_relative */ 1069+ false, /* pc_relative */
1118+ 0, /* bitpos */ 1070+ 0, /* bitpos */
1119+ complain_overflow_dont, /* complain_on_overflow */ 1071+ complain_overflow_dont, /* complain_on_overflow */
1120+ bfd_elf_generic_reloc, /* special_function */ 1072+ bfd_elf_generic_reloc, /* special_function */
1121+ "R_MICROBLAZE_TLSLD", /* name */ 1073+ "R_MICROBLAZE_TLSLD", /* name */
1122+ FALSE, /* partial_inplace */ 1074+ false, /* partial_inplace */
1123+ 0, /* src_mask */ 1075+ 0, /* src_mask */
1124+ 0x0000ffff, /* dst_mask */ 1076+ 0x0000ffff, /* dst_mask */
1125+ FALSE), /* pcrel_offset */ 1077+ false), /* pcrel_offset */
1126+ 1078+
1127+ /* Computes the load module index of the load module that contains the 1079+ /* Computes the load module index of the load module that contains the
1128+ definition of its TLS sym. */ 1080+ definition of its TLS sym. */
@@ -1130,81 +1082,81 @@ index 00000000000..bf58b4b0a67
1130+ 0, /* rightshift */ 1082+ 0, /* rightshift */
1131+ 2, /* size (0 = byte, 1 = short, 2 = long) */ 1083+ 2, /* size (0 = byte, 1 = short, 2 = long) */
1132+ 32, /* bitsize */ 1084+ 32, /* bitsize */
1133+ FALSE, /* pc_relative */ 1085+ false, /* pc_relative */
1134+ 0, /* bitpos */ 1086+ 0, /* bitpos */
1135+ complain_overflow_dont, /* complain_on_overflow */ 1087+ complain_overflow_dont, /* complain_on_overflow */
1136+ bfd_elf_generic_reloc, /* special_function */ 1088+ bfd_elf_generic_reloc, /* special_function */
1137+ "R_MICROBLAZE_TLSDTPMOD32", /* name */ 1089+ "R_MICROBLAZE_TLSDTPMOD32", /* name */
1138+ FALSE, /* partial_inplace */ 1090+ false, /* partial_inplace */
1139+ 0, /* src_mask */ 1091+ 0, /* src_mask */
1140+ 0x0000ffff, /* dst_mask */ 1092+ 0x0000ffff, /* dst_mask */
1141+ FALSE), /* pcrel_offset */ 1093+ false), /* pcrel_offset */
1142+ 1094+
1143+ /* Computes a dtv-relative displacement, the difference between the value 1095+ /* Computes a dtv-relative displacement, the difference between the value
1144+ of sym+add and the base address of the thread-local storage block that 1096+ of sym+add and the base address of the thread-local storage block that
1145+ contains the definition of sym, minus 0x8000. Used for initializing GOT */ 1097+ contains the definition of sym, minus 0x8000. Used for initializing GOT */
1146+ HOWTO (R_MICROBLAZE_TLSDTPREL32, 1098+ HOWTO (R_MICROBLAZE_TLSDTPREL32,
1147+ 0, /* rightshift */ 1099+ 0, /* rightshift */
1148+ 2, /* size (0 = byte, 1 = short, 2 = long) */ 1100+ 4, /* size */
1149+ 32, /* bitsize */ 1101+ 32, /* bitsize */
1150+ FALSE, /* pc_relative */ 1102+ false, /* pc_relative */
1151+ 0, /* bitpos */ 1103+ 0, /* bitpos */
1152+ complain_overflow_dont, /* complain_on_overflow */ 1104+ complain_overflow_dont, /* complain_on_overflow */
1153+ bfd_elf_generic_reloc, /* special_function */ 1105+ bfd_elf_generic_reloc, /* special_function */
1154+ "R_MICROBLAZE_TLSDTPREL32", /* name */ 1106+ "R_MICROBLAZE_TLSDTPREL32", /* name */
1155+ FALSE, /* partial_inplace */ 1107+ false, /* partial_inplace */
1156+ 0, /* src_mask */ 1108+ 0, /* src_mask */
1157+ 0x0000ffff, /* dst_mask */ 1109+ 0x0000ffff, /* dst_mask */
1158+ FALSE), /* pcrel_offset */ 1110+ false), /* pcrel_offset */
1159+ 1111+
1160+ /* Computes a dtv-relative displacement, the difference between the value 1112+ /* Computes a dtv-relative displacement, the difference between the value
1161+ of sym+add and the base address of the thread-local storage block that 1113+ of sym+add and the base address of the thread-local storage block that
1162+ contains the definition of sym, minus 0x8000. */ 1114+ contains the definition of sym, minus 0x8000. */
1163+ HOWTO (R_MICROBLAZE_TLSDTPREL64, 1115+ HOWTO (R_MICROBLAZE_TLSDTPREL64,
1164+ 0, /* rightshift */ 1116+ 0, /* rightshift */
1165+ 2, /* size (0 = byte, 1 = short, 2 = long) */ 1117+ 4, /* size */
1166+ 32, /* bitsize */ 1118+ 32, /* bitsize */
1167+ FALSE, /* pc_relative */ 1119+ false, /* pc_relative */
1168+ 0, /* bitpos */ 1120+ 0, /* bitpos */
1169+ complain_overflow_dont, /* complain_on_overflow */ 1121+ complain_overflow_dont, /* complain_on_overflow */
1170+ bfd_elf_generic_reloc, /* special_function */ 1122+ bfd_elf_generic_reloc, /* special_function */
1171+ "R_MICROBLAZE_TLSDTPREL64", /* name */ 1123+ "R_MICROBLAZE_TLSDTPREL64", /* name */
1172+ FALSE, /* partial_inplace */ 1124+ false, /* partial_inplace */
1173+ 0, /* src_mask */ 1125+ 0, /* src_mask */
1174+ 0x0000ffff, /* dst_mask */ 1126+ 0x0000ffff, /* dst_mask */
1175+ FALSE), /* pcrel_offset */ 1127+ false), /* pcrel_offset */
1176+ 1128+
1177+ /* Computes a tp-relative displacement, the difference between the value of 1129+ /* Computes a tp-relative displacement, the difference between the value of
1178+ sym+add and the value of the thread pointer (r13). */ 1130+ sym+add and the value of the thread pointer (r13). */
1179+ HOWTO (R_MICROBLAZE_TLSGOTTPREL32, 1131+ HOWTO (R_MICROBLAZE_TLSGOTTPREL32,
1180+ 0, /* rightshift */ 1132+ 0, /* rightshift */
1181+ 2, /* size (0 = byte, 1 = short, 2 = long) */ 1133+ 4, /* size */
1182+ 32, /* bitsize */ 1134+ 32, /* bitsize */
1183+ FALSE, /* pc_relative */ 1135+ false, /* pc_relative */
1184+ 0, /* bitpos */ 1136+ 0, /* bitpos */
1185+ complain_overflow_dont, /* complain_on_overflow */ 1137+ complain_overflow_dont, /* complain_on_overflow */
1186+ bfd_elf_generic_reloc, /* special_function */ 1138+ bfd_elf_generic_reloc, /* special_function */
1187+ "R_MICROBLAZE_TLSGOTTPREL32", /* name */ 1139+ "R_MICROBLAZE_TLSGOTTPREL32", /* name */
1188+ FALSE, /* partial_inplace */ 1140+ false, /* partial_inplace */
1189+ 0, /* src_mask */ 1141+ 0, /* src_mask */
1190+ 0x0000ffff, /* dst_mask */ 1142+ 0x0000ffff, /* dst_mask */
1191+ FALSE), /* pcrel_offset */ 1143+ false), /* pcrel_offset */
1192+ 1144+
1193+ /* Computes a tp-relative displacement, the difference between the value of 1145+ /* Computes a tp-relative displacement, the difference between the value of
1194+ sym+add and the value of the thread pointer (r13). */ 1146+ sym+add and the value of the thread pointer (r13). */
1195+ HOWTO (R_MICROBLAZE_TLSTPREL32, 1147+ HOWTO (R_MICROBLAZE_TLSTPREL32,
1196+ 0, /* rightshift */ 1148+ 0, /* rightshift */
1197+ 2, /* size (0 = byte, 1 = short, 2 = long) */ 1149+ 4, /* size */
1198+ 32, /* bitsize */ 1150+ 32, /* bitsize */
1199+ FALSE, /* pc_relative */ 1151+ false, /* pc_relative */
1200+ 0, /* bitpos */ 1152+ 0, /* bitpos */
1201+ complain_overflow_dont, /* complain_on_overflow */ 1153+ complain_overflow_dont, /* complain_on_overflow */
1202+ bfd_elf_generic_reloc, /* special_function */ 1154+ bfd_elf_generic_reloc, /* special_function */
1203+ "R_MICROBLAZE_TLSTPREL32", /* name */ 1155+ "R_MICROBLAZE_TLSTPREL32", /* name */
1204+ FALSE, /* partial_inplace */ 1156+ false, /* partial_inplace */
1205+ 0, /* src_mask */ 1157+ 0, /* src_mask */
1206+ 0x0000ffff, /* dst_mask */ 1158+ 0x0000ffff, /* dst_mask */
1207+ FALSE), /* pcrel_offset */ 1159+ false), /* pcrel_offset */
1208+ 1160+
1209+}; 1161+};
1210+ 1162+
@@ -1297,6 +1249,12 @@ index 00000000000..bf58b4b0a67
1297+ case BFD_RELOC_MICROBLAZE_64_GOT: 1249+ case BFD_RELOC_MICROBLAZE_64_GOT:
1298+ microblaze_reloc = R_MICROBLAZE_GOT_64; 1250+ microblaze_reloc = R_MICROBLAZE_GOT_64;
1299+ break; 1251+ break;
1252+ case BFD_RELOC_MICROBLAZE_64_TEXTPCREL:
1253+ microblaze_reloc = R_MICROBLAZE_TEXTPCREL_64;
1254+ break;
1255+ case BFD_RELOC_MICROBLAZE_64_TEXTREL:
1256+ microblaze_reloc = R_MICROBLAZE_TEXTREL_64;
1257+ break;
1300+ case BFD_RELOC_MICROBLAZE_64_PLT: 1258+ case BFD_RELOC_MICROBLAZE_64_PLT:
1301+ microblaze_reloc = R_MICROBLAZE_PLT_64; 1259+ microblaze_reloc = R_MICROBLAZE_PLT_64;
1302+ break; 1260+ break;
@@ -1357,8 +1315,8 @@ index 00000000000..bf58b4b0a67
1357+ 1315+
1358+/* Set the howto pointer for a RCE ELF reloc. */ 1316+/* Set the howto pointer for a RCE ELF reloc. */
1359+ 1317+
1360+static void 1318+static bool
1361+microblaze_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED, 1319+microblaze_elf_info_to_howto (bfd * abfd,
1362+ arelent * cache_ptr, 1320+ arelent * cache_ptr,
1363+ Elf_Internal_Rela * dst) 1321+ Elf_Internal_Rela * dst)
1364+{ 1322+{
@@ -1371,25 +1329,56 @@ index 00000000000..bf58b4b0a67
1371+ r_type = ELF64_R_TYPE (dst->r_info); 1329+ r_type = ELF64_R_TYPE (dst->r_info);
1372+ if (r_type >= R_MICROBLAZE_max) 1330+ if (r_type >= R_MICROBLAZE_max)
1373+ { 1331+ {
1374+ (*_bfd_error_handler) (_("%B: unrecognised MicroBlaze reloc number: %d"), 1332+ /* xgettext:c-format */
1375+ abfd, r_type); 1333+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
1334+ abfd, r_type);
1376+ bfd_set_error (bfd_error_bad_value); 1335+ bfd_set_error (bfd_error_bad_value);
1377+ r_type = R_MICROBLAZE_NONE; 1336+ return false;
1378+ } 1337+ }
1379+ 1338+
1380+ cache_ptr->howto = microblaze_elf_howto_table [r_type]; 1339+ cache_ptr->howto = microblaze_elf_howto_table [r_type];
1340+ return true;
1341+}
1342+
1343+struct _microblaze_elf_section_data
1344+{
1345+ struct bfd_elf_section_data elf;
1346+ /* Count of used relaxation table entries. */
1347+ size_t relax_count;
1348+ /* Relaxation table. */
1349+ struct relax_table *relax;
1350+};
1351+
1352+#define microblaze_elf_section_data(sec) \
1353+ ((struct _microblaze_elf_section_data *) elf_section_data (sec))
1354+
1355+static bool
1356+microblaze_elf_new_section_hook (bfd *abfd, asection *sec)
1357+{
1358+ if (!sec->used_by_bfd)
1359+ {
1360+ struct _microblaze_elf_section_data *sdata;
1361+ size_t amt = sizeof (*sdata);
1362+
1363+ sdata = bfd_zalloc (abfd, amt);
1364+ if (sdata == NULL)
1365+ return false;
1366+ sec->used_by_bfd = sdata;
1367+ }
1368+
1369+ return _bfd_elf_new_section_hook (abfd, sec);
1381+} 1370+}
1382+ 1371+
1383+/* Microblaze ELF local labels start with 'L.' or '$L', not '.L'. */ 1372+/* Microblaze ELF local labels start with 'L.' or '$L', not '.L'. */
1384+ 1373+
1385+static bfd_boolean 1374+static bool
1386+microblaze_elf_is_local_label_name (bfd *abfd, const char *name) 1375+microblaze_elf_is_local_label_name (bfd *abfd, const char *name)
1387+{ 1376+{
1388+ if (name[0] == 'L' && name[1] == '.') 1377+ if (name[0] == 'L' && name[1] == '.')
1389+ return TRUE; 1378+ return true;
1390+ 1379+
1391+ if (name[0] == '$' && name[1] == 'L') 1380+ if (name[0] == '$' && name[1] == 'L')
1392+ return TRUE; 1381+ return true;
1393+ 1382+
1394+ /* With gcc, the labels go back to starting with '.', so we accept 1383+ /* With gcc, the labels go back to starting with '.', so we accept
1395+ the generic ELF local label syntax as well. */ 1384+ the generic ELF local label syntax as well. */
@@ -1472,9 +1461,10 @@ index 00000000000..bf58b4b0a67
1472+ 1461+
1473+/* Get the ELF linker hash table from a link_info structure. */ 1462+/* Get the ELF linker hash table from a link_info structure. */
1474+ 1463+
1475+#define elf64_mb_hash_table(p) \ 1464+#define elf64_mb_hash_table(p) \
1476+ (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \ 1465+ ((is_elf_hash_table ((p)->hash) \
1477+ == MICROBLAZE_ELF_DATA ? ((struct elf64_mb_link_hash_table *) ((p)->hash)) : NULL) 1466+ && elf_hash_table_id (elf_hash_table (p)) == MICROBLAZE_ELF_DATA) \
1467+ ? (struct elf64_mb_link_hash_table *) (p)->hash : NULL)
1478+ 1468+
1479+/* Create an entry in a microblaze ELF linker hash table. */ 1469+/* Create an entry in a microblaze ELF linker hash table. */
1480+ 1470+
@@ -1500,7 +1490,6 @@ index 00000000000..bf58b4b0a67
1500+ struct elf64_mb_link_hash_entry *eh; 1490+ struct elf64_mb_link_hash_entry *eh;
1501+ 1491+
1502+ eh = (struct elf64_mb_link_hash_entry *) entry; 1492+ eh = (struct elf64_mb_link_hash_entry *) entry;
1503+ eh->dyn_relocs = NULL;
1504+ eh->tls_mask = 0; 1493+ eh->tls_mask = 0;
1505+ } 1494+ }
1506+ 1495+
@@ -1513,7 +1502,7 @@ index 00000000000..bf58b4b0a67
1513+microblaze_elf_link_hash_table_create (bfd *abfd) 1502+microblaze_elf_link_hash_table_create (bfd *abfd)
1514+{ 1503+{
1515+ struct elf64_mb_link_hash_table *ret; 1504+ struct elf64_mb_link_hash_table *ret;
1516+ bfd_size_type amt = sizeof (struct elf64_mb_link_hash_table); 1505+ size_t amt = sizeof (struct elf64_mb_link_hash_table);
1517+ 1506+
1518+ ret = (struct elf64_mb_link_hash_table *) bfd_zmalloc (amt); 1507+ ret = (struct elf64_mb_link_hash_table *) bfd_zmalloc (amt);
1519+ if (ret == NULL) 1508+ if (ret == NULL)
@@ -1537,19 +1526,19 @@ index 00000000000..bf58b4b0a67
1537+{ 1526+{
1538+ struct bfd_link_hash_entry *h; 1527+ struct bfd_link_hash_entry *h;
1539+ 1528+
1540+ h = bfd_link_hash_lookup (info->hash, RO_SDA_ANCHOR_NAME, FALSE, FALSE, TRUE); 1529+ h = bfd_link_hash_lookup (info->hash, RO_SDA_ANCHOR_NAME, false, false, true);
1541+ if (h != (struct bfd_link_hash_entry *) NULL 1530+ if (h != (struct bfd_link_hash_entry *) NULL
1542+ && h->type == bfd_link_hash_defined) 1531+ && h->type == bfd_link_hash_defined)
1543+ ro_small_data_pointer = (h->u.def.value 1532+ ro_small_data_pointer = (h->u.def.value
1544+ + h->u.def.section->output_section->vma 1533+ + h->u.def.section->output_section->vma
1545+ + h->u.def.section->output_offset); 1534+ + h->u.def.section->output_offset);
1546+ 1535+
1547+ h = bfd_link_hash_lookup (info->hash, RW_SDA_ANCHOR_NAME, FALSE, FALSE, TRUE); 1536+ h = bfd_link_hash_lookup (info->hash, RW_SDA_ANCHOR_NAME, false, false, true);
1548+ if (h != (struct bfd_link_hash_entry *) NULL 1537+ if (h != (struct bfd_link_hash_entry *) NULL
1549+ && h->type == bfd_link_hash_defined) 1538+ && h->type == bfd_link_hash_defined)
1550+ rw_small_data_pointer = (h->u.def.value 1539+ rw_small_data_pointer = (h->u.def.value
1551+ + h->u.def.section->output_section->vma 1540+ + h->u.def.section->output_section->vma
1552+ + h->u.def.section->output_offset); 1541+ + h->u.def.section->output_offset);
1553+} 1542+}
1554+ 1543+
1555+static bfd_vma 1544+static bfd_vma
@@ -1620,7 +1609,7 @@ index 00000000000..bf58b4b0a67
1620+ section, which means that the addend must be adjusted 1609+ section, which means that the addend must be adjusted
1621+ accordingly. */ 1610+ accordingly. */
1622+ 1611+
1623+static bfd_boolean 1612+static int
1624+microblaze_elf_relocate_section (bfd *output_bfd, 1613+microblaze_elf_relocate_section (bfd *output_bfd,
1625+ struct bfd_link_info *info, 1614+ struct bfd_link_info *info,
1626+ bfd *input_bfd, 1615+ bfd *input_bfd,
@@ -1636,7 +1625,7 @@ index 00000000000..bf58b4b0a67
1636+ Elf_Internal_Rela *rel, *relend; 1625+ Elf_Internal_Rela *rel, *relend;
1637+ int endian = (bfd_little_endian (output_bfd)) ? 0 : 2; 1626+ int endian = (bfd_little_endian (output_bfd)) ? 0 : 2;
1638+ /* Assume success. */ 1627+ /* Assume success. */
1639+ bfd_boolean ret = TRUE; 1628+ bool ret = true;
1640+ asection *sreloc; 1629+ asection *sreloc;
1641+ bfd_vma *local_got_offsets; 1630+ bfd_vma *local_got_offsets;
1642+ unsigned int tls_type; 1631+ unsigned int tls_type;
@@ -1646,7 +1635,7 @@ index 00000000000..bf58b4b0a67
1646+ 1635+
1647+ htab = elf64_mb_hash_table (info); 1636+ htab = elf64_mb_hash_table (info);
1648+ if (htab == NULL) 1637+ if (htab == NULL)
1649+ return FALSE; 1638+ return false;
1650+ 1639+
1651+ local_got_offsets = elf_local_got_offsets (input_bfd); 1640+ local_got_offsets = elf_local_got_offsets (input_bfd);
1652+ 1641+
@@ -1667,7 +1656,7 @@ index 00000000000..bf58b4b0a67
1667+ const char *sym_name; 1656+ const char *sym_name;
1668+ bfd_reloc_status_type r = bfd_reloc_ok; 1657+ bfd_reloc_status_type r = bfd_reloc_ok;
1669+ const char *errmsg = NULL; 1658+ const char *errmsg = NULL;
1670+ bfd_boolean unresolved_reloc = FALSE; 1659+ bool unresolved_reloc = false;
1671+ 1660+
1672+ h = NULL; 1661+ h = NULL;
1673+ r_type = ELF64_R_TYPE (rel->r_info); 1662+ r_type = ELF64_R_TYPE (rel->r_info);
@@ -1675,10 +1664,11 @@ index 00000000000..bf58b4b0a67
1675+ 1664+
1676+ if (r_type < 0 || r_type >= (int) R_MICROBLAZE_max) 1665+ if (r_type < 0 || r_type >= (int) R_MICROBLAZE_max)
1677+ { 1666+ {
1678+ (*_bfd_error_handler) (_("%s: unknown relocation type %d"), 1667+ /* xgettext:c-format */
1679+ bfd_get_filename (input_bfd), (int) r_type); 1668+ _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
1669+ input_bfd, (int) r_type);
1680+ bfd_set_error (bfd_error_bad_value); 1670+ bfd_set_error (bfd_error_bad_value);
1681+ ret = FALSE; 1671+ ret = false;
1682+ continue; 1672+ continue;
1683+ } 1673+ }
1684+ 1674+
@@ -1728,11 +1718,12 @@ index 00000000000..bf58b4b0a67
1728+ else 1718+ else
1729+ { 1719+ {
1730+ bfd_vma relocation; 1720+ bfd_vma relocation;
1721+ bool resolved_to_zero;
1731+ 1722+
1732+ /* This is a final link. */ 1723+ /* This is a final link. */
1733+ sym = NULL; 1724+ sym = NULL;
1734+ sec = NULL; 1725+ sec = NULL;
1735+ unresolved_reloc = FALSE; 1726+ unresolved_reloc = false;
1736+ 1727+
1737+ if (r_symndx < symtab_hdr->sh_info) 1728+ if (r_symndx < symtab_hdr->sh_info)
1738+ { 1729+ {
@@ -1750,8 +1741,8 @@ index 00000000000..bf58b4b0a67
1750+ else 1741+ else
1751+ { 1742+ {
1752+ /* External symbol. */ 1743+ /* External symbol. */
1753+ bfd_boolean warned ATTRIBUTE_UNUSED; 1744+ bool warned ATTRIBUTE_UNUSED;
1754+ bfd_boolean ignored ATTRIBUTE_UNUSED; 1745+ bool ignored ATTRIBUTE_UNUSED;
1755+ 1746+
1756+ RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, 1747+ RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
1757+ r_symndx, symtab_hdr, sym_hashes, 1748+ r_symndx, symtab_hdr, sym_hashes,
@@ -1767,6 +1758,9 @@ index 00000000000..bf58b4b0a67
1767+ goto check_reloc; 1758+ goto check_reloc;
1768+ } 1759+ }
1769+ 1760+
1761+ resolved_to_zero = (h != NULL
1762+ && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
1763+
1770+ switch ((int) r_type) 1764+ switch ((int) r_type)
1771+ { 1765+ {
1772+ case (int) R_MICROBLAZE_SRO32 : 1766+ case (int) R_MICROBLAZE_SRO32 :
@@ -1785,7 +1779,7 @@ index 00000000000..bf58b4b0a67
1785+ microblaze_elf_final_sdp (info); 1779+ microblaze_elf_final_sdp (info);
1786+ if (ro_small_data_pointer == 0) 1780+ if (ro_small_data_pointer == 0)
1787+ { 1781+ {
1788+ ret = FALSE; 1782+ ret = false;
1789+ r = bfd_reloc_undefined; 1783+ r = bfd_reloc_undefined;
1790+ goto check_reloc; 1784+ goto check_reloc;
1791+ } 1785+ }
@@ -1801,13 +1795,16 @@ index 00000000000..bf58b4b0a67
1801+ } 1795+ }
1802+ else 1796+ else
1803+ { 1797+ {
1804+ (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"), 1798+ _bfd_error_handler
1805+ bfd_get_filename (input_bfd), 1799+ /* xgettext:c-format */
1806+ sym_name, 1800+ (_("%pB: the target (%s) of an %s relocation"
1807+ microblaze_elf_howto_table[(int) r_type]->name, 1801+ " is in the wrong section (%pA)"),
1808+ bfd_section_name (sec)); 1802+ input_bfd,
1803+ sym_name,
1804+ microblaze_elf_howto_table[(int) r_type]->name,
1805+ sec);
1809+ /*bfd_set_error (bfd_error_bad_value); ??? why? */ 1806+ /*bfd_set_error (bfd_error_bad_value); ??? why? */
1810+ ret = FALSE; 1807+ ret = false;
1811+ continue; 1808+ continue;
1812+ } 1809+ }
1813+ } 1810+ }
@@ -1830,7 +1827,7 @@ index 00000000000..bf58b4b0a67
1830+ microblaze_elf_final_sdp (info); 1827+ microblaze_elf_final_sdp (info);
1831+ if (rw_small_data_pointer == 0) 1828+ if (rw_small_data_pointer == 0)
1832+ { 1829+ {
1833+ ret = FALSE; 1830+ ret = false;
1834+ r = bfd_reloc_undefined; 1831+ r = bfd_reloc_undefined;
1835+ goto check_reloc; 1832+ goto check_reloc;
1836+ } 1833+ }
@@ -1846,13 +1843,16 @@ index 00000000000..bf58b4b0a67
1846+ } 1843+ }
1847+ else 1844+ else
1848+ { 1845+ {
1849+ (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"), 1846+ _bfd_error_handler
1850+ bfd_get_filename (input_bfd), 1847+ /* xgettext:c-format */
1851+ sym_name, 1848+ (_("%pB: the target (%s) of an %s relocation"
1852+ microblaze_elf_howto_table[(int) r_type]->name, 1849+ " is in the wrong section (%pA)"),
1853+ bfd_section_name (sec)); 1850+ input_bfd,
1851+ sym_name,
1852+ microblaze_elf_howto_table[(int) r_type]->name,
1853+ sec);
1854+ /*bfd_set_error (bfd_error_bad_value); ??? why? */ 1854+ /*bfd_set_error (bfd_error_bad_value); ??? why? */
1855+ ret = FALSE; 1855+ ret = false;
1856+ continue; 1856+ continue;
1857+ } 1857+ }
1858+ } 1858+ }
@@ -1863,36 +1863,47 @@ index 00000000000..bf58b4b0a67
1863+ break; /* Do nothing. */ 1863+ break; /* Do nothing. */
1864+ 1864+
1865+ case (int) R_MICROBLAZE_GOTPC_64: 1865+ case (int) R_MICROBLAZE_GOTPC_64:
1866+ case (int) R_MICROBLAZE_GPC_64: 1866+ relocation = (htab->elf.sgotplt->output_section->vma
1867+ relocation = htab->sgotplt->output_section->vma 1867+ + htab->elf.sgotplt->output_offset);
1868+ + htab->sgotplt->output_offset;
1869+ relocation -= (input_section->output_section->vma 1868+ relocation -= (input_section->output_section->vma
1870+ + input_section->output_offset 1869+ + input_section->output_offset
1871+ + offset + INST_WORD_SIZE); 1870+ + offset + INST_WORD_SIZE);
1872+ relocation += addend; 1871+ relocation += addend;
1873+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff, 1872+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1874+ contents + offset + endian); 1873+ contents + offset + endian);
1875+ bfd_put_16 (input_bfd, relocation & 0xffff, 1874+ bfd_put_16 (input_bfd, relocation & 0xffff,
1876+ contents + offset + endian + INST_WORD_SIZE); 1875+ contents + offset + endian + INST_WORD_SIZE);
1876+ break;
1877+
1878+ case (int) R_MICROBLAZE_TEXTPCREL_64:
1879+ relocation = input_section->output_section->vma;
1880+ relocation -= (input_section->output_section->vma
1881+ + input_section->output_offset
1882+ + offset + INST_WORD_SIZE);
1883+ relocation += addend;
1884+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
1885+ contents + offset + endian);
1886+ bfd_put_16 (input_bfd, relocation & 0xffff,
1887+ contents + offset + endian + INST_WORD_SIZE);
1877+ break; 1888+ break;
1878+ 1889+
1879+ case (int) R_MICROBLAZE_PLT_64: 1890+ case (int) R_MICROBLAZE_PLT_64:
1880+ { 1891+ {
1881+ bfd_vma immediate; 1892+ bfd_vma immediate;
1882+ if (htab->splt != NULL && h != NULL 1893+ if (htab->elf.splt != NULL && h != NULL
1883+ && h->plt.offset != (bfd_vma) -1) 1894+ && h->plt.offset != (bfd_vma) -1)
1884+ { 1895+ {
1885+ relocation = (htab->splt->output_section->vma 1896+ relocation = (htab->elf.splt->output_section->vma
1886+ + htab->splt->output_offset 1897+ + htab->elf.splt->output_offset
1887+ + h->plt.offset); 1898+ + h->plt.offset);
1888+ unresolved_reloc = FALSE; 1899+ unresolved_reloc = false;
1889+ immediate = relocation - (input_section->output_section->vma 1900+ immediate = relocation - (input_section->output_section->vma
1890+ + input_section->output_offset 1901+ + input_section->output_offset
1891+ + offset + INST_WORD_SIZE); 1902+ + offset + INST_WORD_SIZE);
1892+ bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff, 1903+ bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff,
1893+ contents + offset + endian); 1904+ contents + offset + endian);
1894+ bfd_put_16 (input_bfd, immediate & 0xffff, 1905+ bfd_put_16 (input_bfd, immediate & 0xffff,
1895+ contents + offset + endian + INST_WORD_SIZE); 1906+ contents + offset + endian + INST_WORD_SIZE);
1896+ } 1907+ }
1897+ else 1908+ else
1898+ { 1909+ {
@@ -1901,9 +1912,9 @@ index 00000000000..bf58b4b0a67
1901+ + offset + INST_WORD_SIZE); 1912+ + offset + INST_WORD_SIZE);
1902+ immediate = relocation; 1913+ immediate = relocation;
1903+ bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff, 1914+ bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff,
1904+ contents + offset + endian); 1915+ contents + offset + endian);
1905+ bfd_put_16 (input_bfd, immediate & 0xffff, 1916+ bfd_put_16 (input_bfd, immediate & 0xffff,
1906+ contents + offset + endian + INST_WORD_SIZE); 1917+ contents + offset + endian + INST_WORD_SIZE);
1907+ } 1918+ }
1908+ break; 1919+ break;
1909+ } 1920+ }
@@ -1913,6 +1924,7 @@ index 00000000000..bf58b4b0a67
1913+ goto dogot; 1924+ goto dogot;
1914+ case (int) R_MICROBLAZE_TLSLD: 1925+ case (int) R_MICROBLAZE_TLSLD:
1915+ tls_type = (TLS_TLS | TLS_LD); 1926+ tls_type = (TLS_TLS | TLS_LD);
1927+ /* Fall through. */
1916+ dogot: 1928+ dogot:
1917+ case (int) R_MICROBLAZE_GOT_64: 1929+ case (int) R_MICROBLAZE_GOT_64:
1918+ { 1930+ {
@@ -1921,8 +1933,8 @@ index 00000000000..bf58b4b0a67
1921+ unsigned long indx; 1933+ unsigned long indx;
1922+ bfd_vma static_value; 1934+ bfd_vma static_value;
1923+ 1935+
1924+ bfd_boolean need_relocs = FALSE; 1936+ bool need_relocs = false;
1925+ if (htab->sgot == NULL) 1937+ if (htab->elf.sgot == NULL)
1926+ abort (); 1938+ abort ();
1927+ 1939+
1928+ indx = 0; 1940+ indx = 0;
@@ -1938,10 +1950,11 @@ index 00000000000..bf58b4b0a67
1938+ offp = &htab->tlsld_got.offset; 1950+ offp = &htab->tlsld_got.offset;
1939+ else if (h != NULL) 1951+ else if (h != NULL)
1940+ { 1952+ {
1941+ if (htab->sgotplt != NULL && h->got.offset != (bfd_vma) -1) 1953+ if (htab->elf.sgotplt != NULL
1942+ offp = &h->got.offset; 1954+ && h->got.offset != (bfd_vma) -1)
1955+ offp = &h->got.offset;
1943+ else 1956+ else
1944+ abort (); 1957+ abort ();
1945+ } 1958+ }
1946+ else 1959+ else
1947+ { 1960+ {
@@ -1962,7 +1975,7 @@ index 00000000000..bf58b4b0a67
1962+ /* Symbol index to use for relocs */ 1975+ /* Symbol index to use for relocs */
1963+ if (h != NULL) 1976+ if (h != NULL)
1964+ { 1977+ {
1965+ bfd_boolean dyn = 1978+ bool dyn =
1966+ elf_hash_table (info)->dynamic_sections_created; 1979+ elf_hash_table (info)->dynamic_sections_created;
1967+ 1980+
1968+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 1981+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
@@ -1978,7 +1991,7 @@ index 00000000000..bf58b4b0a67
1978+ && (h == NULL 1991+ && (h == NULL
1979+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT 1992+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
1980+ || h->root.type != bfd_link_hash_undefweak)) 1993+ || h->root.type != bfd_link_hash_undefweak))
1981+ need_relocs = TRUE; 1994+ need_relocs = true;
1982+ 1995+
1983+ /* 2. Compute/Emit Static value of r-expression */ 1996+ /* 2. Compute/Emit Static value of r-expression */
1984+ static_value = relocation + addend; 1997+ static_value = relocation + addend;
@@ -1988,105 +2001,103 @@ index 00000000000..bf58b4b0a67
1988+ { 2001+ {
1989+ bfd_vma got_offset; 2002+ bfd_vma got_offset;
1990+ 2003+
1991+ got_offset = (htab->sgot->output_section->vma 2004+ got_offset = (htab->elf.sgot->output_section->vma
1992+ + htab->sgot->output_offset 2005+ + htab->elf.sgot->output_offset
1993+ + off); 2006+ + off);
1994+ 2007+
1995+ /* Process module-id */ 2008+ /* Process module-id */
1996+ if (IS_TLS_LD(tls_type)) 2009+ if (IS_TLS_LD(tls_type))
1997+ { 2010+ {
1998+ if (! bfd_link_pic (info)) 2011+ if (! bfd_link_pic (info))
1999+ { 2012+ bfd_put_32 (output_bfd, 1,
2000+ bfd_put_32 (output_bfd, 1, htab->sgot->contents + off); 2013+ htab->elf.sgot->contents + off);
2001+ }
2002+ else 2014+ else
2003+ { 2015+ microblaze_elf_output_dynamic_relocation
2004+ microblaze_elf_output_dynamic_relocation (output_bfd, 2016+ (output_bfd,
2005+ htab->srelgot, htab->srelgot->reloc_count++, 2017+ htab->elf.srelgot,
2006+ /* symindex= */ 0, R_MICROBLAZE_TLSDTPMOD32, 2018+ htab->elf.srelgot->reloc_count++,
2007+ got_offset, 0); 2019+ /* symindex= */ 0, R_MICROBLAZE_TLSDTPMOD32,
2008+ } 2020+ got_offset, 0);
2009+ } 2021+ }
2010+ else if (IS_TLS_GD(tls_type)) 2022+ else if (IS_TLS_GD(tls_type))
2011+ { 2023+ {
2012+ if (! need_relocs) 2024+ if (! need_relocs)
2013+ { 2025+ bfd_put_32 (output_bfd, 1,
2014+ bfd_put_32 (output_bfd, 1, htab->sgot->contents + off); 2026+ htab->elf.sgot->contents + off);
2015+ } 2027+ else
2016+ else 2028+ microblaze_elf_output_dynamic_relocation
2017+ { 2029+ (output_bfd,
2018+ microblaze_elf_output_dynamic_relocation (output_bfd, 2030+ htab->elf.srelgot,
2019+ htab->srelgot, 2031+ htab->elf.srelgot->reloc_count++,
2020+ htab->srelgot->reloc_count++, 2032+ /* symindex= */ indx, R_MICROBLAZE_TLSDTPMOD32,
2021+ /* symindex= */ indx, R_MICROBLAZE_TLSDTPMOD32, 2033+ got_offset, indx ? 0 : static_value);
2022+ got_offset, indx ? 0 : static_value);
2023+ }
2024+ } 2034+ }
2025+ 2035+
2026+ /* Process Offset */ 2036+ /* Process Offset */
2027+ if (htab->srelgot == NULL) 2037+ if (htab->elf.srelgot == NULL)
2028+ abort (); 2038+ abort ();
2029+ 2039+
2030+ got_offset = (htab->sgot->output_section->vma 2040+ got_offset = (htab->elf.sgot->output_section->vma
2031+ + htab->sgot->output_offset 2041+ + htab->elf.sgot->output_offset
2032+ + off2); 2042+ + off2);
2033+ if (IS_TLS_LD(tls_type)) 2043+ if (IS_TLS_LD(tls_type))
2034+ { 2044+ {
2035+ /* For LD, offset should be 0 */ 2045+ /* For LD, offset should be 0 */
2036+ *offp |= 1; 2046+ *offp |= 1;
2037+ bfd_put_32 (output_bfd, 0, htab->sgot->contents + off2); 2047+ bfd_put_32 (output_bfd, 0,
2048+ htab->elf.sgot->contents + off2);
2038+ } 2049+ }
2039+ else if (IS_TLS_GD(tls_type)) 2050+ else if (IS_TLS_GD(tls_type))
2040+ { 2051+ {
2041+ *offp |= 1; 2052+ *offp |= 1;
2042+ static_value -= dtprel_base(info); 2053+ static_value -= dtprel_base(info);
2043+ if (need_relocs) 2054+ if (need_relocs)
2044+ { 2055+ microblaze_elf_output_dynamic_relocation
2045+ microblaze_elf_output_dynamic_relocation (output_bfd, 2056+ (output_bfd,
2046+ htab->srelgot, htab->srelgot->reloc_count++, 2057+ htab->elf.srelgot,
2047+ /* symindex= */ indx, R_MICROBLAZE_TLSDTPREL32, 2058+ htab->elf.srelgot->reloc_count++,
2048+ got_offset, indx ? 0 : static_value); 2059+ /* symindex= */ indx, R_MICROBLAZE_TLSDTPREL32,
2049+ } 2060+ got_offset, indx ? 0 : static_value);
2050+ else 2061+ else
2051+ { 2062+ bfd_put_32 (output_bfd, static_value,
2052+ bfd_put_32 (output_bfd, static_value, 2063+ htab->elf.sgot->contents + off2);
2053+ htab->sgot->contents + off2);
2054+ }
2055+ } 2064+ }
2056+ else 2065+ else
2057+ { 2066+ {
2058+ bfd_put_32 (output_bfd, static_value, 2067+ bfd_put_32 (output_bfd, static_value,
2059+ htab->sgot->contents + off2); 2068+ htab->elf.sgot->contents + off2);
2060+ 2069+
2061+ /* Relocs for dyn symbols generated by 2070+ /* Relocs for dyn symbols generated by
2062+ finish_dynamic_symbols */ 2071+ finish_dynamic_symbols */
2063+ if (bfd_link_pic (info) && h == NULL) 2072+ if (bfd_link_pic (info) && h == NULL)
2064+ { 2073+ {
2065+ *offp |= 1; 2074+ *offp |= 1;
2066+ microblaze_elf_output_dynamic_relocation (output_bfd, 2075+ microblaze_elf_output_dynamic_relocation
2067+ htab->srelgot, htab->srelgot->reloc_count++, 2076+ (output_bfd,
2068+ /* symindex= */ indx, R_MICROBLAZE_REL, 2077+ htab->elf.srelgot,
2069+ got_offset, static_value); 2078+ htab->elf.srelgot->reloc_count++,
2070+ } 2079+ /* symindex= */ indx, R_MICROBLAZE_REL,
2080+ got_offset, static_value);
2081+ }
2071+ } 2082+ }
2072+ } 2083+ }
2073+ 2084+
2074+ /* 4. Fixup Relocation with GOT offset value 2085+ /* 4. Fixup Relocation with GOT offset value
2075+ Compute relative address of GOT entry for applying 2086+ Compute relative address of GOT entry for applying
2076+ the current relocation */ 2087+ the current relocation */
2077+ relocation = htab->sgot->output_section->vma 2088+ relocation = htab->elf.sgot->output_section->vma
2078+ + htab->sgot->output_offset 2089+ + htab->elf.sgot->output_offset
2079+ + off 2090+ + off
2080+ - htab->sgotplt->output_section->vma 2091+ - htab->elf.sgotplt->output_section->vma
2081+ - htab->sgotplt->output_offset; 2092+ - htab->elf.sgotplt->output_offset;
2082+ 2093+
2083+ /* Apply Current Relocation */ 2094+ /* Apply Current Relocation */
2084+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff, 2095+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
2085+ contents + offset + endian); 2096+ contents + offset + endian);
2086+ bfd_put_16 (input_bfd, relocation & 0xffff, 2097+ bfd_put_16 (input_bfd, relocation & 0xffff,
2087+ contents + offset + endian + INST_WORD_SIZE); 2098+ contents + offset + endian + INST_WORD_SIZE);
2088+ 2099+
2089+ unresolved_reloc = FALSE; 2100+ unresolved_reloc = false;
2090+ break; 2101+ break;
2091+ } 2102+ }
2092+ 2103+
@@ -2095,22 +2106,23 @@ index 00000000000..bf58b4b0a67
2095+ bfd_vma immediate; 2106+ bfd_vma immediate;
2096+ unsigned short lo, high; 2107+ unsigned short lo, high;
2097+ relocation += addend; 2108+ relocation += addend;
2098+ relocation -= htab->sgotplt->output_section->vma 2109+ relocation -= (htab->elf.sgotplt->output_section->vma
2099+ + htab->sgotplt->output_offset; 2110+ + htab->elf.sgotplt->output_offset);
2100+ /* Write this value into correct location. */ 2111+ /* Write this value into correct location. */
2101+ immediate = relocation; 2112+ immediate = relocation;
2102+ lo = immediate & 0x0000ffff; 2113+ lo = immediate & 0x0000ffff;
2103+ high = (immediate >> 16) & 0x0000ffff; 2114+ high = (immediate >> 16) & 0x0000ffff;
2104+ bfd_put_16 (input_bfd, high, contents + offset + endian); 2115+ bfd_put_16 (input_bfd, high, contents + offset + endian);
2105+ bfd_put_16 (input_bfd, lo, contents + offset + INST_WORD_SIZE + endian); 2116+ bfd_put_16 (input_bfd, lo,
2117+ contents + offset + INST_WORD_SIZE + endian);
2106+ break; 2118+ break;
2107+ } 2119+ }
2108+ 2120+
2109+ case (int) R_MICROBLAZE_GOTOFF_32: 2121+ case (int) R_MICROBLAZE_GOTOFF_32:
2110+ { 2122+ {
2111+ relocation += addend; 2123+ relocation += addend;
2112+ relocation -= htab->sgotplt->output_section->vma 2124+ relocation -= (htab->elf.sgotplt->output_section->vma
2113+ + htab->sgotplt->output_offset; 2125+ + htab->elf.sgotplt->output_offset);
2114+ /* Write this value into correct location. */ 2126+ /* Write this value into correct location. */
2115+ bfd_put_32 (input_bfd, relocation, contents + offset); 2127+ bfd_put_32 (input_bfd, relocation, contents + offset);
2116+ break; 2128+ break;
@@ -2124,6 +2136,8 @@ index 00000000000..bf58b4b0a67
2124+ bfd_put_16 (input_bfd, relocation & 0xffff, 2136+ bfd_put_16 (input_bfd, relocation & 0xffff,
2125+ contents + offset + endian + INST_WORD_SIZE); 2137+ contents + offset + endian + INST_WORD_SIZE);
2126+ break; 2138+ break;
2139+ case (int) R_MICROBLAZE_TEXTREL_64:
2140+ case (int) R_MICROBLAZE_TEXTREL_32_LO:
2127+ case (int) R_MICROBLAZE_64_PCREL : 2141+ case (int) R_MICROBLAZE_64_PCREL :
2128+ case (int) R_MICROBLAZE_64: 2142+ case (int) R_MICROBLAZE_64:
2129+ case (int) R_MICROBLAZE_32: 2143+ case (int) R_MICROBLAZE_32:
@@ -2145,6 +2159,14 @@ index 00000000000..bf58b4b0a67
2145+ relocation -= (input_section->output_section->vma 2159+ relocation -= (input_section->output_section->vma
2146+ + input_section->output_offset 2160+ + input_section->output_offset
2147+ + offset + INST_WORD_SIZE); 2161+ + offset + INST_WORD_SIZE);
2162+ else if (r_type == R_MICROBLAZE_TEXTREL_64
2163+ || r_type == R_MICROBLAZE_TEXTREL_32_LO)
2164+ relocation -= input_section->output_section->vma;
2165+
2166+ if (r_type == R_MICROBLAZE_TEXTREL_32_LO)
2167+ bfd_put_16 (input_bfd, relocation & 0xffff,
2168+ contents + offset + endian);
2169+
2148+ unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian); 2170+ unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
2149+ if ((insn & 0xff000000) == 0xb2000000) 2171+ if ((insn & 0xff000000) == 0xb2000000)
2150+ { 2172+ {
@@ -2164,7 +2186,8 @@ index 00000000000..bf58b4b0a67
2164+ 2186+
2165+ if ((bfd_link_pic (info) 2187+ if ((bfd_link_pic (info)
2166+ && (h == NULL 2188+ && (h == NULL
2167+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT 2189+ || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
2190+ && !resolved_to_zero)
2168+ || h->root.type != bfd_link_hash_undefweak) 2191+ || h->root.type != bfd_link_hash_undefweak)
2169+ && (!howto->pc_relative 2192+ && (!howto->pc_relative
2170+ || (h != NULL 2193+ || (h != NULL
@@ -2182,7 +2205,7 @@ index 00000000000..bf58b4b0a67
2182+ { 2205+ {
2183+ Elf_Internal_Rela outrel; 2206+ Elf_Internal_Rela outrel;
2184+ bfd_byte *loc; 2207+ bfd_byte *loc;
2185+ bfd_boolean skip; 2208+ bool skip;
2186+ 2209+
2187+ /* When generating a shared object, these relocations 2210+ /* When generating a shared object, these relocations
2188+ are copied into the output file to be resolved at run 2211+ are copied into the output file to be resolved at run
@@ -2190,15 +2213,15 @@ index 00000000000..bf58b4b0a67
2190+ 2213+
2191+ BFD_ASSERT (sreloc != NULL); 2214+ BFD_ASSERT (sreloc != NULL);
2192+ 2215+
2193+ skip = FALSE; 2216+ skip = false;
2194+ 2217+
2195+ outrel.r_offset = 2218+ outrel.r_offset =
2196+ _bfd_elf_section_offset (output_bfd, info, input_section, 2219+ _bfd_elf_section_offset (output_bfd, info, input_section,
2197+ rel->r_offset); 2220+ rel->r_offset);
2198+ if (outrel.r_offset == (bfd_vma) -1) 2221+ if (outrel.r_offset == (bfd_vma) -1)
2199+ skip = TRUE; 2222+ skip = true;
2200+ else if (outrel.r_offset == (bfd_vma) -2) 2223+ else if (outrel.r_offset == (bfd_vma) -2)
2201+ skip = TRUE; 2224+ skip = true;
2202+ outrel.r_offset += (input_section->output_section->vma 2225+ outrel.r_offset += (input_section->output_section->vma
2203+ + input_section->output_offset); 2226+ + input_section->output_offset);
2204+ 2227+
@@ -2224,11 +2247,11 @@ index 00000000000..bf58b4b0a67
2224+ else 2247+ else
2225+ { 2248+ {
2226+ BFD_FAIL (); 2249+ BFD_FAIL ();
2227+ (*_bfd_error_handler) 2250+ _bfd_error_handler
2228+ (_("%B: probably compiled without -fPIC?"), 2251+ (_("%pB: probably compiled without -fPIC?"),
2229+ input_bfd); 2252+ input_bfd);
2230+ bfd_set_error (bfd_error_bad_value); 2253+ bfd_set_error (bfd_error_bad_value);
2231+ return FALSE; 2254+ return false;
2232+ } 2255+ }
2233+ } 2256+ }
2234+ 2257+
@@ -2247,25 +2270,33 @@ index 00000000000..bf58b4b0a67
2247+ else 2270+ else
2248+ { 2271+ {
2249+ if (r_type == R_MICROBLAZE_64_PCREL) 2272+ if (r_type == R_MICROBLAZE_64_PCREL)
2250+ { 2273+ {
2251+ if (!input_section->output_section->vma && 2274+ if (!input_section->output_section->vma &&
2252+ !input_section->output_offset && !offset) 2275+ !input_section->output_offset && !offset)
2253+ relocation -= (input_section->output_section->vma 2276+ relocation -= (input_section->output_section->vma
2254+ + input_section->output_offset 2277+ + input_section->output_offset
2255+ + offset); 2278+ + offset);
2256+ else 2279+ else
2257+ relocation -= (input_section->output_section->vma 2280+ relocation -= (input_section->output_section->vma
2258+ + input_section->output_offset 2281+ + input_section->output_offset + offset + INST_WORD_SIZE);
2259+ + offset + INST_WORD_SIZE); 2282+ }
2283+ else if (r_type == R_MICROBLAZE_TEXTREL_64
2284+ || r_type == R_MICROBLAZE_TEXTREL_32_LO)
2285+ relocation -= input_section->output_section->vma;
2286+
2287+ if (r_type == R_MICROBLAZE_TEXTREL_32_LO)
2288+ {
2289+ bfd_put_16 (input_bfd, relocation & 0xffff,
2290+ contents + offset + endian);
2260+ } 2291+ }
2261+ unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian); 2292+ unsigned long insn = bfd_get_32 (input_bfd, contents + offset +endian);
2262+ if ((insn & 0xff000000) == 0xb2000000) 2293+ if ((insn & 0xff000000) == 0xb2000000)
2263+ { 2294+ {
2264+ insn &= ~0x00ffffff; 2295+ insn &= ~0x00ffffff;
2265+ insn |= (relocation >> 16) & 0xffffff; 2296+ insn |= (relocation >> 16) & 0xffffff;
2266+ bfd_put_32 (input_bfd, insn, 2297+ bfd_put_32 (input_bfd, insn,
2267+ contents + offset + endian); 2298+ contents + offset + endian);
2268+ } 2299+ }
2269+ else 2300+ else
2270+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff, 2301+ bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
2271+ contents + offset + endian); 2302+ contents + offset + endian);
@@ -2314,7 +2345,7 @@ index 00000000000..bf58b4b0a67
2314+ 2345+
2315+ case bfd_reloc_undefined: 2346+ case bfd_reloc_undefined:
2316+ (*info->callbacks->undefined_symbol) 2347+ (*info->callbacks->undefined_symbol)
2317+ (info, name, input_bfd, input_section, offset, TRUE); 2348+ (info, name, input_bfd, input_section, offset, true);
2318+ break; 2349+ break;
2319+ 2350+
2320+ case bfd_reloc_outofrange: 2351+ case bfd_reloc_outofrange:
@@ -2347,36 +2378,37 @@ index 00000000000..bf58b4b0a67
2347+ object file when linking. 2378+ object file when linking.
2348+ 2379+
2349+ Note: We only use this hook to catch endian mismatches. */ 2380+ Note: We only use this hook to catch endian mismatches. */
2350+static bfd_boolean 2381+static bool
2351+microblaze_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd) 2382+microblaze_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
2352+{ 2383+{
2353+ /* Check if we have the same endianess. */ 2384+ /* Check if we have the same endianess. */
2354+ if (! _bfd_generic_verify_endian_match (ibfd, obfd)) 2385+ if (! _bfd_generic_verify_endian_match (ibfd, obfd))
2355+ return FALSE; 2386+ return false;
2356+ 2387+
2357+ return TRUE; 2388+ return true;
2358+} 2389+}
2359+ 2390+
2360+ 2391+
2361+/* Calculate fixup value for reference. */ 2392+/* Calculate fixup value for reference. */
2362+ 2393+
2363+static int 2394+static size_t
2364+calc_fixup (bfd_vma start, bfd_vma size, asection *sec) 2395+calc_fixup (bfd_vma start, bfd_vma size, asection *sec)
2365+{ 2396+{
2366+ bfd_vma end = start + size; 2397+ bfd_vma end = start + size;
2367+ int i, fixup = 0; 2398+ size_t i, fixup = 0;
2399+ struct _microblaze_elf_section_data *sdata;
2368+ 2400+
2369+ if (sec == NULL || sec->relax == NULL) 2401+ if (sec == NULL || (sdata = microblaze_elf_section_data (sec)) == NULL)
2370+ return 0; 2402+ return 0;
2371+ 2403+
2372+ /* Look for addr in relax table, total fixup value. */ 2404+ /* Look for addr in relax table, total fixup value. */
2373+ for (i = 0; i < sec->relax_count; i++) 2405+ for (i = 0; i < sdata->relax_count; i++)
2374+ { 2406+ {
2375+ if (end <= sec->relax[i].addr) 2407+ if (end <= sdata->relax[i].addr)
2376+ break; 2408+ break;
2377+ if ((end != start) && (start > sec->relax[i].addr)) 2409+ if (end != start && start > sdata->relax[i].addr)
2378+ continue; 2410+ continue;
2379+ fixup += sec->relax[i].size; 2411+ fixup += sdata->relax[i].size;
2380+ } 2412+ }
2381+ return fixup; 2413+ return fixup;
2382+} 2414+}
@@ -2429,39 +2461,39 @@ index 00000000000..bf58b4b0a67
2429+ bfd_put_32 (abfd, instr_lo, bfd_addr + INST_WORD_SIZE); 2461+ bfd_put_32 (abfd, instr_lo, bfd_addr + INST_WORD_SIZE);
2430+} 2462+}
2431+ 2463+
2432+static bfd_boolean 2464+static bool
2433+microblaze_elf_relax_section (bfd *abfd, 2465+microblaze_elf_relax_section (bfd *abfd,
2434+ asection *sec, 2466+ asection *sec,
2435+ struct bfd_link_info *link_info, 2467+ struct bfd_link_info *link_info,
2436+ bfd_boolean *again) 2468+ bool *again)
2437+{ 2469+{
2438+ Elf_Internal_Shdr *symtab_hdr; 2470+ Elf_Internal_Shdr *symtab_hdr;
2439+ Elf_Internal_Rela *internal_relocs; 2471+ Elf_Internal_Rela *internal_relocs;
2440+ Elf_Internal_Rela *free_relocs = NULL;
2441+ Elf_Internal_Rela *irel, *irelend; 2472+ Elf_Internal_Rela *irel, *irelend;
2442+ bfd_byte *contents = NULL; 2473+ bfd_byte *contents = NULL;
2443+ bfd_byte *free_contents = NULL;
2444+ int rel_count; 2474+ int rel_count;
2445+ unsigned int shndx; 2475+ unsigned int shndx;
2446+ int i, sym_index; 2476+ size_t i, sym_index;
2447+ asection *o; 2477+ asection *o;
2448+ struct elf_link_hash_entry *sym_hash; 2478+ struct elf_link_hash_entry *sym_hash;
2449+ Elf_Internal_Sym *isymbuf, *isymend; 2479+ Elf_Internal_Sym *isymbuf, *isymend;
2450+ Elf_Internal_Sym *isym; 2480+ Elf_Internal_Sym *isym;
2451+ int symcount; 2481+ size_t symcount;
2452+ int offset; 2482+ size_t offset;
2453+ bfd_vma src, dest; 2483+ bfd_vma src, dest;
2484+ struct _microblaze_elf_section_data *sdata;
2454+ 2485+
2455+ /* We only do this once per section. We may be able to delete some code 2486+ /* We only do this once per section. We may be able to delete some code
2456+ by running multiple passes, but it is not worth it. */ 2487+ by running multiple passes, but it is not worth it. */
2457+ *again = FALSE; 2488+ *again = false;
2458+ 2489+
2459+ /* Only do this for a text section. */ 2490+ /* Only do this for a text section. */
2460+ if (bfd_link_relocatable (link_info) 2491+ if (bfd_link_relocatable (link_info)
2461+ || (sec->flags & SEC_RELOC) == 0 2492+ || (sec->flags & SEC_RELOC) == 0
2462+ || (sec->reloc_count == 0) 2493+ || (sec->flags & SEC_CODE) == 0
2463+ || (sec->flags & SEC_CODE) == 0) 2494+ || sec->reloc_count == 0
2464+ return TRUE; 2495+ || (sdata = microblaze_elf_section_data (sec)) == NULL)
2496+ return true;
2465+ 2497+
2466+ BFD_ASSERT ((sec->size > 0) || (sec->rawsize > 0)); 2498+ BFD_ASSERT ((sec->size > 0) || (sec->rawsize > 0));
2467+ 2499+
@@ -2482,14 +2514,12 @@ index 00000000000..bf58b4b0a67
2482+ internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, link_info->keep_memory); 2514+ internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, link_info->keep_memory);
2483+ if (internal_relocs == NULL) 2515+ if (internal_relocs == NULL)
2484+ goto error_return; 2516+ goto error_return;
2485+ if (! link_info->keep_memory)
2486+ free_relocs = internal_relocs;
2487+ 2517+
2488+ sec->relax = (struct relax_table *) bfd_malloc ((sec->reloc_count + 1) 2518+ sdata->relax_count = 0;
2489+ * sizeof (struct relax_table)); 2519+ sdata->relax = (struct relax_table *) bfd_malloc ((sec->reloc_count + 1)
2490+ if (sec->relax == NULL) 2520+ * sizeof (*sdata->relax));
2521+ if (sdata->relax == NULL)
2491+ goto error_return; 2522+ goto error_return;
2492+ sec->relax_count = 0;
2493+ 2523+
2494+ irelend = internal_relocs + sec->reloc_count; 2524+ irelend = internal_relocs + sec->reloc_count;
2495+ rel_count = 0; 2525+ rel_count = 0;
@@ -2497,7 +2527,8 @@ index 00000000000..bf58b4b0a67
2497+ { 2527+ {
2498+ bfd_vma symval; 2528+ bfd_vma symval;
2499+ if ((ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64_PCREL) 2529+ if ((ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64_PCREL)
2500+ && (ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64 )) 2530+ && (ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_64 )
2531+&& (ELF64_R_TYPE (irel->r_info) != (int) R_MICROBLAZE_TEXTREL_64))
2501+ continue; /* Can't delete this reloc. */ 2532+ continue; /* Can't delete this reloc. */
2502+ 2533+
2503+ /* Get the section contents. */ 2534+ /* Get the section contents. */
@@ -2510,8 +2541,6 @@ index 00000000000..bf58b4b0a67
2510+ contents = (bfd_byte *) bfd_malloc (sec->size); 2541+ contents = (bfd_byte *) bfd_malloc (sec->size);
2511+ if (contents == NULL) 2542+ if (contents == NULL)
2512+ goto error_return; 2543+ goto error_return;
2513+ free_contents = contents;
2514+
2515+ if (!bfd_get_section_contents (abfd, sec, contents, 2544+ if (!bfd_get_section_contents (abfd, sec, contents,
2516+ (file_ptr) 0, sec->size)) 2545+ (file_ptr) 0, sec->size))
2517+ goto error_return; 2546+ goto error_return;
@@ -2567,15 +2596,20 @@ index 00000000000..bf58b4b0a67
2567+ + sec->output_section->vma 2596+ + sec->output_section->vma
2568+ + sec->output_offset); 2597+ + sec->output_offset);
2569+ } 2598+ }
2599+ else if (ELF64_R_TYPE (irel->r_info) == (int) R_MICROBLAZE_TEXTREL_64)
2600+ {
2601+ symval = symval + irel->r_addend - (sec->output_section->vma);
2602+ }
2570+ else 2603+ else
2571+ symval += irel->r_addend; 2604+ symval += irel->r_addend;
2572+ 2605+
2573+ if ((symval & 0xffff8000) == 0) 2606+ if ((symval & 0xffff8000) == 0
2607+ || (symval & 0xffff8000) == 0xffff8000)
2574+ { 2608+ {
2575+ /* We can delete this instruction. */ 2609+ /* We can delete this instruction. */
2576+ sec->relax[sec->relax_count].addr = irel->r_offset; 2610+ sdata->relax[sdata->relax_count].addr = irel->r_offset;
2577+ sec->relax[sec->relax_count].size = INST_WORD_SIZE; 2611+ sdata->relax[sdata->relax_count].size = INST_WORD_SIZE;
2578+ sec->relax_count++; 2612+ sdata->relax_count++;
2579+ 2613+
2580+ /* Rewrite relocation type. */ 2614+ /* Rewrite relocation type. */
2581+ switch ((enum elf_microblaze_reloc_type) ELF64_R_TYPE (irel->r_info)) 2615+ switch ((enum elf_microblaze_reloc_type) ELF64_R_TYPE (irel->r_info))
@@ -2588,19 +2622,23 @@ index 00000000000..bf58b4b0a67
2588+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), 2622+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
2589+ (int) R_MICROBLAZE_32_LO); 2623+ (int) R_MICROBLAZE_32_LO);
2590+ break; 2624+ break;
2625+ case R_MICROBLAZE_TEXTREL_64:
2626+ irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
2627+ (int) R_MICROBLAZE_TEXTREL_32_LO);
2628+ break;
2591+ default: 2629+ default:
2592+ /* Cannot happen. */ 2630+ /* Cannot happen. */
2593+ BFD_ASSERT (FALSE); 2631+ BFD_ASSERT (false);
2594+ } 2632+ }
2595+ } 2633+ }
2596+ } /* Loop through all relocations. */ 2634+ } /* Loop through all relocations. */
2597+ 2635+
2598+ /* Loop through the relocs again, and see if anything needs to change. */ 2636+ /* Loop through the relocs again, and see if anything needs to change. */
2599+ if (sec->relax_count > 0) 2637+ if (sdata->relax_count > 0)
2600+ { 2638+ {
2601+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec); 2639+ shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
2602+ rel_count = 0; 2640+ rel_count = 0;
2603+ sec->relax[sec->relax_count].addr = sec->size; 2641+ sdata->relax[sdata->relax_count].addr = sec->size;
2604+ 2642+
2605+ for (irel = internal_relocs; irel < irelend; irel++, rel_count++) 2643+ for (irel = internal_relocs; irel < irelend; irel++, rel_count++)
2606+ { 2644+ {
@@ -2653,14 +2691,14 @@ index 00000000000..bf58b4b0a67
2653+ case R_MICROBLAZE_NONE: 2691+ case R_MICROBLAZE_NONE:
2654+ case R_MICROBLAZE_32_NONE: 2692+ case R_MICROBLAZE_32_NONE:
2655+ { 2693+ {
2656+ /* This was a PC-relative instruction that was 2694+ /* This was a PC-relative instruction that was
2657+ completely resolved. */ 2695+ completely resolved. */
2658+ int sfix, efix; 2696+ size_t sfix, efix;
2659+ unsigned int val; 2697+ unsigned int val;
2660+ bfd_vma target_address; 2698+ bfd_vma target_address;
2661+ target_address = irel->r_addend + irel->r_offset; 2699+ target_address = irel->r_addend + irel->r_offset;
2662+ sfix = calc_fixup (irel->r_offset, 0, sec); 2700+ sfix = calc_fixup (irel->r_offset, 0, sec);
2663+ efix = calc_fixup (target_address, 0, sec); 2701+ efix = calc_fixup (target_address, 0, sec);
2664+ 2702+
2665+ /* Validate the in-band val. */ 2703+ /* Validate the in-band val. */
2666+ val = bfd_get_32 (abfd, contents + irel->r_offset); 2704+ val = bfd_get_32 (abfd, contents + irel->r_offset);
@@ -2675,10 +2713,10 @@ index 00000000000..bf58b4b0a67
2675+ break; 2713+ break;
2676+ case R_MICROBLAZE_64_NONE: 2714+ case R_MICROBLAZE_64_NONE:
2677+ { 2715+ {
2678+ /* This was a PC-relative 64-bit instruction that was 2716+ /* This was a PC-relative 64-bit instruction that was
2679+ completely resolved. */ 2717+ completely resolved. */
2680+ int sfix, efix; 2718+ size_t sfix, efix;
2681+ bfd_vma target_address; 2719+ bfd_vma target_address;
2682+ target_address = irel->r_addend + irel->r_offset + INST_WORD_SIZE; 2720+ target_address = irel->r_addend + irel->r_offset + INST_WORD_SIZE;
2683+ sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec); 2721+ sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
2684+ efix = calc_fixup (target_address, 0, sec); 2722+ efix = calc_fixup (target_address, 0, sec);
@@ -2704,9 +2742,9 @@ index 00000000000..bf58b4b0a67
2704+ continue; 2742+ continue;
2705+ 2743+
2706+ /* We always cache the relocs. Perhaps, if info->keep_memory is 2744+ /* We always cache the relocs. Perhaps, if info->keep_memory is
2707+ FALSE, we should free them, if we are permitted to. */ 2745+ false, we should free them, if we are permitted to. */
2708+ 2746+
2709+ irelocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, TRUE); 2747+ irelocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, true);
2710+ if (irelocs == NULL) 2748+ if (irelocs == NULL)
2711+ goto error_return; 2749+ goto error_return;
2712+ 2750+
@@ -2717,6 +2755,8 @@ index 00000000000..bf58b4b0a67
2717+ if (1 && ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE) 2755+ if (1 && ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_NONE)
2718+ { 2756+ {
2719+ unsigned int val; 2757+ unsigned int val;
2758+ if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
2759+ continue;
2720+ 2760+
2721+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info); 2761+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2722+ 2762+
@@ -2732,7 +2772,7 @@ index 00000000000..bf58b4b0a67
2732+ else 2772+ else
2733+ { 2773+ {
2734+ /* We always cache the section contents. 2774+ /* We always cache the section contents.
2735+ Perhaps, if info->keep_memory is FALSE, we 2775+ Perhaps, if info->keep_memory is false, we
2736+ should free them, if we are permitted to. */ 2776+ should free them, if we are permitted to. */
2737+ 2777+
2738+ if (o->rawsize == 0) 2778+ if (o->rawsize == 0)
@@ -2759,6 +2799,9 @@ index 00000000000..bf58b4b0a67
2759+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32 2799+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32
2760+ || ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_IMML_64) 2800+ || ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_IMML_64)
2761+ { 2801+ {
2802+ if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
2803+ continue;
2804+
2762+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info); 2805+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2763+ 2806+
2764+ /* Look at the reloc only if the value has been resolved. */ 2807+ /* Look at the reloc only if the value has been resolved. */
@@ -2772,7 +2815,7 @@ index 00000000000..bf58b4b0a67
2772+ else 2815+ else
2773+ { 2816+ {
2774+ /* We always cache the section contents. 2817+ /* We always cache the section contents.
2775+ Perhaps, if info->keep_memory is FALSE, we 2818+ Perhaps, if info->keep_memory is false, we
2776+ should free them, if we are permitted to. */ 2819+ should free them, if we are permitted to. */
2777+ if (o->rawsize == 0) 2820+ if (o->rawsize == 0)
2778+ o->rawsize = o->size; 2821+ o->rawsize = o->size;
@@ -2791,6 +2834,9 @@ index 00000000000..bf58b4b0a67
2791+ } 2834+ }
2792+ else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_SYM_OP_SYM) 2835+ else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_SYM_OP_SYM)
2793+ { 2836+ {
2837+ if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
2838+ continue;
2839+
2794+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info); 2840+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2795+ 2841+
2796+ /* Look at the reloc only if the value has been resolved. */ 2842+ /* Look at the reloc only if the value has been resolved. */
@@ -2801,7 +2847,7 @@ index 00000000000..bf58b4b0a67
2801+ else 2847+ else
2802+ { 2848+ {
2803+ /* We always cache the section contents. 2849+ /* We always cache the section contents.
2804+ Perhaps, if info->keep_memory is FALSE, we 2850+ Perhaps, if info->keep_memory is false, we
2805+ should free them, if we are permitted to. */ 2851+ should free them, if we are permitted to. */
2806+ 2852+
2807+ if (o->rawsize == 0) 2853+ if (o->rawsize == 0)
@@ -2822,9 +2868,15 @@ index 00000000000..bf58b4b0a67
2822+ sec); 2868+ sec);
2823+ } 2869+ }
2824+ } 2870+ }
2825+ else if ((ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_PCREL_LO) 2871+ else if ((ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_PCREL_LO)
2826+ || (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_LO)) 2872+ || (ELF32_R_TYPE (irelscan->r_info)
2873+ == (int) R_MICROBLAZE_32_LO)
2874+ || (ELF32_R_TYPE (irelscan->r_info)
2875+ == (int) R_MICROBLAZE_TEXTREL_32_LO))
2827+ { 2876+ {
2877+ if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
2878+ continue;
2879+
2828+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info); 2880+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2829+ 2881+
2830+ /* Look at the reloc only if the value has been resolved. */ 2882+ /* Look at the reloc only if the value has been resolved. */
@@ -2841,7 +2893,7 @@ index 00000000000..bf58b4b0a67
2841+ else 2893+ else
2842+ { 2894+ {
2843+ /* We always cache the section contents. 2895+ /* We always cache the section contents.
2844+ Perhaps, if info->keep_memory is FALSE, we 2896+ Perhaps, if info->keep_memory is false, we
2845+ should free them, if we are permitted to. */ 2897+ should free them, if we are permitted to. */
2846+ if (o->rawsize == 0) 2898+ if (o->rawsize == 0)
2847+ o->rawsize = o->size; 2899+ o->rawsize = o->size;
@@ -2867,8 +2919,12 @@ index 00000000000..bf58b4b0a67
2867+ } 2919+ }
2868+ } 2920+ }
2869+ 2921+
2870+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64) 2922+ if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64
2923+ || (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_TEXTREL_64))
2871+ { 2924+ {
2925+ if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
2926+ continue;
2927+
2872+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info); 2928+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2873+ 2929+
2874+ /* Look at the reloc only if the value has been resolved. */ 2930+ /* Look at the reloc only if the value has been resolved. */
@@ -2884,7 +2940,7 @@ index 00000000000..bf58b4b0a67
2884+ else 2940+ else
2885+ { 2941+ {
2886+ /* We always cache the section contents. 2942+ /* We always cache the section contents.
2887+ Perhaps, if info->keep_memory is FALSE, we 2943+ Perhaps, if info->keep_memory is false, we
2888+ should free them, if we are permitted to. */ 2944+ should free them, if we are permitted to. */
2889+ 2945+
2890+ if (o->rawsize == 0) 2946+ if (o->rawsize == 0)
@@ -2899,23 +2955,27 @@ index 00000000000..bf58b4b0a67
2899+ elf_section_data (o)->this_hdr.contents = ocontents; 2955+ elf_section_data (o)->this_hdr.contents = ocontents;
2900+ } 2956+ }
2901+ } 2957+ }
2902+ unsigned long instr_hi = bfd_get_32 (abfd, ocontents 2958+ unsigned long instr_hi = bfd_get_32 (abfd, ocontents
2903+ + irelscan->r_offset); 2959+ + irelscan->r_offset);
2904+ unsigned long instr_lo = bfd_get_32 (abfd, ocontents 2960+ unsigned long instr_lo = bfd_get_32 (abfd, ocontents
2905+ + irelscan->r_offset 2961+ + irelscan->r_offset
2906+ + INST_WORD_SIZE); 2962+ + INST_WORD_SIZE);
2907+ if ((instr_hi & 0xff000000) == 0xb2000000) 2963+ if ((instr_hi & 0xff000000) == 0xb2000000)
2908+ immediate = (instr_hi & 0x00ffffff) << 24; 2964+ immediate = (instr_hi & 0x00ffffff) << 24;
2909+ else 2965+ else
2910+ immediate = (instr_hi & 0x0000ffff) << 16; 2966+ immediate = (instr_hi & 0x0000ffff) << 16;
2911+ immediate |= (instr_lo & 0x0000ffff); 2967+ immediate |= (instr_lo & 0x0000ffff);
2912+ offset = calc_fixup (irelscan->r_addend, 0, sec); 2968+ offset = calc_fixup (irelscan->r_addend, 0, sec);
2913+ immediate -= offset; 2969+ immediate -= offset;
2914+ irelscan->r_addend -= offset; 2970+ irelscan->r_addend -= offset;
2971+
2915+ } 2972+ }
2916+ } 2973+ }
2917+ else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_PCREL) 2974+ else if (ELF64_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_64_PCREL)
2918+ { 2975+ {
2976+ if (ELF64_R_SYM (irelscan->r_info) >= symtab_hdr->sh_info)
2977+ continue;
2978+
2919+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info); 2979+ isym = isymbuf + ELF64_R_SYM (irelscan->r_info);
2920+ 2980+
2921+ /* Look at the reloc only if the value has been resolved. */ 2981+ /* Look at the reloc only if the value has been resolved. */
@@ -2932,7 +2992,7 @@ index 00000000000..bf58b4b0a67
2932+ else 2992+ else
2933+ { 2993+ {
2934+ /* We always cache the section contents. 2994+ /* We always cache the section contents.
2935+ Perhaps, if info->keep_memory is FALSE, we 2995+ Perhaps, if info->keep_memory is false, we
2936+ should free them, if we are permitted to. */ 2996+ should free them, if we are permitted to. */
2937+ if (o->rawsize == 0) 2997+ if (o->rawsize == 0)
2938+ o->rawsize = o->size; 2998+ o->rawsize = o->size;
@@ -2998,65 +3058,66 @@ index 00000000000..bf58b4b0a67
2998+ } 3058+ }
2999+ 3059+
3000+ /* Physically move the code and change the cooked size. */ 3060+ /* Physically move the code and change the cooked size. */
3001+ dest = sec->relax[0].addr; 3061+ dest = sdata->relax[0].addr;
3002+ for (i = 0; i < sec->relax_count; i++) 3062+ for (i = 0; i < sdata->relax_count; i++)
3003+ { 3063+ {
3004+ int len; 3064+ size_t len;
3005+ src = sec->relax[i].addr + sec->relax[i].size; 3065+ src = sdata->relax[i].addr + sdata->relax[i].size;
3006+ len = sec->relax[i+1].addr - sec->relax[i].addr - sec->relax[i].size; 3066+ len = (sdata->relax[i+1].addr - sdata->relax[i].addr
3007+ 3067+ - sdata->relax[i].size);
3008+ memmove (contents + dest, contents + src, len); 3068+
3009+ sec->size -= sec->relax[i].size; 3069+ memmove (contents + dest, contents + src, len);
3010+ dest += len; 3070+ sec->size -= sdata->relax[i].size;
3011+ } 3071+ dest += len;
3072+ }
3012+ 3073+
3013+ elf_section_data (sec)->relocs = internal_relocs; 3074+ elf_section_data (sec)->relocs = internal_relocs;
3014+ free_relocs = NULL;
3015+ 3075+
3016+ elf_section_data (sec)->this_hdr.contents = contents; 3076+ elf_section_data (sec)->this_hdr.contents = contents;
3017+ free_contents = NULL;
3018+ 3077+
3019+ symtab_hdr->contents = (bfd_byte *) isymbuf; 3078+ symtab_hdr->contents = (bfd_byte *) isymbuf;
3020+ } 3079+ }
3021+ 3080+
3022+ if (free_relocs != NULL) 3081+ if (internal_relocs != NULL
3023+ { 3082+ && elf_section_data (sec)->relocs != internal_relocs)
3024+ free (free_relocs); 3083+ free (internal_relocs);
3025+ free_relocs = NULL;
3026+ }
3027+ 3084+
3028+ if (free_contents != NULL) 3085+ if (contents != NULL
3086+ && elf_section_data (sec)->this_hdr.contents != contents)
3029+ { 3087+ {
3030+ if (!link_info->keep_memory) 3088+ if (! link_info->keep_memory)
3031+ free (free_contents); 3089+ free (contents);
3032+ else 3090+ else
3033+ /* Cache the section contents for elf_link_input_bfd. */ 3091+ {
3034+ elf_section_data (sec)->this_hdr.contents = contents; 3092+ /* Cache the section contents for elf_link_input_bfd. */
3035+ free_contents = NULL; 3093+ elf_section_data (sec)->this_hdr.contents = contents;
3094+ }
3036+ } 3095+ }
3037+ 3096+
3038+ if (sec->relax_count == 0) 3097+ if (sdata->relax_count == 0)
3039+ { 3098+ {
3040+ *again = FALSE; 3099+ *again = false;
3041+ free (sec->relax); 3100+ free (sdata->relax);
3042+ sec->relax = NULL; 3101+ sdata->relax = NULL;
3043+ } 3102+ }
3044+ else 3103+ else
3045+ *again = TRUE; 3104+ *again = true;
3046+ return TRUE; 3105+ return true;
3047+ 3106+
3048+ error_return: 3107+ error_return:
3049+ if (free_relocs != NULL) 3108+ if (isymbuf != NULL
3050+ free (free_relocs); 3109+ && symtab_hdr->contents != (unsigned char *) isymbuf)
3051+ if (free_contents != NULL) 3110+ free (isymbuf);
3052+ free (free_contents); 3111+ if (internal_relocs != NULL
3053+ if (sec->relax != NULL) 3112+ && elf_section_data (sec)->relocs != internal_relocs)
3054+ { 3113+ free (internal_relocs);
3055+ free (sec->relax); 3114+ if (contents != NULL
3056+ sec->relax = NULL; 3115+ && elf_section_data (sec)->this_hdr.contents != contents)
3057+ sec->relax_count = 0; 3116+ free (contents);
3058+ } 3117+ free (sdata->relax);
3059+ return FALSE; 3118+ sdata->relax = NULL;
3119+ sdata->relax_count = 0;
3120+ return false;
3060+} 3121+}
3061+ 3122+
3062+/* Return the section that should be marked against GC for a given 3123+/* Return the section that should be marked against GC for a given
@@ -3082,13 +3143,13 @@ index 00000000000..bf58b4b0a67
3082+ 3143+
3083+/* Update the got entry reference counts for the section being removed. */ 3144+/* Update the got entry reference counts for the section being removed. */
3084+ 3145+
3085+static bfd_boolean 3146+static bool
3086+microblaze_elf_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED, 3147+microblaze_elf_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED,
3087+ struct bfd_link_info * info ATTRIBUTE_UNUSED, 3148+ struct bfd_link_info * info ATTRIBUTE_UNUSED,
3088+ asection * sec ATTRIBUTE_UNUSED, 3149+ asection * sec ATTRIBUTE_UNUSED,
3089+ const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED) 3150+ const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
3090+{ 3151+{
3091+ return TRUE; 3152+ return true;
3092+} 3153+}
3093+ 3154+
3094+/* PIC support. */ 3155+/* PIC support. */
@@ -3104,37 +3165,7 @@ index 00000000000..bf58b4b0a67
3104+/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up 3165+/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
3105+ shortcuts to them in our hash table. */ 3166+ shortcuts to them in our hash table. */
3106+ 3167+
3107+static bfd_boolean 3168+static bool
3108+create_got_section (bfd *dynobj, struct bfd_link_info *info)
3109+{
3110+ struct elf64_mb_link_hash_table *htab;
3111+
3112+ if (! _bfd_elf_create_got_section (dynobj, info))
3113+ return FALSE;
3114+ htab = elf64_mb_hash_table (info);
3115+ if (htab == NULL)
3116+ return FALSE;
3117+
3118+ htab->sgot = bfd_get_linker_section (dynobj, ".got");
3119+ htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
3120+ if (!htab->sgot || !htab->sgotplt)
3121+ return FALSE;
3122+
3123+ if ((htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got")) == NULL)
3124+ htab->srelgot = bfd_make_section_anyway (dynobj, ".rela.got");
3125+ if (htab->srelgot == NULL
3126+ || ! bfd_set_section_flags (htab->srelgot, SEC_ALLOC
3127+ | SEC_LOAD
3128+ | SEC_HAS_CONTENTS
3129+ | SEC_IN_MEMORY
3130+ | SEC_LINKER_CREATED
3131+ | SEC_READONLY)
3132+ || ! bfd_set_section_alignment (htab->srelgot, 2))
3133+ return FALSE;
3134+ return TRUE;
3135+}
3136+
3137+static bfd_boolean
3138+update_local_sym_info (bfd *abfd, 3169+update_local_sym_info (bfd *abfd,
3139+ Elf_Internal_Shdr *symtab_hdr, 3170+ Elf_Internal_Shdr *symtab_hdr,
3140+ unsigned long r_symndx, 3171+ unsigned long r_symndx,
@@ -3150,7 +3181,7 @@ index 00000000000..bf58b4b0a67
3150+ size *= (sizeof (*local_got_refcounts) + sizeof (*local_got_tls_masks)); 3181+ size *= (sizeof (*local_got_refcounts) + sizeof (*local_got_tls_masks));
3151+ local_got_refcounts = bfd_zalloc (abfd, size); 3182+ local_got_refcounts = bfd_zalloc (abfd, size);
3152+ if (local_got_refcounts == NULL) 3183+ if (local_got_refcounts == NULL)
3153+ return FALSE; 3184+ return false;
3154+ elf_local_got_refcounts (abfd) = local_got_refcounts; 3185+ elf_local_got_refcounts (abfd) = local_got_refcounts;
3155+ } 3186+ }
3156+ 3187+
@@ -3159,11 +3190,11 @@ index 00000000000..bf58b4b0a67
3159+ local_got_tls_masks[r_symndx] |= tls_type; 3190+ local_got_tls_masks[r_symndx] |= tls_type;
3160+ local_got_refcounts[r_symndx] += 1; 3191+ local_got_refcounts[r_symndx] += 1;
3161+ 3192+
3162+ return TRUE; 3193+ return true;
3163+} 3194+}
3164+/* Look through the relocs for a section during the first phase. */ 3195+/* Look through the relocs for a section during the first phase. */
3165+ 3196+
3166+static bfd_boolean 3197+static bool
3167+microblaze_elf_check_relocs (bfd * abfd, 3198+microblaze_elf_check_relocs (bfd * abfd,
3168+ struct bfd_link_info * info, 3199+ struct bfd_link_info * info,
3169+ asection * sec, 3200+ asection * sec,
@@ -3178,11 +3209,11 @@ index 00000000000..bf58b4b0a67
3178+ asection *sreloc = NULL; 3209+ asection *sreloc = NULL;
3179+ 3210+
3180+ if (bfd_link_relocatable (info)) 3211+ if (bfd_link_relocatable (info))
3181+ return TRUE; 3212+ return true;
3182+ 3213+
3183+ htab = elf64_mb_hash_table (info); 3214+ htab = elf64_mb_hash_table (info);
3184+ if (htab == NULL) 3215+ if (htab == NULL)
3185+ return FALSE; 3216+ return false;
3186+ 3217+
3187+ symtab_hdr = & elf_tdata (abfd)->symtab_hdr; 3218+ symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
3188+ sym_hashes = elf_sym_hashes (abfd); 3219+ sym_hashes = elf_sym_hashes (abfd);
@@ -3207,7 +3238,9 @@ index 00000000000..bf58b4b0a67
3207+ else 3238+ else
3208+ { 3239+ {
3209+ h = sym_hashes [r_symndx - symtab_hdr->sh_info]; 3240+ h = sym_hashes [r_symndx - symtab_hdr->sh_info];
3210+ 3241+ while (h->root.type == bfd_link_hash_indirect
3242+ || h->root.type == bfd_link_hash_warning)
3243+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
3211+ /* PR15323, ref flags aren't set for references in the same 3244+ /* PR15323, ref flags aren't set for references in the same
3212+ object. */ 3245+ object. */
3213+ h->root.non_ir_ref_regular = 1; 3246+ h->root.non_ir_ref_regular = 1;
@@ -3219,14 +3252,14 @@ index 00000000000..bf58b4b0a67
3219+ Reconstruct it for later use during GC. */ 3252+ Reconstruct it for later use during GC. */
3220+ case R_MICROBLAZE_GNU_VTINHERIT: 3253+ case R_MICROBLAZE_GNU_VTINHERIT:
3221+ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) 3254+ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
3222+ return FALSE; 3255+ return false;
3223+ break; 3256+ break;
3224+ 3257+
3225+ /* This relocation describes which C++ vtable entries are actually 3258+ /* This relocation describes which C++ vtable entries are actually
3226+ used. Record for later use during GC. */ 3259+ used. Record for later use during GC. */
3227+ case R_MICROBLAZE_GNU_VTENTRY: 3260+ case R_MICROBLAZE_GNU_VTENTRY:
3228+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) 3261+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
3229+ return FALSE; 3262+ return false;
3230+ break; 3263+ break;
3231+ 3264+
3232+ /* This relocation requires .plt entry. */ 3265+ /* This relocation requires .plt entry. */
@@ -3239,22 +3272,24 @@ index 00000000000..bf58b4b0a67
3239+ break; 3272+ break;
3240+ 3273+
3241+ /* This relocation requires .got entry. */ 3274+ /* This relocation requires .got entry. */
3242+ case R_MICROBLAZE_TLSGD: 3275+ case R_MICROBLAZE_TLSGD:
3243+ tls_type |= (TLS_TLS | TLS_GD); 3276+ tls_type |= (TLS_TLS | TLS_GD);
3244+ goto dogottls; 3277+ goto dogottls;
3245+ case R_MICROBLAZE_TLSLD: 3278+ case R_MICROBLAZE_TLSLD:
3246+ tls_type |= (TLS_TLS | TLS_LD); 3279+ tls_type |= (TLS_TLS | TLS_LD);
3247+ dogottls: 3280+ /* Fall through. */
3248+ sec->has_tls_reloc = 1; 3281+ dogottls:
3249+ case R_MICROBLAZE_GOT_64: 3282+ sec->has_tls_reloc = 1;
3250+ if (htab->sgot == NULL) 3283+ /* Fall through. */
3251+ { 3284+ case R_MICROBLAZE_GOT_64:
3252+ if (htab->elf.dynobj == NULL) 3285+ if (htab->elf.sgot == NULL)
3253+ htab->elf.dynobj = abfd; 3286+ {
3254+ if (!create_got_section (htab->elf.dynobj, info)) 3287+ if (htab->elf.dynobj == NULL)
3255+ return FALSE; 3288+ htab->elf.dynobj = abfd;
3256+ } 3289+ if (!_bfd_elf_create_got_section (htab->elf.dynobj, info))
3257+ if (h != NULL) 3290+ return false;
3291+ }
3292+ if (h != NULL)
3258+ { 3293+ {
3259+ h->got.refcount += 1; 3294+ h->got.refcount += 1;
3260+ elf64_mb_hash_entry (h)->tls_mask |= tls_type; 3295+ elf64_mb_hash_entry (h)->tls_mask |= tls_type;
@@ -3262,7 +3297,18 @@ index 00000000000..bf58b4b0a67
3262+ else 3297+ else
3263+ { 3298+ {
3264+ if (! update_local_sym_info(abfd, symtab_hdr, r_symndx, tls_type) ) 3299+ if (! update_local_sym_info(abfd, symtab_hdr, r_symndx, tls_type) )
3265+ return FALSE; 3300+ return false;
3301+ }
3302+ break;
3303+
3304+ case R_MICROBLAZE_GOTOFF_64:
3305+ case R_MICROBLAZE_GOTOFF_32:
3306+ if (htab->elf.sgot == NULL)
3307+ {
3308+ if (htab->elf.dynobj == NULL)
3309+ htab->elf.dynobj = abfd;
3310+ if (!_bfd_elf_create_got_section (htab->elf.dynobj, info))
3311+ return false;
3266+ } 3312+ }
3267+ break; 3313+ break;
3268+ 3314+
@@ -3336,13 +3382,13 @@ index 00000000000..bf58b4b0a67
3336+ sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj, 3382+ sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj,
3337+ 2, abfd, 1); 3383+ 2, abfd, 1);
3338+ if (sreloc == NULL) 3384+ if (sreloc == NULL)
3339+ return FALSE; 3385+ return false;
3340+ } 3386+ }
3341+ 3387+
3342+ /* If this is a global symbol, we count the number of 3388+ /* If this is a global symbol, we count the number of
3343+ relocations we need for this symbol. */ 3389+ relocations we need for this symbol. */
3344+ if (h != NULL) 3390+ if (h != NULL)
3345+ head = &((struct elf64_mb_link_hash_entry *) h)->dyn_relocs; 3391+ head = &h->dyn_relocs;
3346+ else 3392+ else
3347+ { 3393+ {
3348+ /* Track dynamic relocs needed for local syms too. 3394+ /* Track dynamic relocs needed for local syms too.
@@ -3353,14 +3399,14 @@ index 00000000000..bf58b4b0a67
3353+ Elf_Internal_Sym *isym; 3399+ Elf_Internal_Sym *isym;
3354+ void *vpp; 3400+ void *vpp;
3355+ 3401+
3356+ isym = bfd_sym_from_r_symndx (&htab->sym_sec, 3402+ isym = bfd_sym_from_r_symndx (&htab->elf.sym_cache,
3357+ abfd, r_symndx); 3403+ abfd, r_symndx);
3358+ if (isym == NULL) 3404+ if (isym == NULL)
3359+ return FALSE; 3405+ return false;
3360+ 3406+
3361+ s = bfd_section_from_elf_index (abfd, isym->st_shndx); 3407+ s = bfd_section_from_elf_index (abfd, isym->st_shndx);
3362+ if (s == NULL) 3408+ if (s == NULL)
3363+ return FALSE; 3409+ return false;
3364+ 3410+
3365+ vpp = &elf_section_data (s)->local_dynrel; 3411+ vpp = &elf_section_data (s)->local_dynrel;
3366+ head = (struct elf64_mb_dyn_relocs **) vpp; 3412+ head = (struct elf64_mb_dyn_relocs **) vpp;
@@ -3369,11 +3415,11 @@ index 00000000000..bf58b4b0a67
3369+ p = *head; 3415+ p = *head;
3370+ if (p == NULL || p->sec != sec) 3416+ if (p == NULL || p->sec != sec)
3371+ { 3417+ {
3372+ bfd_size_type amt = sizeof *p; 3418+ size_t amt = sizeof *p;
3373+ p = ((struct elf64_mb_dyn_relocs *) 3419+ p = ((struct elf64_mb_dyn_relocs *)
3374+ bfd_alloc (htab->elf.dynobj, amt)); 3420+ bfd_alloc (htab->elf.dynobj, amt));
3375+ if (p == NULL) 3421+ if (p == NULL)
3376+ return FALSE; 3422+ return false;
3377+ p->next = *head; 3423+ p->next = *head;
3378+ *head = p; 3424+ *head = p;
3379+ p->sec = sec; 3425+ p->sec = sec;
@@ -3390,23 +3436,23 @@ index 00000000000..bf58b4b0a67
3390+ } 3436+ }
3391+ } 3437+ }
3392+ 3438+
3393+ return TRUE; 3439+ return true;
3394+} 3440+}
3395+ 3441+
3396+static bfd_boolean 3442+static bool
3397+microblaze_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) 3443+microblaze_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
3398+{ 3444+{
3399+ struct elf64_mb_link_hash_table *htab; 3445+ struct elf64_mb_link_hash_table *htab;
3400+ 3446+
3401+ htab = elf64_mb_hash_table (info); 3447+ htab = elf64_mb_hash_table (info);
3402+ if (htab == NULL) 3448+ if (htab == NULL)
3403+ return FALSE; 3449+ return false;
3404+ 3450+
3405+ if (!htab->sgot && !create_got_section (dynobj, info)) 3451+ if (!htab->sgot && !_bfd_elf_create_got_section (dynobj, info))
3406+ return FALSE; 3452+ return false;
3407+ 3453+
3408+ if (!_bfd_elf_create_dynamic_sections (dynobj, info)) 3454+ if (!_bfd_elf_create_dynamic_sections (dynobj, info))
3409+ return FALSE; 3455+ return false;
3410+ 3456+
3411+ htab->splt = bfd_get_linker_section (dynobj, ".plt"); 3457+ htab->splt = bfd_get_linker_section (dynobj, ".plt");
3412+ htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt"); 3458+ htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
@@ -3418,7 +3464,7 @@ index 00000000000..bf58b4b0a67
3418+ || (!bfd_link_pic (info) && !htab->srelbss)) 3464+ || (!bfd_link_pic (info) && !htab->srelbss))
3419+ abort (); 3465+ abort ();
3420+ 3466+
3421+ return TRUE; 3467+ return true;
3422+} 3468+}
3423+ 3469+
3424+/* Copy the extra info we tack onto an elf_link_hash_entry. */ 3470+/* Copy the extra info we tack onto an elf_link_hash_entry. */
@@ -3472,20 +3518,21 @@ index 00000000000..bf58b4b0a67
3472+ _bfd_elf_link_hash_copy_indirect (info, dir, ind); 3518+ _bfd_elf_link_hash_copy_indirect (info, dir, ind);
3473+} 3519+}
3474+ 3520+
3475+static bfd_boolean 3521+static bool
3476+microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info, 3522+microblaze_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
3477+ struct elf_link_hash_entry *h) 3523+ struct elf_link_hash_entry *h)
3478+{ 3524+{
3479+ struct elf64_mb_link_hash_table *htab; 3525+ struct elf64_mb_link_hash_table *htab;
3480+ struct elf64_mb_link_hash_entry * eh; 3526+ struct elf64_mb_link_hash_entry * eh;
3481+ struct elf64_mb_dyn_relocs *p; 3527+ struct elf64_mb_dyn_relocs *p;
3482+ asection *sdynbss, *s; 3528+ asection *sdynbss;
3529+ asection *s, *srel;
3483+ unsigned int power_of_two; 3530+ unsigned int power_of_two;
3484+ bfd *dynobj; 3531+ bfd *dynobj;
3485+ 3532+
3486+ htab = elf64_mb_hash_table (info); 3533+ htab = elf64_mb_hash_table (info);
3487+ if (htab == NULL) 3534+ if (htab == NULL)
3488+ return FALSE; 3535+ return false;
3489+ 3536+
3490+ /* If this is a function, put it in the procedure linkage table. We 3537+ /* If this is a function, put it in the procedure linkage table. We
3491+ will fill in the contents of the procedure linkage table later, 3538+ will fill in the contents of the procedure linkage table later,
@@ -3507,7 +3554,7 @@ index 00000000000..bf58b4b0a67
3507+ h->needs_plt = 0; 3554+ h->needs_plt = 0;
3508+ } 3555+ }
3509+ 3556+
3510+ return TRUE; 3557+ return true;
3511+ } 3558+ }
3512+ else 3559+ else
3513+ /* It's possible that we incorrectly decided a .plt reloc was 3560+ /* It's possible that we incorrectly decided a .plt reloc was
@@ -3526,8 +3573,8 @@ index 00000000000..bf58b4b0a67
3526+ BFD_ASSERT (def->root.type == bfd_link_hash_defined); 3573+ BFD_ASSERT (def->root.type == bfd_link_hash_defined);
3527+ h->root.u.def.section = def->root.u.def.section; 3574+ h->root.u.def.section = def->root.u.def.section;
3528+ h->root.u.def.value = def->root.u.def.value; 3575+ h->root.u.def.value = def->root.u.def.value;
3529+ return TRUE; 3576+ return true;
3530+ } 3577+ }
3531+ 3578+
3532+ /* This is a reference to a symbol defined by a dynamic object which 3579+ /* This is a reference to a symbol defined by a dynamic object which
3533+ is not a function. */ 3580+ is not a function. */
@@ -3537,18 +3584,18 @@ index 00000000000..bf58b4b0a67
3537+ For such cases we need not do anything here; the relocations will 3584+ For such cases we need not do anything here; the relocations will
3538+ be handled correctly by relocate_section. */ 3585+ be handled correctly by relocate_section. */
3539+ if (bfd_link_pic (info)) 3586+ if (bfd_link_pic (info))
3540+ return TRUE; 3587+ return true;
3541+ 3588+
3542+ /* If there are no references to this symbol that do not use the 3589+ /* If there are no references to this symbol that do not use the
3543+ GOT, we don't need to generate a copy reloc. */ 3590+ GOT, we don't need to generate a copy reloc. */
3544+ if (!h->non_got_ref) 3591+ if (!h->non_got_ref)
3545+ return TRUE; 3592+ return true;
3546+ 3593+
3547+ /* If -z nocopyreloc was given, we won't generate them either. */ 3594+ /* If -z nocopyreloc was given, we won't generate them either. */
3548+ if (info->nocopyreloc) 3595+ if (info->nocopyreloc)
3549+ { 3596+ {
3550+ h->non_got_ref = 0; 3597+ h->non_got_ref = 0;
3551+ return TRUE; 3598+ return true;
3552+ } 3599+ }
3553+ 3600+
3554+ eh = (struct elf64_mb_link_hash_entry *) h; 3601+ eh = (struct elf64_mb_link_hash_entry *) h;
@@ -3564,7 +3611,7 @@ index 00000000000..bf58b4b0a67
3564+ if (p == NULL) 3611+ if (p == NULL)
3565+ { 3612+ {
3566+ h->non_got_ref = 0; 3613+ h->non_got_ref = 0;
3567+ return TRUE; 3614+ return true;
3568+ } 3615+ }
3569+ 3616+
3570+ /* We must allocate the symbol in our .dynbss section, which will 3617+ /* We must allocate the symbol in our .dynbss section, which will
@@ -3597,25 +3644,25 @@ index 00000000000..bf58b4b0a67
3597+ sdynbss = htab->sdynbss; 3644+ sdynbss = htab->sdynbss;
3598+ /* Apply the required alignment. */ 3645+ /* Apply the required alignment. */
3599+ sdynbss->size = BFD_ALIGN (sdynbss->size, (bfd_size_type) (1 << power_of_two)); 3646+ sdynbss->size = BFD_ALIGN (sdynbss->size, (bfd_size_type) (1 << power_of_two));
3600+ if (power_of_two > bfd_section_alignment (sdynbss)) 3647+ if (power_of_two > sdynbss->alignment_power)
3601+ { 3648+ {
3602+ if (! bfd_set_section_alignment (sdynbss, power_of_two)) 3649+ if (! bfd_set_section_alignment (sdynbss, power_of_two))
3603+ return FALSE; 3650+ return false;
3604+ } 3651+ }
3605+ 3652+
3606+ /* Define the symbol as being at this point in the section. */ 3653+ /* Define the symbol as being at this point in the section. */
3607+ h->root.u.def.section = sdynbss; 3654+ h->root.u.def.section = s;
3608+ h->root.u.def.value = sdynbss->size; 3655+ h->root.u.def.value = s->size;
3609+ 3656+
3610+ /* Increment the section size to make room for the symbol. */ 3657+ /* Increment the section size to make room for the symbol. */
3611+ sdynbss->size += h->size; 3658+ s->size += h->size;
3612+ return TRUE; 3659+ return true;
3613+} 3660+}
3614+ 3661+
3615+/* Allocate space in .plt, .got and associated reloc sections for 3662+/* Allocate space in .plt, .got and associated reloc sections for
3616+ dynamic relocs. */ 3663+ dynamic relocs. */
3617+ 3664+
3618+static bfd_boolean 3665+static bool
3619+allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat) 3666+allocate_dynrelocs (struct elf_link_hash_entry *h, void * dat)
3620+{ 3667+{
3621+ struct bfd_link_info *info; 3668+ struct bfd_link_info *info;
@@ -3624,12 +3671,12 @@ index 00000000000..bf58b4b0a67
3624+ struct elf64_mb_dyn_relocs *p; 3671+ struct elf64_mb_dyn_relocs *p;
3625+ 3672+
3626+ if (h->root.type == bfd_link_hash_indirect) 3673+ if (h->root.type == bfd_link_hash_indirect)
3627+ return TRUE; 3674+ return true;
3628+ 3675+
3629+ info = (struct bfd_link_info *) dat; 3676+ info = (struct bfd_link_info *) dat;
3630+ htab = elf64_mb_hash_table (info); 3677+ htab = elf64_mb_hash_table (info);
3631+ if (htab == NULL) 3678+ if (htab == NULL)
3632+ return FALSE; 3679+ return false;
3633+ 3680+
3634+ if (htab->elf.dynamic_sections_created 3681+ if (htab->elf.dynamic_sections_created
3635+ && h->plt.refcount > 0) 3682+ && h->plt.refcount > 0)
@@ -3640,12 +3687,12 @@ index 00000000000..bf58b4b0a67
3640+ && !h->forced_local) 3687+ && !h->forced_local)
3641+ { 3688+ {
3642+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) 3689+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3643+ return FALSE; 3690+ return false;
3644+ } 3691+ }
3645+ 3692+
3646+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h)) 3693+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h))
3647+ { 3694+ {
3648+ asection *s = htab->splt; 3695+ asection *s = htab->elf.splt;
3649+ 3696+
3650+ /* The first entry in .plt is reserved. */ 3697+ /* The first entry in .plt is reserved. */
3651+ if (s->size == 0) 3698+ if (s->size == 0)
@@ -3668,13 +3715,13 @@ index 00000000000..bf58b4b0a67
3668+ /* Make room for this entry. */ 3715+ /* Make room for this entry. */
3669+ s->size += PLT_ENTRY_SIZE; 3716+ s->size += PLT_ENTRY_SIZE;
3670+ 3717+
3671+ /* We also need to make an entry in the .got.plt section, which 3718+ /* We also need to make an entry in the .got.plt section, which
3672+ will be placed in the .got section by the linker script. */ 3719+ will be placed in the .got section by the linker script. */
3673+ htab->sgotplt->size += 4; 3720+ htab->elf.sgotplt->size += 4;
3674+ 3721+
3675+ /* We also need to make an entry in the .rel.plt section. */ 3722+ /* We also need to make an entry in the .rel.plt section. */
3676+ htab->srelplt->size += sizeof (Elf64_External_Rela); 3723+ htab->elf.srelplt->size += sizeof (Elf64_External_Rela);
3677+ } 3724+ }
3678+ else 3725+ else
3679+ { 3726+ {
3680+ h->plt.offset = (bfd_vma) -1; 3727+ h->plt.offset = (bfd_vma) -1;
@@ -3699,7 +3746,7 @@ index 00000000000..bf58b4b0a67
3699+ && !h->forced_local) 3746+ && !h->forced_local)
3700+ { 3747+ {
3701+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) 3748+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3702+ return FALSE; 3749+ return false;
3703+ } 3750+ }
3704+ 3751+
3705+ need = 0; 3752+ need = 0;
@@ -3729,18 +3776,18 @@ index 00000000000..bf58b4b0a67
3729+ h->got.offset = (bfd_vma) -1; 3776+ h->got.offset = (bfd_vma) -1;
3730+ } 3777+ }
3731+ else 3778+ else
3732+ { 3779+ {
3733+ s = htab->sgot; 3780+ s = htab->elf.sgot;
3734+ h->got.offset = s->size; 3781+ h->got.offset = s->size;
3735+ s->size += need; 3782+ s->size += need;
3736+ htab->srelgot->size += need * (sizeof (Elf64_External_Rela) / 4); 3783+ htab->elf.srelgot->size += need * (sizeof (Elf64_External_Rela) / 4);
3737+ } 3784+ }
3738+ } 3785+ }
3739+ else 3786+ else
3740+ h->got.offset = (bfd_vma) -1; 3787+ h->got.offset = (bfd_vma) -1;
3741+ 3788+
3742+ if (eh->dyn_relocs == NULL) 3789+ if (eh->dyn_relocs == NULL)
3743+ return TRUE; 3790+ return true;
3744+ 3791+
3745+ /* In the shared -Bsymbolic case, discard space allocated for 3792+ /* In the shared -Bsymbolic case, discard space allocated for
3746+ dynamic pc-relative relocs against symbols which turn out to be 3793+ dynamic pc-relative relocs against symbols which turn out to be
@@ -3766,6 +3813,8 @@ index 00000000000..bf58b4b0a67
3766+ pp = &p->next; 3813+ pp = &p->next;
3767+ } 3814+ }
3768+ } 3815+ }
3816+ else if (UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
3817+ h->dyn_relocs = NULL;
3769+ } 3818+ }
3770+ else 3819+ else
3771+ { 3820+ {
@@ -3786,7 +3835,7 @@ index 00000000000..bf58b4b0a67
3786+ && !h->forced_local) 3835+ && !h->forced_local)
3787+ { 3836+ {
3788+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) 3837+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
3789+ return FALSE; 3838+ return false;
3790+ } 3839+ }
3791+ 3840+
3792+ /* If that succeeded, we know we'll be keeping all the 3841+ /* If that succeeded, we know we'll be keeping all the
@@ -3795,24 +3844,24 @@ index 00000000000..bf58b4b0a67
3795+ goto keep; 3844+ goto keep;
3796+ } 3845+ }
3797+ 3846+
3798+ eh->dyn_relocs = NULL; 3847+ h->dyn_relocs = NULL;
3799+ 3848+
3800+ keep: ; 3849+ keep: ;
3801+ } 3850+ }
3802+ 3851+
3803+ /* Finally, allocate space. */ 3852+ /* Finally, allocate space. */
3804+ for (p = eh->dyn_relocs; p != NULL; p = p->next) 3853+ for (p = h->dyn_relocs; p != NULL; p = p->next)
3805+ { 3854+ {
3806+ asection *sreloc = elf_section_data (p->sec)->sreloc; 3855+ asection *sreloc = elf_section_data (p->sec)->sreloc;
3807+ sreloc->size += p->count * sizeof (Elf64_External_Rela); 3856+ sreloc->size += p->count * sizeof (Elf64_External_Rela);
3808+ } 3857+ }
3809+ 3858+
3810+ return TRUE; 3859+ return true;
3811+} 3860+}
3812+ 3861+
3813+/* Set the sizes of the dynamic sections. */ 3862+/* Set the sizes of the dynamic sections. */
3814+ 3863+
3815+static bfd_boolean 3864+static bool
3816+microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, 3865+microblaze_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
3817+ struct bfd_link_info *info) 3866+ struct bfd_link_info *info)
3818+{ 3867+{
@@ -3823,7 +3872,7 @@ index 00000000000..bf58b4b0a67
3823+ 3872+
3824+ htab = elf64_mb_hash_table (info); 3873+ htab = elf64_mb_hash_table (info);
3825+ if (htab == NULL) 3874+ if (htab == NULL)
3826+ return FALSE; 3875+ return false;
3827+ 3876+
3828+ dynobj = htab->elf.dynobj; 3877+ dynobj = htab->elf.dynobj;
3829+ BFD_ASSERT (dynobj != NULL); 3878+ BFD_ASSERT (dynobj != NULL);
@@ -3844,7 +3893,7 @@ index 00000000000..bf58b4b0a67
3844+ 3893+
3845+ for (s = ibfd->sections; s != NULL; s = s->next) 3894+ for (s = ibfd->sections; s != NULL; s = s->next)
3846+ { 3895+ {
3847+ struct elf64_mb_dyn_relocs *p; 3896+ struct elf_dyn_relocs *p;
3848+ 3897+
3849+ for (p = ((struct elf64_mb_dyn_relocs *) 3898+ for (p = ((struct elf64_mb_dyn_relocs *)
3850+ elf_section_data (s)->local_dynrel); 3899+ elf_section_data (s)->local_dynrel);
@@ -3877,8 +3926,8 @@ index 00000000000..bf58b4b0a67
3877+ locsymcount = symtab_hdr->sh_info; 3926+ locsymcount = symtab_hdr->sh_info;
3878+ end_local_got = local_got + locsymcount; 3927+ end_local_got = local_got + locsymcount;
3879+ lgot_masks = (unsigned char *) end_local_got; 3928+ lgot_masks = (unsigned char *) end_local_got;
3880+ s = htab->sgot; 3929+ s = htab->elf.sgot;
3881+ srel = htab->srelgot; 3930+ srel = htab->elf.srelgot;
3882+ 3931+
3883+ for (; local_got < end_local_got; ++local_got, ++lgot_masks) 3932+ for (; local_got < end_local_got; ++local_got, ++lgot_masks)
3884+ { 3933+ {
@@ -3918,10 +3967,10 @@ index 00000000000..bf58b4b0a67
3918+ 3967+
3919+ if (htab->tlsld_got.refcount > 0) 3968+ if (htab->tlsld_got.refcount > 0)
3920+ { 3969+ {
3921+ htab->tlsld_got.offset = htab->sgot->size; 3970+ htab->tlsld_got.offset = htab->elf.sgot->size;
3922+ htab->sgot->size += 8; 3971+ htab->elf.sgot->size += 8;
3923+ if (bfd_link_pic (info)) 3972+ if (bfd_link_pic (info))
3924+ htab->srelgot->size += sizeof (Elf64_External_Rela); 3973+ htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
3925+ } 3974+ }
3926+ else 3975+ else
3927+ htab->tlsld_got.offset = (bfd_vma) -1; 3976+ htab->tlsld_got.offset = (bfd_vma) -1;
@@ -3929,8 +3978,8 @@ index 00000000000..bf58b4b0a67
3929+ if (elf_hash_table (info)->dynamic_sections_created) 3978+ if (elf_hash_table (info)->dynamic_sections_created)
3930+ { 3979+ {
3931+ /* Make space for the trailing nop in .plt. */ 3980+ /* Make space for the trailing nop in .plt. */
3932+ if (htab->splt->size > 0) 3981+ if (htab->elf.splt->size > 0)
3933+ htab->splt->size += 4; 3982+ htab->elf.splt->size += 4;
3934+ } 3983+ }
3935+ 3984+
3936+ /* The check_relocs and adjust_dynamic_symbol entry points have 3985+ /* The check_relocs and adjust_dynamic_symbol entry points have
@@ -3939,105 +3988,73 @@ index 00000000000..bf58b4b0a67
3939+ for (s = dynobj->sections; s != NULL; s = s->next) 3988+ for (s = dynobj->sections; s != NULL; s = s->next)
3940+ { 3989+ {
3941+ const char *name; 3990+ const char *name;
3942+ bfd_boolean strip = FALSE; 3991+ bool strip = false;
3943+ 3992+
3944+ if ((s->flags & SEC_LINKER_CREATED) == 0) 3993+ if ((s->flags & SEC_LINKER_CREATED) == 0)
3945+ continue; 3994+ continue;
3946+ 3995+
3947+ /* It's OK to base decisions on the section name, because none 3996+ /* It's OK to base decisions on the section name, because none
3948+ of the dynobj section names depend upon the input files. */ 3997+ of the dynobj section names depend upon the input files. */
3949+ name = bfd_section_name (s); 3998+ name = bfd_section_name (s);
3950+ 3999+
3951+ if (strncmp (name, ".rela", 5) == 0) 4000+ if (startswith (name, ".rela"))
3952+ { 4001+ {
3953+ if (s->size == 0) 4002+ if (s->size == 0)
3954+ { 4003+ {
3955+ /* If we don't need this section, strip it from the 4004+ /* If we don't need this section, strip it from the
3956+ output file. This is to handle .rela.bss and 4005+ output file. This is to handle .rela.bss and
3957+ .rela.plt. We must create it in 4006+ .rela.plt. We must create it in
3958+ create_dynamic_sections, because it must be created 4007+ create_dynamic_sections, because it must be created
3959+ before the linker maps input sections to output 4008+ before the linker maps input sections to output
3960+ sections. The linker does that before 4009+ sections. The linker does that before
3961+ adjust_dynamic_symbol is called, and it is that 4010+ adjust_dynamic_symbol is called, and it is that
3962+ function which decides whether anything needs to go 4011+ function which decides whether anything needs to go
3963+ into these sections. */ 4012+ into these sections. */
3964+ strip = TRUE; 4013+ strip = true;
3965+ } 4014+ }
3966+ else 4015+ else
3967+ { 4016+ {
3968+ /* We use the reloc_count field as a counter if we need 4017+ /* We use the reloc_count field as a counter if we need
3969+ to copy relocs into the output file. */ 4018+ to copy relocs into the output file. */
3970+ s->reloc_count = 0; 4019+ s->reloc_count = 0;
3971+ } 4020+ }
3972+ } 4021+ }
3973+ else if (s != htab->splt && s != htab->sgot && s != htab->sgotplt) 4022+ else if (s != htab->elf.splt
3974+ { 4023+ && s != htab->elf.sgot
3975+ /* It's not one of our sections, so don't allocate space. */ 4024+ && s != htab->elf.sgotplt
3976+ continue; 4025+ && s != htab->elf.sdynbss
3977+ } 4026+ && s != htab->elf.sdynrelro)
4027+ {
4028+ /* It's not one of our sections, so don't allocate space. */
4029+ continue;
4030+ }
3978+ 4031+
3979+ if (strip) 4032+ if (strip)
3980+ { 4033+ {
3981+ s->flags |= SEC_EXCLUDE; 4034+ s->flags |= SEC_EXCLUDE;
3982+ continue; 4035+ continue;
3983+ } 4036+ }
3984+ 4037+
3985+ /* Allocate memory for the section contents. */ 4038+ /* Allocate memory for the section contents. */
3986+ /* FIXME: This should be a call to bfd_alloc not bfd_zalloc. 4039+ /* FIXME: This should be a call to bfd_alloc not bfd_zalloc.
3987+ Unused entries should be reclaimed before the section's contents 4040+ Unused entries should be reclaimed before the section's contents
3988+ are written out, but at the moment this does not happen. Thus in 4041+ are written out, but at the moment this does not happen. Thus in
3989+ order to prevent writing out garbage, we initialise the section's 4042+ order to prevent writing out garbage, we initialise the section's
3990+ contents to zero. */ 4043+ contents to zero. */
3991+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); 4044+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
3992+ if (s->contents == NULL && s->size != 0) 4045+ if (s->contents == NULL && s->size != 0)
3993+ return FALSE; 4046+ return false;
3994+ } 4047+ }
3995+ 4048+
3996+ if (elf_hash_table (info)->dynamic_sections_created) 4049+ /* ??? Force DF_BIND_NOW? */
3997+ { 4050+ info->flags |= DF_BIND_NOW;
3998+ /* Add some entries to the .dynamic section. We fill in the 4051+ return _bfd_elf_add_dynamic_tags (output_bfd, info, true);
3999+ values later, in microblaze_elf_finish_dynamic_sections, but we
4000+ must add the entries now so that we get the correct size for
4001+ the .dynamic section. The DT_DEBUG entry is filled in by the
4002+ dynamic linker and used by the debugger. */
4003+#define add_dynamic_entry(TAG, VAL) \
4004+ _bfd_elf_add_dynamic_entry (info, TAG, VAL)
4005+
4006+ if (bfd_link_executable (info))
4007+ {
4008+ if (!add_dynamic_entry (DT_DEBUG, 0))
4009+ return FALSE;
4010+ }
4011+
4012+ if (!add_dynamic_entry (DT_RELA, 0)
4013+ || !add_dynamic_entry (DT_RELASZ, 0)
4014+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
4015+ return FALSE;
4016+
4017+ if (htab->splt->size != 0)
4018+ {
4019+ if (!add_dynamic_entry (DT_PLTGOT, 0)
4020+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
4021+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
4022+ || !add_dynamic_entry (DT_JMPREL, 0)
4023+ || !add_dynamic_entry (DT_BIND_NOW, 1))
4024+ return FALSE;
4025+ }
4026+
4027+ if (info->flags & DF_TEXTREL)
4028+ {
4029+ if (!add_dynamic_entry (DT_TEXTREL, 0))
4030+ return FALSE;
4031+ }
4032+ }
4033+#undef add_dynamic_entry
4034+ return TRUE;
4035+} 4052+}
4036+ 4053+
4037+/* Finish up dynamic symbol handling. We set the contents of various 4054+/* Finish up dynamic symbol handling. We set the contents of various
4038+ dynamic sections here. */ 4055+ dynamic sections here. */
4039+ 4056+
4040+static bfd_boolean 4057+static bool
4041+microblaze_elf_finish_dynamic_symbol (bfd *output_bfd, 4058+microblaze_elf_finish_dynamic_symbol (bfd *output_bfd,
4042+ struct bfd_link_info *info, 4059+ struct bfd_link_info *info,
4043+ struct elf_link_hash_entry *h, 4060+ struct elf_link_hash_entry *h,
@@ -4048,7 +4065,7 @@ index 00000000000..bf58b4b0a67
4048+ 4065+
4049+ htab = elf64_mb_hash_table (info); 4066+ htab = elf64_mb_hash_table (info);
4050+ if (htab == NULL) 4067+ if (htab == NULL)
4051+ return FALSE; 4068+ return false;
4052+ 4069+
4053+ if (h->plt.offset != (bfd_vma) -1) 4070+ if (h->plt.offset != (bfd_vma) -1)
4054+ { 4071+ {
@@ -4065,9 +4082,9 @@ index 00000000000..bf58b4b0a67
4065+ it up. */ 4082+ it up. */
4066+ BFD_ASSERT (h->dynindx != -1); 4083+ BFD_ASSERT (h->dynindx != -1);
4067+ 4084+
4068+ splt = htab->splt; 4085+ splt = htab->elf.splt;
4069+ srela = htab->srelplt; 4086+ srela = htab->elf.srelplt;
4070+ sgotplt = htab->sgotplt; 4087+ sgotplt = htab->elf.sgotplt;
4071+ BFD_ASSERT (splt != NULL && srela != NULL && sgotplt != NULL); 4088+ BFD_ASSERT (splt != NULL && srela != NULL && sgotplt != NULL);
4072+ 4089+
4073+ plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; /* first entry reserved. */ 4090+ plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; /* first entry reserved. */
@@ -4076,7 +4093,7 @@ index 00000000000..bf58b4b0a67
4076+ 4093+
4077+ /* For non-PIC objects we need absolute address of the GOT entry. */ 4094+ /* For non-PIC objects we need absolute address of the GOT entry. */
4078+ if (!bfd_link_pic (info)) 4095+ if (!bfd_link_pic (info))
4079+ got_addr += htab->sgotplt->output_section->vma + sgotplt->output_offset; 4096+ got_addr += sgotplt->output_section->vma + sgotplt->output_offset;
4080+ 4097+
4081+ /* Fill in the entry in the procedure linkage table. */ 4098+ /* Fill in the entry in the procedure linkage table. */
4082+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_0 + ((got_addr >> 16) & 0xffff), 4099+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD_0 + ((got_addr >> 16) & 0xffff),
@@ -4128,8 +4145,8 @@ index 00000000000..bf58b4b0a67
4128+ /* This symbol has an entry in the global offset table. Set it 4145+ /* This symbol has an entry in the global offset table. Set it
4129+ up. */ 4146+ up. */
4130+ 4147+
4131+ sgot = htab->sgot; 4148+ sgot = htab->elf.sgot;
4132+ srela = htab->srelgot; 4149+ srela = htab->elf.srelgot;
4133+ BFD_ASSERT (sgot != NULL && srela != NULL); 4150+ BFD_ASSERT (sgot != NULL && srela != NULL);
4134+ 4151+
4135+ offset = (sgot->output_section->vma + sgot->output_offset 4152+ offset = (sgot->output_section->vma + sgot->output_offset
@@ -4143,16 +4160,23 @@ index 00000000000..bf58b4b0a67
4143+ if (bfd_link_pic (info) 4160+ if (bfd_link_pic (info)
4144+ && ((info->symbolic && h->def_regular) 4161+ && ((info->symbolic && h->def_regular)
4145+ || h->dynindx == -1)) 4162+ || h->dynindx == -1))
4146+ { 4163+ {
4147+ asection *sec = h->root.u.def.section; 4164+ asection *sec = h->root.u.def.section;
4148+ microblaze_elf_output_dynamic_relocation (output_bfd, 4165+ bfd_vma value;
4149+ srela, srela->reloc_count++, 4166+
4150+ /* symindex= */ 0, 4167+ value = h->root.u.def.value;
4151+ R_MICROBLAZE_REL, offset, 4168+ if (sec->output_section != NULL)
4152+ h->root.u.def.value 4169+ /* PR 21180: If the output section is NULL, then the symbol is no
4153+ + sec->output_section->vma 4170+ longer needed, and in theory the GOT entry is redundant. But
4154+ + sec->output_offset); 4171+ it is too late to change our minds now... */
4155+ } 4172+ value += sec->output_section->vma + sec->output_offset;
4173+
4174+ microblaze_elf_output_dynamic_relocation (output_bfd,
4175+ srela, srela->reloc_count++,
4176+ /* symindex= */ 0,
4177+ R_MICROBLAZE_REL, offset,
4178+ value);
4179+ }
4156+ else 4180+ else
4157+ { 4181+ {
4158+ microblaze_elf_output_dynamic_relocation (output_bfd, 4182+ microblaze_elf_output_dynamic_relocation (output_bfd,
@@ -4176,16 +4200,17 @@ index 00000000000..bf58b4b0a67
4176+ 4200+
4177+ BFD_ASSERT (h->dynindx != -1); 4201+ BFD_ASSERT (h->dynindx != -1);
4178+ 4202+
4179+ s = bfd_get_linker_section (htab->elf.dynobj, ".rela.bss");
4180+ BFD_ASSERT (s != NULL);
4181+
4182+ rela.r_offset = (h->root.u.def.value 4203+ rela.r_offset = (h->root.u.def.value
4183+ + h->root.u.def.section->output_section->vma 4204+ + h->root.u.def.section->output_section->vma
4184+ + h->root.u.def.section->output_offset); 4205+ + h->root.u.def.section->output_offset);
4185+ rela.r_info = ELF64_R_INFO (h->dynindx, R_MICROBLAZE_COPY); 4206+ rela.r_info = ELF64_R_INFO (h->dynindx, R_MICROBLAZE_COPY);
4186+ rela.r_addend = 0; 4207+ rela.r_addend = 0;
4187+ loc = s->contents + s->reloc_count++ * sizeof (Elf64_External_Rela); 4208+ if (h->root.u.def.section == htab->elf.sdynrelro)
4188+ bfd_elf64_swap_reloca_out (output_bfd, &rela, loc); 4209+ s = htab->elf.sreldynrelro;
4210+ else
4211+ s = htab->elf.srelbss;
4212+ loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
4213+ bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
4189+ } 4214+ }
4190+ 4215+
4191+ /* Mark some specially defined symbols as absolute. */ 4216+ /* Mark some specially defined symbols as absolute. */
@@ -4194,13 +4219,13 @@ index 00000000000..bf58b4b0a67
4194+ || h == htab->elf.hplt) 4219+ || h == htab->elf.hplt)
4195+ sym->st_shndx = SHN_ABS; 4220+ sym->st_shndx = SHN_ABS;
4196+ 4221+
4197+ return TRUE; 4222+ return true;
4198+} 4223+}
4199+ 4224+
4200+ 4225+
4201+/* Finish up the dynamic sections. */ 4226+/* Finish up the dynamic sections. */
4202+ 4227+
4203+static bfd_boolean 4228+static bool
4204+microblaze_elf_finish_dynamic_sections (bfd *output_bfd, 4229+microblaze_elf_finish_dynamic_sections (bfd *output_bfd,
4205+ struct bfd_link_info *info) 4230+ struct bfd_link_info *info)
4206+{ 4231+{
@@ -4210,7 +4235,7 @@ index 00000000000..bf58b4b0a67
4210+ 4235+
4211+ htab = elf64_mb_hash_table (info); 4236+ htab = elf64_mb_hash_table (info);
4212+ if (htab == NULL) 4237+ if (htab == NULL)
4213+ return FALSE; 4238+ return false;
4214+ 4239+
4215+ dynobj = htab->elf.dynobj; 4240+ dynobj = htab->elf.dynobj;
4216+ 4241+
@@ -4221,62 +4246,68 @@ index 00000000000..bf58b4b0a67
4221+ asection *splt; 4246+ asection *splt;
4222+ Elf64_External_Dyn *dyncon, *dynconend; 4247+ Elf64_External_Dyn *dyncon, *dynconend;
4223+ 4248+
4224+ splt = bfd_get_linker_section (dynobj, ".plt");
4225+ BFD_ASSERT (splt != NULL && sdyn != NULL);
4226+
4227+ dyncon = (Elf64_External_Dyn *) sdyn->contents; 4249+ dyncon = (Elf64_External_Dyn *) sdyn->contents;
4228+ dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size); 4250+ dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size);
4229+ for (; dyncon < dynconend; dyncon++) 4251+ for (; dyncon < dynconend; dyncon++)
4230+ { 4252+ {
4231+ Elf_Internal_Dyn dyn; 4253+ Elf_Internal_Dyn dyn;
4232+ const char *name; 4254+ asection *s;
4233+ bfd_boolean size; 4255+ bool size;
4234+ 4256+
4235+ bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn); 4257+ bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
4236+ 4258+
4237+ switch (dyn.d_tag) 4259+ switch (dyn.d_tag)
4238+ { 4260+ {
4239+ case DT_PLTGOT: name = ".got.plt"; size = FALSE; break; 4261+ case DT_PLTGOT:
4240+ case DT_PLTRELSZ: name = ".rela.plt"; size = TRUE; break; 4262+ s = htab->elf.sgotplt;
4241+ case DT_JMPREL: name = ".rela.plt"; size = FALSE; break; 4263+ size = false;
4242+ case DT_RELA: name = ".rela.dyn"; size = FALSE; break; 4264+ break;
4243+ case DT_RELASZ: name = ".rela.dyn"; size = TRUE; break;
4244+ default: name = NULL; size = FALSE; break;
4245+ }
4246+ 4265+
4247+ if (name != NULL) 4266+ case DT_PLTRELSZ:
4248+ { 4267+ s = htab->elf.srelplt;
4249+ asection *s; 4268+ size = true;
4269+ break;
4250+ 4270+
4251+ s = bfd_get_section_by_name (output_bfd, name); 4271+ case DT_JMPREL:
4252+ if (s == NULL) 4272+ s = htab->elf.srelplt;
4253+ dyn.d_un.d_val = 0; 4273+ size = false;
4254+ else 4274+ break;
4255+ { 4275+
4256+ if (! size) 4276+ default:
4257+ dyn.d_un.d_ptr = s->vma; 4277+ continue;
4258+ else 4278+ }
4259+ dyn.d_un.d_val = s->size; 4279+
4260+ } 4280+ if (s == NULL)
4261+ bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); 4281+ dyn.d_un.d_val = 0;
4262+ } 4282+ else
4263+ } 4283+ {
4284+ if (!size)
4285+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
4286+ else
4287+ dyn.d_un.d_val = s->size;
4288+ }
4289+ bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
4290+ }
4291+
4292+ splt = htab->elf.splt;
4293+ BFD_ASSERT (splt != NULL && sdyn != NULL);
4264+ 4294+
4265+ /* Clear the first entry in the procedure linkage table, 4295+ /* Clear the first entry in the procedure linkage table,
4266+ and put a nop in the last four bytes. */ 4296+ and put a nop in the last four bytes. */
4267+ if (splt->size > 0) 4297+ if (splt->size > 0)
4268+ { 4298+ {
4269+ memset (splt->contents, 0, PLT_ENTRY_SIZE); 4299+ memset (splt->contents, 0, PLT_ENTRY_SIZE);
4270+ bfd_put_32 (output_bfd, (bfd_vma) 0x80000000 /* nop. */, 4300+ bfd_put_32 (output_bfd, (bfd_vma) 0x80000000 /* nop. */,
4271+ splt->contents + splt->size - 4); 4301+ splt->contents + splt->size - 4);
4272+ }
4273+ 4302+
4274+ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4; 4303+ if (splt->output_section != bfd_abs_section_ptr)
4304+ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
4305+ }
4275+ } 4306+ }
4276+ 4307+
4277+ /* Set the first entry in the global offset table to the address of 4308+ /* Set the first entry in the global offset table to the address of
4278+ the dynamic section. */ 4309+ the dynamic section. */
4279+ sgot = bfd_get_linker_section (dynobj, ".got.plt"); 4310+ sgot = htab->elf.sgotplt;
4280+ if (sgot && sgot->size > 0) 4311+ if (sgot && sgot->size > 0)
4281+ { 4312+ {
4282+ if (sdyn == NULL) 4313+ if (sdyn == NULL)
@@ -4288,26 +4319,16 @@ index 00000000000..bf58b4b0a67
4288+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; 4319+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
4289+ } 4320+ }
4290+ 4321+
4291+ if (htab->sgot && htab->sgot->size > 0) 4322+ if (htab->elf.sgot && htab->elf.sgot->size > 0)
4292+ elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 4; 4323+ elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize = 4;
4293+
4294+ return TRUE;
4295+}
4296+ 4324+
4297+static bfd_boolean 4325+ return true;
4298+microblaze_elf_object_p (bfd *abfd)
4299+{
4300+ bfd_default_set_arch_mach (abfd, bfd_arch_microblaze,
4301+ bfd_mach_microblaze64);
4302+ return TRUE;
4303+} 4326+}
4304+
4305+
4306+ 4327+
4307+/* Hook called by the linker routine which adds symbols from an object 4328+/* Hook called by the linker routine which adds symbols from an object
4308+ file. We use it to put .comm items in .sbss, and not .bss. */ 4329+ file. We use it to put .comm items in .sbss, and not .bss. */
4309+ 4330+
4310+static bfd_boolean 4331+static bool
4311+microblaze_elf_add_symbol_hook (bfd *abfd, 4332+microblaze_elf_add_symbol_hook (bfd *abfd,
4312+ struct bfd_link_info *info, 4333+ struct bfd_link_info *info,
4313+ Elf_Internal_Sym *sym, 4334+ Elf_Internal_Sym *sym,
@@ -4324,13 +4345,13 @@ index 00000000000..bf58b4b0a67
4324+ put into .sbss. */ 4345+ put into .sbss. */
4325+ *secp = bfd_make_section_old_way (abfd, ".sbss"); 4346+ *secp = bfd_make_section_old_way (abfd, ".sbss");
4326+ if (*secp == NULL 4347+ if (*secp == NULL
4327+ || ! bfd_set_section_flags (*secp, SEC_IS_COMMON)) 4348+ || !bfd_set_section_flags (*secp, SEC_IS_COMMON | SEC_SMALL_DATA))
4328+ return FALSE; 4349+ return false;
4329+ 4350+
4330+ *valp = sym->st_size; 4351+ *valp = sym->st_size;
4331+ } 4352+ }
4332+ 4353+
4333+ return TRUE; 4354+ return true;
4334+} 4355+}
4335+ 4356+
4336+#define TARGET_LITTLE_SYM microblaze_elf64_le_vec 4357+#define TARGET_LITTLE_SYM microblaze_elf64_le_vec
@@ -4349,6 +4370,7 @@ index 00000000000..bf58b4b0a67
4349+ 4370+
4350+#define bfd_elf64_bfd_reloc_type_lookup microblaze_elf_reloc_type_lookup 4371+#define bfd_elf64_bfd_reloc_type_lookup microblaze_elf_reloc_type_lookup
4351+#define bfd_elf64_bfd_is_local_label_name microblaze_elf_is_local_label_name 4372+#define bfd_elf64_bfd_is_local_label_name microblaze_elf_is_local_label_name
4373+#define bfd_elf64_new_section_hook microblaze_elf_new_section_hook
4352+#define elf_backend_relocate_section microblaze_elf_relocate_section 4374+#define elf_backend_relocate_section microblaze_elf_relocate_section
4353+#define bfd_elf64_bfd_relax_section microblaze_elf_relax_section 4375+#define bfd_elf64_bfd_relax_section microblaze_elf_relax_section
4354+#define bfd_elf64_bfd_merge_private_bfd_data microblaze_elf_merge_private_bfd_data 4376+#define bfd_elf64_bfd_merge_private_bfd_data microblaze_elf_merge_private_bfd_data
@@ -4360,11 +4382,13 @@ index 00000000000..bf58b4b0a67
4360+#define elf_backend_copy_indirect_symbol microblaze_elf_copy_indirect_symbol 4382+#define elf_backend_copy_indirect_symbol microblaze_elf_copy_indirect_symbol
4361+#define bfd_elf64_bfd_link_hash_table_create microblaze_elf_link_hash_table_create 4383+#define bfd_elf64_bfd_link_hash_table_create microblaze_elf_link_hash_table_create
4362+#define elf_backend_can_gc_sections 1 4384+#define elf_backend_can_gc_sections 1
4363+#define elf_backend_can_refcount 1 4385+#define elf_backend_can_refcount 1
4364+#define elf_backend_want_got_plt 1 4386+#define elf_backend_want_got_plt 1
4365+#define elf_backend_plt_readonly 1 4387+#define elf_backend_plt_readonly 1
4366+#define elf_backend_got_header_size 12 4388+#define elf_backend_got_header_size 12
4367+#define elf_backend_rela_normal 1 4389+#define elf_backend_want_dynrelro 1
4390+#define elf_backend_rela_normal 1
4391+#define elf_backend_dtrel_excludes_plt 1
4368+ 4392+
4369+#define elf_backend_adjust_dynamic_symbol microblaze_elf_adjust_dynamic_symbol 4393+#define elf_backend_adjust_dynamic_symbol microblaze_elf_adjust_dynamic_symbol
4370+#define elf_backend_create_dynamic_sections microblaze_elf_create_dynamic_sections 4394+#define elf_backend_create_dynamic_sections microblaze_elf_create_dynamic_sections
@@ -4372,14 +4396,13 @@ index 00000000000..bf58b4b0a67
4372+#define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol 4396+#define elf_backend_finish_dynamic_symbol microblaze_elf_finish_dynamic_symbol
4373+#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections 4397+#define elf_backend_size_dynamic_sections microblaze_elf_size_dynamic_sections
4374+#define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook 4398+#define elf_backend_add_symbol_hook microblaze_elf_add_symbol_hook
4375+#define elf_backend_object_p microblaze_elf_object_p
4376+ 4399+
4377+#include "elf64-target.h" 4400+#include "elf64-target.h"
4378diff --git a/bfd/libbfd.h b/bfd/libbfd.h 4401diff --git a/bfd/libbfd.h b/bfd/libbfd.h
4379index 74d7e4111d3..311fec7f2e8 100644 4402index 6e62e556962..ef5568a78b0 100644
4380--- a/bfd/libbfd.h 4403--- a/bfd/libbfd.h
4381+++ b/bfd/libbfd.h 4404+++ b/bfd/libbfd.h
4382@@ -2971,6 +2971,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", 4405@@ -2992,6 +2992,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
4383 "BFD_RELOC_MICROBLAZE_32_ROSDA", 4406 "BFD_RELOC_MICROBLAZE_32_ROSDA",
4384 "BFD_RELOC_MICROBLAZE_32_RWSDA", 4407 "BFD_RELOC_MICROBLAZE_32_RWSDA",
4385 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM", 4408 "BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM",
@@ -4387,7 +4410,7 @@ index 74d7e4111d3..311fec7f2e8 100644
4387 "BFD_RELOC_MICROBLAZE_64_NONE", 4410 "BFD_RELOC_MICROBLAZE_64_NONE",
4388 "BFD_RELOC_MICROBLAZE_64_GOTPC", 4411 "BFD_RELOC_MICROBLAZE_64_GOTPC",
4389 "BFD_RELOC_MICROBLAZE_64_GOT", 4412 "BFD_RELOC_MICROBLAZE_64_GOT",
4390@@ -2978,6 +2979,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", 4413@@ -2999,6 +3000,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
4391 "BFD_RELOC_MICROBLAZE_64_GOTOFF", 4414 "BFD_RELOC_MICROBLAZE_64_GOTOFF",
4392 "BFD_RELOC_MICROBLAZE_32_GOTOFF", 4415 "BFD_RELOC_MICROBLAZE_32_GOTOFF",
4393 "BFD_RELOC_MICROBLAZE_COPY", 4416 "BFD_RELOC_MICROBLAZE_COPY",
@@ -4397,10 +4420,10 @@ index 74d7e4111d3..311fec7f2e8 100644
4397 "BFD_RELOC_MICROBLAZE_64_TLSGD", 4420 "BFD_RELOC_MICROBLAZE_64_TLSGD",
4398 "BFD_RELOC_MICROBLAZE_64_TLSLD", 4421 "BFD_RELOC_MICROBLAZE_64_TLSLD",
4399diff --git a/bfd/reloc.c b/bfd/reloc.c 4422diff --git a/bfd/reloc.c b/bfd/reloc.c
4400index dc923fe39c2..d2204ded537 100644 4423index 164060361a9..e733e2397f4 100644
4401--- a/bfd/reloc.c 4424--- a/bfd/reloc.c
4402+++ b/bfd/reloc.c 4425+++ b/bfd/reloc.c
4403@@ -6867,6 +6867,12 @@ ENUM 4426@@ -6898,6 +6898,12 @@ ENUM
4404 ENUMDOC 4427 ENUMDOC
4405 This is a 32 bit reloc for the microblaze to handle 4428 This is a 32 bit reloc for the microblaze to handle
4406 expressions of the form "Symbol Op Symbol" 4429 expressions of the form "Symbol Op Symbol"
@@ -4413,7 +4436,7 @@ index dc923fe39c2..d2204ded537 100644
4413 ENUM 4436 ENUM
4414 BFD_RELOC_MICROBLAZE_64_NONE 4437 BFD_RELOC_MICROBLAZE_64_NONE
4415 ENUMDOC 4438 ENUMDOC
4416@@ -6960,6 +6966,20 @@ ENUMDOC 4439@@ -6991,6 +6997,20 @@ ENUMDOC
4417 value in two words (with an imm instruction). The relocation is 4440 value in two words (with an imm instruction). The relocation is
4418 relative offset from start of TEXT. 4441 relative offset from start of TEXT.
4419 4442
@@ -4435,10 +4458,10 @@ index dc923fe39c2..d2204ded537 100644
4435 BFD_RELOC_AARCH64_RELOC_START 4458 BFD_RELOC_AARCH64_RELOC_START
4436 ENUMDOC 4459 ENUMDOC
4437diff --git a/bfd/targets.c b/bfd/targets.c 4460diff --git a/bfd/targets.c b/bfd/targets.c
4438index 35492b92bbe..99fbfdf6cd8 100644 4461index 417743efc0e..333f05c55f4 100644
4439--- a/bfd/targets.c 4462--- a/bfd/targets.c
4440+++ b/bfd/targets.c 4463+++ b/bfd/targets.c
4441@@ -782,6 +782,8 @@ extern const bfd_target mep_elf32_le_vec; 4464@@ -795,6 +795,8 @@ extern const bfd_target mep_elf32_le_vec;
4442 extern const bfd_target metag_elf32_vec; 4465 extern const bfd_target metag_elf32_vec;
4443 extern const bfd_target microblaze_elf32_vec; 4466 extern const bfd_target microblaze_elf32_vec;
4444 extern const bfd_target microblaze_elf32_le_vec; 4467 extern const bfd_target microblaze_elf32_le_vec;
@@ -4447,7 +4470,7 @@ index 35492b92bbe..99fbfdf6cd8 100644
4447 extern const bfd_target mips_ecoff_be_vec; 4470 extern const bfd_target mips_ecoff_be_vec;
4448 extern const bfd_target mips_ecoff_le_vec; 4471 extern const bfd_target mips_ecoff_le_vec;
4449 extern const bfd_target mips_ecoff_bele_vec; 4472 extern const bfd_target mips_ecoff_bele_vec;
4450@@ -1146,6 +1148,10 @@ static const bfd_target * const _bfd_target_vector[] = 4473@@ -1165,6 +1167,10 @@ static const bfd_target * const _bfd_target_vector[] =
4451 4474
4452 &metag_elf32_vec, 4475 &metag_elf32_vec,
4453 4476
@@ -4459,18 +4482,10 @@ index 35492b92bbe..99fbfdf6cd8 100644
4459 4482
4460 &mips_ecoff_be_vec, 4483 &mips_ecoff_be_vec,
4461diff --git a/gdb/features/Makefile b/gdb/features/Makefile 4484diff --git a/gdb/features/Makefile b/gdb/features/Makefile
4462index 67c3ae17a77..131fc14adbf 100644 4485index fc3196864c9..1bb198abfd3 100644
4463--- a/gdb/features/Makefile 4486--- a/gdb/features/Makefile
4464+++ b/gdb/features/Makefile 4487+++ b/gdb/features/Makefile
4465@@ -46,6 +46,7 @@ 4488@@ -101,7 +101,9 @@ OUTPUTS = $(patsubst %,$(outdir)/%.dat,$(WHICH))
4466 # List of .dat files to create in ../regformats/
4467 WHICH = mips-linux mips-dsp-linux \
4468 microblaze-with-stack-protect \
4469+ microblaze64-with-stack-protect \
4470 mips64-linux mips64-dsp-linux \
4471 nios2-linux \
4472 rs6000/powerpc-32 \
4473@@ -107,7 +108,9 @@ OUTPUTS = $(patsubst %,$(outdir)/%.dat,$(WHICH))
4474 # to make on the command line. 4489 # to make on the command line.
4475 XMLTOC = \ 4490 XMLTOC = \
4476 microblaze-with-stack-protect.xml \ 4491 microblaze-with-stack-protect.xml \
@@ -4481,7 +4496,7 @@ index 67c3ae17a77..131fc14adbf 100644
4481 mips-linux.xml \ 4496 mips-linux.xml \
4482 mips64-dsp-linux.xml \ 4497 mips64-dsp-linux.xml \
4483diff --git a/gdb/features/microblaze-core.xml b/gdb/features/microblaze-core.xml 4498diff --git a/gdb/features/microblaze-core.xml b/gdb/features/microblaze-core.xml
4484index 47fb4fb4b51..b2ee4f11bc2 100644 4499index 29fdd6c0a2f..a5c3cce069d 100644
4485--- a/gdb/features/microblaze-core.xml 4500--- a/gdb/features/microblaze-core.xml
4486+++ b/gdb/features/microblaze-core.xml 4501+++ b/gdb/features/microblaze-core.xml
4487@@ -8,7 +8,7 @@ 4502@@ -8,7 +8,7 @@
@@ -4510,7 +4525,7 @@ index 47fb4fb4b51..b2ee4f11bc2 100644
4510+ <reg name="shr" bitsize="32"/> 4525+ <reg name="shr" bitsize="32"/>
4511 </feature> 4526 </feature>
4512diff --git a/gdb/features/microblaze-stack-protect.xml b/gdb/features/microblaze-stack-protect.xml 4527diff --git a/gdb/features/microblaze-stack-protect.xml b/gdb/features/microblaze-stack-protect.xml
4513index 2b95c2f2bcf..9efe6114128 100644 4528index aac51ea471c..722a51f0df5 100644
4514--- a/gdb/features/microblaze-stack-protect.xml 4529--- a/gdb/features/microblaze-stack-protect.xml
4515+++ b/gdb/features/microblaze-stack-protect.xml 4530+++ b/gdb/features/microblaze-stack-protect.xml
4516@@ -7,6 +7,6 @@ 4531@@ -7,6 +7,6 @@
@@ -4523,12 +4538,12 @@ index 2b95c2f2bcf..9efe6114128 100644
4523+ <reg name="shr" bitsize="32"/> 4538+ <reg name="shr" bitsize="32"/>
4524 </feature> 4539 </feature>
4525diff --git a/gdb/features/microblaze-with-stack-protect.c b/gdb/features/microblaze-with-stack-protect.c 4540diff --git a/gdb/features/microblaze-with-stack-protect.c b/gdb/features/microblaze-with-stack-protect.c
4526index b39aa198874..609934e2b41 100644 4541index aa180bf35d5..6a9e74c7a6f 100644
4527--- a/gdb/features/microblaze-with-stack-protect.c 4542--- a/gdb/features/microblaze-with-stack-protect.c
4528+++ b/gdb/features/microblaze-with-stack-protect.c 4543+++ b/gdb/features/microblaze-with-stack-protect.c
4529@@ -14,7 +14,7 @@ initialize_tdesc_microblaze_with_stack_protect (void) 4544@@ -14,7 +14,7 @@ initialize_tdesc_microblaze_with_stack_protect (void)
4530 4545
4531 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.core"); 4546 feature = tdesc_create_feature (result.get (), "org.gnu.gdb.microblaze.core");
4532 tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int"); 4547 tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
4533- tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "data_ptr"); 4548- tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "data_ptr");
4534+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int"); 4549+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
@@ -4547,21 +4562,21 @@ index b39aa198874..609934e2b41 100644
4547@@ -72,8 +72,8 @@ initialize_tdesc_microblaze_with_stack_protect (void) 4562@@ -72,8 +72,8 @@ initialize_tdesc_microblaze_with_stack_protect (void)
4548 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int"); 4563 tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
4549 4564
4550 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.stack-protect"); 4565 feature = tdesc_create_feature (result.get (), "org.gnu.gdb.microblaze.stack-protect");
4551- tdesc_create_reg (feature, "rslr", 57, 1, NULL, 32, "int"); 4566- tdesc_create_reg (feature, "rslr", 57, 1, NULL, 32, "int");
4552- tdesc_create_reg (feature, "rshr", 58, 1, NULL, 32, "int"); 4567- tdesc_create_reg (feature, "rshr", 58, 1, NULL, 32, "int");
4553+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 32, "int"); 4568+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 32, "int");
4554+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 32, "int"); 4569+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 32, "int");
4555 4570
4556 tdesc_microblaze_with_stack_protect = result; 4571 tdesc_microblaze_with_stack_protect = result.release ();
4557 } 4572 }
4558diff --git a/gdb/features/microblaze.c b/gdb/features/microblaze.c 4573diff --git a/gdb/features/microblaze.c b/gdb/features/microblaze.c
4559index 6c86fc07700..ceb98ca8b82 100644 4574index ef2c64c720e..201232dff83 100644
4560--- a/gdb/features/microblaze.c 4575--- a/gdb/features/microblaze.c
4561+++ b/gdb/features/microblaze.c 4576+++ b/gdb/features/microblaze.c
4562@@ -14,7 +14,7 @@ initialize_tdesc_microblaze (void) 4577@@ -14,7 +14,7 @@ initialize_tdesc_microblaze (void)
4563 4578
4564 feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze.core"); 4579 feature = tdesc_create_feature (result.get (), "org.gnu.gdb.microblaze.core");
4565 tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int"); 4580 tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int");
4566- tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "data_ptr"); 4581- tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "data_ptr");
4567+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int"); 4582+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int");
@@ -4584,7 +4599,7 @@ index 6c86fc07700..ceb98ca8b82 100644
4584+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64"); 4599+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
4585+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64"); 4600+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
4586 4601
4587 tdesc_microblaze = result; 4602 tdesc_microblaze = result.release ();
4588 } 4603 }
4589diff --git a/gdb/features/microblaze64-core.xml b/gdb/features/microblaze64-core.xml 4604diff --git a/gdb/features/microblaze64-core.xml b/gdb/features/microblaze64-core.xml
4590new file mode 100644 4605new file mode 100644
@@ -4681,7 +4696,7 @@ index 00000000000..1bbf5fc3cea
4681+</feature> 4696+</feature>
4682diff --git a/gdb/features/microblaze64-with-stack-protect.c b/gdb/features/microblaze64-with-stack-protect.c 4697diff --git a/gdb/features/microblaze64-with-stack-protect.c b/gdb/features/microblaze64-with-stack-protect.c
4683new file mode 100644 4698new file mode 100644
4684index 00000000000..f448c9a749c 4699index 00000000000..a4de4666c76
4685--- /dev/null 4700--- /dev/null
4686+++ b/gdb/features/microblaze64-with-stack-protect.c 4701+++ b/gdb/features/microblaze64-with-stack-protect.c
4687@@ -0,0 +1,79 @@ 4702@@ -0,0 +1,79 @@
@@ -4696,10 +4711,10 @@ index 00000000000..f448c9a749c
4696+static void 4711+static void
4697+initialize_tdesc_microblaze64_with_stack_protect (void) 4712+initialize_tdesc_microblaze64_with_stack_protect (void)
4698+{ 4713+{
4699+ struct target_desc *result = allocate_target_description (); 4714+ target_desc_up result = allocate_target_description ();
4700+ struct tdesc_feature *feature; 4715+ struct tdesc_feature *feature;
4701+ 4716+
4702+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.core"); 4717+ feature = tdesc_create_feature (result.get() , "org.gnu.gdb.microblaze64.core");
4703+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64"); 4718+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64");
4704+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64"); 4719+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64");
4705+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64"); 4720+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64");
@@ -4758,11 +4773,11 @@ index 00000000000..f448c9a749c
4758+ tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int"); 4773+ tdesc_create_reg (feature, "rtlblo", 55, 1, NULL, 32, "int");
4759+ tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int"); 4774+ tdesc_create_reg (feature, "rtlbhi", 56, 1, NULL, 32, "int");
4760+ 4775+
4761+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.stack-protect"); 4776+ feature = tdesc_create_feature (result.get(), "org.gnu.gdb.microblaze64.stack-protect");
4762+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64"); 4777+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
4763+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64"); 4778+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
4764+ 4779+
4765+ tdesc_microblaze64_with_stack_protect = result; 4780+ tdesc_microblaze64_with_stack_protect = result.release();
4766+} 4781+}
4767diff --git a/gdb/features/microblaze64-with-stack-protect.xml b/gdb/features/microblaze64-with-stack-protect.xml 4782diff --git a/gdb/features/microblaze64-with-stack-protect.xml b/gdb/features/microblaze64-with-stack-protect.xml
4768new file mode 100644 4783new file mode 100644
@@ -4784,7 +4799,7 @@ index 00000000000..0e9f01611f3
4784+</target> 4799+</target>
4785diff --git a/gdb/features/microblaze64.c b/gdb/features/microblaze64.c 4800diff --git a/gdb/features/microblaze64.c b/gdb/features/microblaze64.c
4786new file mode 100644 4801new file mode 100644
4787index 00000000000..1aa37c45129 4802index 00000000000..8ab7a90dd95
4788--- /dev/null 4803--- /dev/null
4789+++ b/gdb/features/microblaze64.c 4804+++ b/gdb/features/microblaze64.c
4790@@ -0,0 +1,77 @@ 4805@@ -0,0 +1,77 @@
@@ -4799,10 +4814,10 @@ index 00000000000..1aa37c45129
4799+static void 4814+static void
4800+initialize_tdesc_microblaze64 (void) 4815+initialize_tdesc_microblaze64 (void)
4801+{ 4816+{
4802+ struct target_desc *result = allocate_target_description (); 4817+ target_desc_up result = allocate_target_description ();
4803+ struct tdesc_feature *feature; 4818+ struct tdesc_feature *feature;
4804+ 4819+
4805+ feature = tdesc_create_feature (result, "org.gnu.gdb.microblaze64.core"); 4820+ feature = tdesc_create_feature (result.get(), "org.gnu.gdb.microblaze64.core");
4806+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64"); 4821+ tdesc_create_reg (feature, "r0", 0, 1, NULL, 64, "uint64");
4807+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64"); 4822+ tdesc_create_reg (feature, "r1", 1, 1, NULL, 64, "uint64");
4808+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64"); 4823+ tdesc_create_reg (feature, "r2", 2, 1, NULL, 64, "uint64");
@@ -4863,7 +4878,7 @@ index 00000000000..1aa37c45129
4863+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64"); 4878+ tdesc_create_reg (feature, "slr", 57, 1, NULL, 64, "uint64");
4864+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64"); 4879+ tdesc_create_reg (feature, "shr", 58, 1, NULL, 64, "uint64");
4865+ 4880+
4866+ tdesc_microblaze64 = result; 4881+ tdesc_microblaze64 = result.release();
4867+} 4882+}
4868diff --git a/gdb/features/microblaze64.xml b/gdb/features/microblaze64.xml 4883diff --git a/gdb/features/microblaze64.xml b/gdb/features/microblaze64.xml
4869new file mode 100644 4884new file mode 100644
@@ -4883,7 +4898,7 @@ index 00000000000..515d18e65cf
4883+ <xi:include href="microblaze64-core.xml"/> 4898+ <xi:include href="microblaze64-core.xml"/>
4884+</target> 4899+</target>
4885diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c 4900diff --git a/gdb/microblaze-linux-tdep.c b/gdb/microblaze-linux-tdep.c
4886index b77acc9dc61..ba87d0bbd63 100644 4901index fc52adffb72..f2db32f0087 100644
4887--- a/gdb/microblaze-linux-tdep.c 4902--- a/gdb/microblaze-linux-tdep.c
4888+++ b/gdb/microblaze-linux-tdep.c 4903+++ b/gdb/microblaze-linux-tdep.c
4889@@ -40,6 +40,7 @@ 4904@@ -40,6 +40,7 @@
@@ -4913,7 +4928,7 @@ index b77acc9dc61..ba87d0bbd63 100644
4913 struct trad_frame_cache *this_cache, 4928 struct trad_frame_cache *this_cache,
4914@@ -147,8 +151,8 @@ microblaze_linux_init_abi (struct gdbarch_info info, 4929@@ -147,8 +151,8 @@ microblaze_linux_init_abi (struct gdbarch_info info,
4915 4930
4916 linux_init_abi (info, gdbarch); 4931 linux_init_abi (info, gdbarch, 0);
4917 4932
4918- set_gdbarch_memory_remove_breakpoint (gdbarch, 4933- set_gdbarch_memory_remove_breakpoint (gdbarch,
4919- microblaze_linux_memory_remove_breakpoint); 4934- microblaze_linux_memory_remove_breakpoint);
@@ -4967,7 +4982,7 @@ index b77acc9dc61..ba87d0bbd63 100644
4967 initialize_tdesc_microblaze_linux (); 4982 initialize_tdesc_microblaze_linux ();
4968 } 4983 }
4969diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c 4984diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
4970index 0a5b5ab59cc..667d658adfd 100644 4985index ccb6b730d64..c347bb9516b 100644
4971--- a/gdb/microblaze-tdep.c 4986--- a/gdb/microblaze-tdep.c
4972+++ b/gdb/microblaze-tdep.c 4987+++ b/gdb/microblaze-tdep.c
4973@@ -40,7 +40,9 @@ 4988@@ -40,7 +40,9 @@
@@ -4980,7 +4995,7 @@ index 0a5b5ab59cc..667d658adfd 100644
4980 4995
4981 /* Instruction macros used for analyzing the prologue. */ 4996 /* Instruction macros used for analyzing the prologue. */
4982 /* This set of instruction macros need to be changed whenever the 4997 /* This set of instruction macros need to be changed whenever the
4983@@ -75,12 +77,13 @@ static const char *microblaze_register_names[] = 4998@@ -75,12 +77,13 @@ static const char * const microblaze_register_names[] =
4984 "rpvr0", "rpvr1", "rpvr2", "rpvr3", "rpvr4", "rpvr5", "rpvr6", 4999 "rpvr0", "rpvr1", "rpvr2", "rpvr3", "rpvr4", "rpvr5", "rpvr6",
4985 "rpvr7", "rpvr8", "rpvr9", "rpvr10", "rpvr11", 5000 "rpvr7", "rpvr8", "rpvr9", "rpvr10", "rpvr11",
4986 "redr", "rpid", "rzpr", "rtlbx", "rtlbsx", "rtlblo", "rtlbhi", 5001 "redr", "rpid", "rzpr", "rtlbx", "rtlbsx", "rtlblo", "rtlbhi",
@@ -4993,9 +5008,9 @@ index 0a5b5ab59cc..667d658adfd 100644
4993 static unsigned int microblaze_debug_flag = 0; 5008 static unsigned int microblaze_debug_flag = 0;
4994+int reg_size = 4; 5009+int reg_size = 4;
4995 5010
4996 static void ATTRIBUTE_PRINTF (1, 2) 5011 #define microblaze_debug(fmt, ...) \
4997 microblaze_debug (const char *fmt, ...) 5012 debug_prefixed_printf_cond_nofunc (microblaze_debug_flag, "MICROBLAZE", \
4998@@ -137,6 +140,15 @@ microblaze_fetch_instruction (CORE_ADDR pc) 5013@@ -128,6 +131,15 @@ microblaze_fetch_instruction (CORE_ADDR pc)
4999 constexpr gdb_byte microblaze_break_insn[] = MICROBLAZE_BREAKPOINT; 5014 constexpr gdb_byte microblaze_break_insn[] = MICROBLAZE_BREAKPOINT;
5000 5015
5001 typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint; 5016 typedef BP_MANIPULATION (microblaze_break_insn) microblaze_breakpoint;
@@ -5011,7 +5026,7 @@ index 0a5b5ab59cc..667d658adfd 100644
5011 static int 5026 static int
5012 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, 5027 microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
5013 struct bp_target_info *bp_tgt) 5028 struct bp_target_info *bp_tgt)
5014@@ -155,7 +167,6 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, 5029@@ -146,7 +158,6 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
5015 /* Make sure we see the memory breakpoints. */ 5030 /* Make sure we see the memory breakpoints. */
5016 scoped_restore restore_memory 5031 scoped_restore restore_memory
5017 = make_scoped_restore_show_memory_breakpoints (1); 5032 = make_scoped_restore_show_memory_breakpoints (1);
@@ -5019,7 +5034,7 @@ index 0a5b5ab59cc..667d658adfd 100644
5019 val = target_read_memory (addr, old_contents, bplen); 5034 val = target_read_memory (addr, old_contents, bplen);
5020 5035
5021 /* If our breakpoint is no longer at the address, this means that the 5036 /* If our breakpoint is no longer at the address, this means that the
5022@@ -170,6 +181,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, 5037@@ -161,6 +172,7 @@ microblaze_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
5023 return val; 5038 return val;
5024 } 5039 }
5025 5040
@@ -5027,7 +5042,7 @@ index 0a5b5ab59cc..667d658adfd 100644
5027 /* Allocate and initialize a frame cache. */ 5042 /* Allocate and initialize a frame cache. */
5028 5043
5029 static struct microblaze_frame_cache * 5044 static struct microblaze_frame_cache *
5030@@ -588,17 +600,16 @@ microblaze_extract_return_value (struct type *type, struct regcache *regcache, 5045@@ -577,17 +589,16 @@ microblaze_extract_return_value (struct type *type, struct regcache *regcache,
5031 gdb_byte *valbuf) 5046 gdb_byte *valbuf)
5032 { 5047 {
5033 gdb_byte buf[8]; 5048 gdb_byte buf[8];
@@ -5047,7 +5062,7 @@ index 0a5b5ab59cc..667d658adfd 100644
5047 return; 5062 return;
5048 case 4: /* for sizes 4 or 8, copy the required length. */ 5063 case 4: /* for sizes 4 or 8, copy the required length. */
5049 case 8: 5064 case 8:
5050@@ -765,6 +776,12 @@ microblaze_software_single_step (struct regcache *regcache) 5065@@ -754,6 +765,12 @@ microblaze_software_single_step (struct regcache *regcache)
5051 } 5066 }
5052 #endif 5067 #endif
5053 5068
@@ -5060,25 +5075,24 @@ index 0a5b5ab59cc..667d658adfd 100644
5060 static int dwarf2_to_reg_map[78] = 5075 static int dwarf2_to_reg_map[78] =
5061 { 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */ 5076 { 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */
5062 4 /* r4 */, 5 /* r5 */, 6 /* r6 */, 7 /* r7 */, /* 4- 7 */ 5077 4 /* r4 */, 5 /* r5 */, 6 /* r6 */, 7 /* r7 */, /* 4- 7 */
5063@@ -799,13 +816,14 @@ microblaze_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int reg) 5078@@ -788,13 +805,14 @@ microblaze_dwarf2_reg_to_regnum (struct gdbarch *gdbarch, int reg)
5064 static void 5079 static void
5065 microblaze_register_g_packet_guesses (struct gdbarch *gdbarch) 5080 microblaze_register_g_packet_guesses (struct gdbarch *gdbarch)
5066 { 5081 {
5067+ 5082+
5068 register_remote_g_packet_guess (gdbarch, 5083 register_remote_g_packet_guess (gdbarch,
5069- 4 * MICROBLAZE_NUM_CORE_REGS, 5084 4 * MICROBLAZE_NUM_CORE_REGS,
5070- tdesc_microblaze); 5085- tdesc_microblaze);
5071+ 4 * MICROBLAZE_NUM_REGS, 5086+ tdesc_microblaze64);
5072+ tdesc_microblaze64);
5073 5087
5074 register_remote_g_packet_guess (gdbarch, 5088 register_remote_g_packet_guess (gdbarch,
5075 4 * MICROBLAZE_NUM_REGS, 5089 4 * MICROBLAZE_NUM_REGS,
5076- tdesc_microblaze_with_stack_protect); 5090- tdesc_microblaze_with_stack_protect);
5077+ tdesc_microblaze64_with_stack_protect); 5091+ tdesc_microblaze64_with_stack_protect);
5078 } 5092 }
5079 5093
5080 void 5094 void
5081@@ -813,7 +831,7 @@ microblaze_supply_gregset (const struct regset *regset, 5095@@ -802,7 +820,7 @@ microblaze_supply_gregset (const struct regset *regset,
5082 struct regcache *regcache, 5096 struct regcache *regcache,
5083 int regnum, const void *gregs) 5097 int regnum, const void *gregs)
5084 { 5098 {
@@ -5087,7 +5101,7 @@ index 0a5b5ab59cc..667d658adfd 100644
5087 if (regnum >= 0) 5101 if (regnum >= 0)
5088 regcache->raw_supply (regnum, regs + regnum); 5102 regcache->raw_supply (regnum, regs + regnum);
5089 5103
5090@@ -821,7 +839,7 @@ microblaze_supply_gregset (const struct regset *regset, 5104@@ -810,7 +828,7 @@ microblaze_supply_gregset (const struct regset *regset,
5091 int i; 5105 int i;
5092 5106
5093 for (i = 0; i < 50; i++) { 5107 for (i = 0; i < 50; i++) {
@@ -5096,7 +5110,7 @@ index 0a5b5ab59cc..667d658adfd 100644
5096 } 5110 }
5097 } 5111 }
5098 } 5112 }
5099@@ -844,6 +862,17 @@ microblaze_iterate_over_regset_sections (struct gdbarch *gdbarch, 5113@@ -833,6 +851,17 @@ microblaze_iterate_over_regset_sections (struct gdbarch *gdbarch,
5100 } 5114 }
5101 5115
5102 5116
@@ -5114,7 +5128,7 @@ index 0a5b5ab59cc..667d658adfd 100644
5114 5128
5115 static struct gdbarch * 5129 static struct gdbarch *
5116 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5130 microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5117@@ -858,8 +887,15 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5131@@ -846,8 +875,15 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5118 if (arches != NULL) 5132 if (arches != NULL)
5119 return arches->gdbarch; 5133 return arches->gdbarch;
5120 if (tdesc == NULL) 5134 if (tdesc == NULL)
@@ -5132,56 +5146,67 @@ index 0a5b5ab59cc..667d658adfd 100644
5132 /* Check any target description for validity. */ 5146 /* Check any target description for validity. */
5133 if (tdesc_has_registers (tdesc)) 5147 if (tdesc_has_registers (tdesc))
5134 { 5148 {
5135@@ -867,27 +903,35 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5149@@ -855,31 +891,42 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5136 int valid_p; 5150 int valid_p;
5137 int i; 5151 int i;
5138 5152
5139- feature = tdesc_find_feature (tdesc, 5153- feature = tdesc_find_feature (tdesc,
5154- "org.gnu.gdb.microblaze.core");
5140+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64) 5155+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64)
5141+ feature = tdesc_find_feature (tdesc, 5156+ feature = tdesc_find_feature (tdesc,
5142+ "org.gnu.gdb.microblaze64.core"); 5157+ "org.gnu.gdb.microblaze64.core");
5143+ else 5158+ else
5144+ feature = tdesc_find_feature (tdesc, 5159+ feature = tdesc_find_feature (tdesc,
5145 "org.gnu.gdb.microblaze.core"); 5160+ "org.gnu.gdb.microblaze.core");
5146 if (feature == NULL) 5161 if (feature == NULL)
5147 return NULL; 5162 return NULL;
5148 tdesc_data = tdesc_data_alloc (); 5163 tdesc_data = tdesc_data_alloc ();
5149 5164
5150 valid_p = 1; 5165 valid_p = 1;
5151- for (i = 0; i < MICROBLAZE_NUM_CORE_REGS; i++) 5166- for (i = 0; i < MICROBLAZE_NUM_CORE_REGS; i++)
5152+ for (i = 0; i < MICROBLAZE_NUM_REGS; i++) 5167- valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
5153 valid_p &= tdesc_numbered_register (feature, tdesc_data, i, 5168- microblaze_register_names[i]);
5154 microblaze_register_names[i]);
5155- feature = tdesc_find_feature (tdesc, 5169- feature = tdesc_find_feature (tdesc,
5170- "org.gnu.gdb.microblaze.stack-protect");
5171+ for (i = 0; i < MICROBLAZE_NUM_REGS; i++)
5172+ valid_p &= tdesc_numbered_register (feature, tdesc_data.get(), i,
5173+ microblaze_register_names[i]);
5156+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64) 5174+ if (info.bfd_arch_info->mach == bfd_mach_microblaze64)
5157+ feature = tdesc_find_feature (tdesc, 5175+ feature = tdesc_find_feature (tdesc,
5158+ "org.gnu.gdb.microblaze64.stack-protect"); 5176+ "org.gnu.gdb.microblaze64.stack-protect");
5159+ else 5177+ else
5160+ feature = tdesc_find_feature (tdesc, 5178+ feature = tdesc_find_feature (tdesc,
5161 "org.gnu.gdb.microblaze.stack-protect"); 5179+ "org.gnu.gdb.microblaze.stack-protect");
5162 if (feature != NULL) 5180 if (feature != NULL)
5163 { 5181- {
5164 valid_p = 1; 5182- valid_p = 1;
5165 valid_p &= tdesc_numbered_register (feature, tdesc_data, 5183- valid_p &= tdesc_numbered_register (feature, tdesc_data.get (),
5166 MICROBLAZE_SLR_REGNUM, 5184- MICROBLAZE_SLR_REGNUM,
5167- "rslr"); 5185- "rslr");
5186- valid_p &= tdesc_numbered_register (feature, tdesc_data.get (),
5187- MICROBLAZE_SHR_REGNUM,
5188- "rshr");
5189- }
5190+ {
5191+ valid_p = 1;
5192+ valid_p &= tdesc_numbered_register (feature, tdesc_data.get(),
5193+ MICROBLAZE_SLR_REGNUM,
5168+ "slr"); 5194+ "slr");
5169 valid_p &= tdesc_numbered_register (feature, tdesc_data, 5195+ valid_p &= tdesc_numbered_register (feature, tdesc_data.get(),
5170 MICROBLAZE_SHR_REGNUM, 5196+ MICROBLAZE_SHR_REGNUM,
5171- "rshr");
5172+ "shr"); 5197+ "shr");
5173 } 5198+ }
5174 5199
5175 if (!valid_p) 5200 if (!valid_p)
5176@@ -895,6 +939,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5201- return NULL;
5177 tdesc_data_cleanup (tdesc_data); 5202+ {
5178 return NULL; 5203+ // tdesc_data_cleanup (tdesc_data.get ());
5179 } 5204+ return NULL;
5180+ 5205+ }
5181 } 5206 }
5182 5207
5183 /* Allocate space for the new architecture. */ 5208 /* Allocate space for the new architecture. */
5184@@ -914,7 +959,17 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5209@@ -899,7 +946,17 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5185 /* Register numbers of various important registers. */ 5210 /* Register numbers of various important registers. */
5186 set_gdbarch_sp_regnum (gdbarch, MICROBLAZE_SP_REGNUM); 5211 set_gdbarch_sp_regnum (gdbarch, MICROBLAZE_SP_REGNUM);
5187 set_gdbarch_pc_regnum (gdbarch, MICROBLAZE_PC_REGNUM); 5212 set_gdbarch_pc_regnum (gdbarch, MICROBLAZE_PC_REGNUM);
@@ -5199,7 +5224,7 @@ index 0a5b5ab59cc..667d658adfd 100644
5199 /* Map Dwarf2 registers to GDB registers. */ 5224 /* Map Dwarf2 registers to GDB registers. */
5200 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum); 5225 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum);
5201 5226
5202@@ -934,7 +989,9 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5227@@ -919,7 +976,9 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5203 microblaze_breakpoint::kind_from_pc); 5228 microblaze_breakpoint::kind_from_pc);
5204 set_gdbarch_sw_breakpoint_from_kind (gdbarch, 5229 set_gdbarch_sw_breakpoint_from_kind (gdbarch,
5205 microblaze_breakpoint::bp_from_kind); 5230 microblaze_breakpoint::bp_from_kind);
@@ -5210,7 +5235,7 @@ index 0a5b5ab59cc..667d658adfd 100644
5210 5235
5211 set_gdbarch_software_single_step (gdbarch, microblaze_software_single_step); 5236 set_gdbarch_software_single_step (gdbarch, microblaze_software_single_step);
5212 5237
5213@@ -942,7 +999,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5238@@ -927,7 +986,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5214 5239
5215 set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc); 5240 set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc);
5216 5241
@@ -5219,8 +5244,8 @@ index 0a5b5ab59cc..667d658adfd 100644
5219 5244
5220 frame_base_set_default (gdbarch, &microblaze_frame_base); 5245 frame_base_set_default (gdbarch, &microblaze_frame_base);
5221 5246
5222@@ -957,12 +1014,11 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 5247@@ -942,12 +1001,11 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
5223 tdesc_use_registers (gdbarch, tdesc, tdesc_data); 5248 tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));
5224 //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer); 5249 //frame_base_append_sniffer (gdbarch, microblaze_frame_sniffer);
5225 5250
5226- /* If we have register sets, enable the generic core file support. */ 5251- /* If we have register sets, enable the generic core file support. */
@@ -5234,7 +5259,7 @@ index 0a5b5ab59cc..667d658adfd 100644
5234 return gdbarch; 5259 return gdbarch;
5235 } 5260 }
5236 5261
5237@@ -974,6 +1030,8 @@ _initialize_microblaze_tdep () 5262@@ -959,6 +1017,8 @@ _initialize_microblaze_tdep ()
5238 5263
5239 initialize_tdesc_microblaze_with_stack_protect (); 5264 initialize_tdesc_microblaze_with_stack_protect ();
5240 initialize_tdesc_microblaze (); 5265 initialize_tdesc_microblaze ();
@@ -5244,10 +5269,10 @@ index 0a5b5ab59cc..667d658adfd 100644
5244 add_setshow_zuinteger_cmd ("microblaze", class_maintenance, 5269 add_setshow_zuinteger_cmd ("microblaze", class_maintenance,
5245 &microblaze_debug_flag, _("\ 5270 &microblaze_debug_flag, _("\
5246diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h 5271diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
5247index 7f75c693b74..e0fa7ef9b12 100644 5272index 2415acfe7b6..f4d810303ca 100644
5248--- a/gdb/microblaze-tdep.h 5273--- a/gdb/microblaze-tdep.h
5249+++ b/gdb/microblaze-tdep.h 5274+++ b/gdb/microblaze-tdep.h
5250@@ -27,7 +27,7 @@ struct microblaze_gregset 5275@@ -28,7 +28,7 @@ struct microblaze_gregset
5251 microblaze_gregset() {} 5276 microblaze_gregset() {}
5252 unsigned int gregs[32]; 5277 unsigned int gregs[32];
5253 unsigned int fpregs[32]; 5278 unsigned int fpregs[32];
@@ -5255,8 +5280,8 @@ index 7f75c693b74..e0fa7ef9b12 100644
5255+ unsigned int pregs[18]; 5280+ unsigned int pregs[18];
5256 }; 5281 };
5257 5282
5258 struct gdbarch_tdep 5283 struct microblaze_gdbarch_tdep : gdbarch_tdep
5259@@ -133,7 +133,7 @@ struct microblaze_frame_cache 5284@@ -134,7 +134,7 @@ struct microblaze_frame_cache
5260 struct trad_frame_saved_reg *saved_regs; 5285 struct trad_frame_saved_reg *saved_regs;
5261 }; 5286 };
5262 /* All registers are 32 bits. */ 5287 /* All registers are 32 bits. */
@@ -5265,36 +5290,20 @@ index 7f75c693b74..e0fa7ef9b12 100644
5265 5290
5266 /* MICROBLAZE_BREAKPOINT defines the breakpoint that should be used. 5291 /* MICROBLAZE_BREAKPOINT defines the breakpoint that should be used.
5267 Only used for native debugging. */ 5292 Only used for native debugging. */
5268diff --git a/gdb/regformats/microblaze-with-stack-protect.dat b/gdb/regformats/microblaze-with-stack-protect.dat
5269index 8040a7b3fd0..450e321d49e 100644
5270--- a/gdb/regformats/microblaze-with-stack-protect.dat
5271+++ b/gdb/regformats/microblaze-with-stack-protect.dat
5272@@ -60,5 +60,5 @@ expedite:r1,rpc
5273 32:rtlbsx
5274 32:rtlblo
5275 32:rtlbhi
5276-32:rslr
5277-32:rshr
5278+32:slr
5279+32:shr
5280diff --git a/gdb/gdbserver/linux-microblaze-low.c b/gdbserver/linux-microblaze-low.c
5281similarity index 100%
5282rename from gdb/gdbserver/linux-microblaze-low.c
5283rename to gdbserver/linux-microblaze-low.c
5284diff --git a/include/elf/common.h b/include/elf/common.h 5293diff --git a/include/elf/common.h b/include/elf/common.h
5285index 571e21af29a..fa10064712a 100644 5294index 70d63e3299c..8aa330d6631 100644
5286--- a/include/elf/common.h 5295--- a/include/elf/common.h
5287+++ b/include/elf/common.h 5296+++ b/include/elf/common.h
5288@@ -340,6 +340,7 @@ 5297@@ -360,6 +360,7 @@
5289 #define EM_RISCV 243 /* RISC-V */ 5298 #define EM_U16_U8CORE 260 /* LAPIS nX-U16/U8 */
5290 #define EM_LANAI 244 /* Lanai 32-bit processor. */ 5299 #define EM_TACHYUM 261 /* Tachyum */
5291 #define EM_BPF 247 /* Linux BPF – in-kernel virtual machine. */ 5300 #define EM_56800EF 262 /* NXP 56800EF Digital Signal Controller (DSC) */
5292+#define EM_MB_64 248 /* Xilinx MicroBlaze 32-bit RISC soft processor core */ 5301+#define EM_MB_64 263 /* Xilinx MicroBlaze 32-bit RISC soft processor core */
5293 #define EM_NFP 250 /* Netronome Flow Processor. */
5294 #define EM_CSKY 252 /* C-SKY processor family. */
5295 5302
5303 /* If it is necessary to assign new unofficial EM_* values, please pick large
5304 random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
5296diff --git a/include/elf/microblaze.h b/include/elf/microblaze.h 5305diff --git a/include/elf/microblaze.h b/include/elf/microblaze.h
5297index 2fec296967b..938841b2408 100644 5306index 43ad3ad3904..79799b86a49 100644
5298--- a/include/elf/microblaze.h 5307--- a/include/elf/microblaze.h
5299+++ b/include/elf/microblaze.h 5308+++ b/include/elf/microblaze.h
5300@@ -61,6 +61,10 @@ START_RELOC_NUMBERS (elf_microblaze_reloc_type) 5309@@ -61,6 +61,10 @@ START_RELOC_NUMBERS (elf_microblaze_reloc_type)
@@ -5309,7 +5318,7 @@ index 2fec296967b..938841b2408 100644
5309 5318
5310 /* Global base address names. */ 5319 /* Global base address names. */
5311diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c 5320diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
5312index be1534c257c..564c810a6c7 100644 5321index b057492ba93..283d87c04a2 100644
5313--- a/opcodes/microblaze-dis.c 5322--- a/opcodes/microblaze-dis.c
5314+++ b/opcodes/microblaze-dis.c 5323+++ b/opcodes/microblaze-dis.c
5315@@ -33,6 +33,7 @@ 5324@@ -33,6 +33,7 @@
@@ -5410,7 +5419,7 @@ index be1534c257c..564c810a6c7 100644
5410 print_func (stream, "\t%s", get_field_rd (&buf, inst)); 5419 print_func (stream, "\t%s", get_field_rd (&buf, inst));
5411 break; 5420 break;
5412diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h 5421diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
5413index 27d8684df04..f9709412097 100644 5422index ffb0f08c692..5e45df995de 100644
5414--- a/opcodes/microblaze-opc.h 5423--- a/opcodes/microblaze-opc.h
5415+++ b/opcodes/microblaze-opc.h 5424+++ b/opcodes/microblaze-opc.h
5416@@ -40,7 +40,7 @@ 5425@@ -40,7 +40,7 @@
@@ -5461,17 +5470,17 @@ index 27d8684df04..f9709412097 100644
5461-#define MAX_OPCODES 289 5470-#define MAX_OPCODES 289
5462+#define MAX_OPCODES 412 5471+#define MAX_OPCODES 412
5463 5472
5464 struct op_code_struct 5473 const struct op_code_struct
5465 { 5474 {
5466@@ -119,6 +132,7 @@ struct op_code_struct 5475@@ -119,6 +132,7 @@ const struct op_code_struct
5467 /* More info about output format here. */ 5476 /* More info about output format here. */
5468 } opcodes[MAX_OPCODES] = 5477 } microblaze_opcodes[MAX_OPCODES] =
5469 { 5478 {
5470+ /* 32-bit instructions */ 5479+ /* 32-bit instructions */
5471 {"add", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x00000000, OPCODE_MASK_H4, add, arithmetic_inst }, 5480 {"add", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x00000000, OPCODE_MASK_H4, add, arithmetic_inst },
5472 {"rsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H4, rsub, arithmetic_inst }, 5481 {"rsub", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x04000000, OPCODE_MASK_H4, rsub, arithmetic_inst },
5473 {"addc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x08000000, OPCODE_MASK_H4, addc, arithmetic_inst }, 5482 {"addc", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x08000000, OPCODE_MASK_H4, addc, arithmetic_inst },
5474@@ -155,9 +169,11 @@ struct op_code_struct 5483@@ -155,9 +169,11 @@ const struct op_code_struct
5475 {"ncget", INST_TYPE_RD_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C006000, OPCODE_MASK_H32, ncget, anyware_inst }, 5484 {"ncget", INST_TYPE_RD_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C006000, OPCODE_MASK_H32, ncget, anyware_inst },
5476 {"ncput", INST_TYPE_R1_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C00E000, OPCODE_MASK_H32, ncput, anyware_inst }, 5485 {"ncput", INST_TYPE_R1_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C00E000, OPCODE_MASK_H32, ncput, anyware_inst },
5477 {"muli", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x60000000, OPCODE_MASK_H, muli, mult_inst }, 5486 {"muli", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x60000000, OPCODE_MASK_H, muli, mult_inst },
@@ -5486,7 +5495,7 @@ index 27d8684df04..f9709412097 100644
5486 {"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, microblaze_or, logical_inst }, 5495 {"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, microblaze_or, logical_inst },
5487 {"and", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000000, OPCODE_MASK_H4, microblaze_and, logical_inst }, 5496 {"and", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000000, OPCODE_MASK_H4, microblaze_and, logical_inst },
5488 {"xor", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000000, OPCODE_MASK_H4, microblaze_xor, logical_inst }, 5497 {"xor", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000000, OPCODE_MASK_H4, microblaze_xor, logical_inst },
5489@@ -174,9 +190,14 @@ struct op_code_struct 5498@@ -174,9 +190,14 @@ const struct op_code_struct
5490 {"wic", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000068, OPCODE_MASK_H34B, wic, special_inst }, 5499 {"wic", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000068, OPCODE_MASK_H34B, wic, special_inst },
5491 {"wdc", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000064, OPCODE_MASK_H34B, wdc, special_inst }, 5500 {"wdc", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000064, OPCODE_MASK_H34B, wdc, special_inst },
5492 {"wdc.clear", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000066, OPCODE_MASK_H34B, wdcclear, special_inst }, 5501 {"wdc.clear", INST_TYPE_R1_R2_SPECIAL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x90000066, OPCODE_MASK_H34B, wdcclear, special_inst },
@@ -5501,7 +5510,7 @@ index 27d8684df04..f9709412097 100644
5501 {"br", INST_TYPE_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98000000, OPCODE_MASK_H124, br, branch_inst }, 5510 {"br", INST_TYPE_R2, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98000000, OPCODE_MASK_H124, br, branch_inst },
5502 {"brd", INST_TYPE_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98100000, OPCODE_MASK_H124, brd, branch_inst }, 5511 {"brd", INST_TYPE_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98100000, OPCODE_MASK_H124, brd, branch_inst },
5503 {"brld", INST_TYPE_RD_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98140000, OPCODE_MASK_H24, brld, branch_inst }, 5512 {"brld", INST_TYPE_RD_R2, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x98140000, OPCODE_MASK_H24, brld, branch_inst },
5504@@ -226,18 +247,24 @@ struct op_code_struct 5513@@ -226,18 +247,24 @@ const struct op_code_struct
5505 {"bgeid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBEA00000, OPCODE_MASK_H1, bgeid, branch_inst }, 5514 {"bgeid", INST_TYPE_R1_IMM, INST_PC_OFFSET, DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBEA00000, OPCODE_MASK_H1, bgeid, branch_inst },
5506 {"lbu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000000, OPCODE_MASK_H4, lbu, memory_load_inst }, 5515 {"lbu", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000000, OPCODE_MASK_H4, lbu, memory_load_inst },
5507 {"lbur", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000200, OPCODE_MASK_H4, lbur, memory_load_inst }, 5516 {"lbur", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xC0000200, OPCODE_MASK_H4, lbur, memory_load_inst },
@@ -5526,7 +5535,7 @@ index 27d8684df04..f9709412097 100644
5526 {"lbui", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE0000000, OPCODE_MASK_H, lbui, memory_load_inst }, 5535 {"lbui", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE0000000, OPCODE_MASK_H, lbui, memory_load_inst },
5527 {"lhui", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE4000000, OPCODE_MASK_H, lhui, memory_load_inst }, 5536 {"lhui", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE4000000, OPCODE_MASK_H, lhui, memory_load_inst },
5528 {"lwi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, lwi, memory_load_inst }, 5537 {"lwi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, lwi, memory_load_inst },
5529@@ -248,9 +275,7 @@ struct op_code_struct 5538@@ -248,9 +275,7 @@ const struct op_code_struct
5530 {"la", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x30000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* la translates to addik. */ 5539 {"la", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x30000000, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* la translates to addik. */
5531 {"tuqula",INST_TYPE_RD, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x3000002A, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* tuqula rd translates to addik rd, r0, 42. */ 5540 {"tuqula",INST_TYPE_RD, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x3000002A, OPCODE_MASK_H, invalid_inst, arithmetic_inst }, /* tuqula rd translates to addik rd, r0, 42. */
5532 {"not", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xA800FFFF, OPCODE_MASK_H34, invalid_inst, logical_inst }, /* not translates to xori rd,ra,-1. */ 5541 {"not", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xA800FFFF, OPCODE_MASK_H34, invalid_inst, logical_inst }, /* not translates to xori rd,ra,-1. */
@@ -5536,7 +5545,7 @@ index 27d8684df04..f9709412097 100644
5536 {"lmi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, invalid_inst, memory_load_inst }, 5545 {"lmi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xE8000000, OPCODE_MASK_H, invalid_inst, memory_load_inst },
5537 {"smi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xF8000000, OPCODE_MASK_H, invalid_inst, memory_store_inst }, 5546 {"smi", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xF8000000, OPCODE_MASK_H, invalid_inst, memory_store_inst },
5538 {"msrset",INST_TYPE_RD_IMM15, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x94100000, OPCODE_MASK_H23N, msrset, special_inst }, 5547 {"msrset",INST_TYPE_RD_IMM15, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x94100000, OPCODE_MASK_H23N, msrset, special_inst },
5539@@ -402,8 +427,135 @@ struct op_code_struct 5548@@ -402,8 +427,135 @@ const struct op_code_struct
5540 {"clz", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900000E0, OPCODE_MASK_H34, clz, special_inst }, 5549 {"clz", INST_TYPE_RD_R1, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x900000E0, OPCODE_MASK_H34, clz, special_inst },
5541 {"mbar", INST_TYPE_IMM5, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8020004, OPCODE_MASK_HN, mbar, special_inst }, 5550 {"mbar", INST_TYPE_IMM5, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xB8020004, OPCODE_MASK_HN, mbar, special_inst },
5542 {"sleep", INST_TYPE_NONE, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBA020004, OPCODE_MASK_HN, invalid_inst, special_inst }, /* translates to mbar 16. */ 5551 {"sleep", INST_TYPE_NONE, INST_PC_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0xBA020004, OPCODE_MASK_HN, invalid_inst, special_inst }, /* translates to mbar 16. */
@@ -5691,7 +5700,7 @@ index 27d8684df04..f9709412097 100644
5691 #endif /* MICROBLAZE_OPC */ 5700 #endif /* MICROBLAZE_OPC */
5692 5701
5693diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h 5702diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
5694index aa53dfe6bb5..ad8b8ce345b 100644 5703index 8e293465fec..254d9fe911e 100644
5695--- a/opcodes/microblaze-opcm.h 5704--- a/opcodes/microblaze-opcm.h
5696+++ b/opcodes/microblaze-opcm.h 5705+++ b/opcodes/microblaze-opcm.h
5697@@ -25,22 +25,23 @@ 5706@@ -25,22 +25,23 @@
@@ -5723,9 +5732,9 @@ index aa53dfe6bb5..ad8b8ce345b 100644
5723+ sb, sbea, sbr, sh, shea, shr, sw, swea, swr, swx, lbui, lhui, lwi, lli, 5732+ sb, sbea, sbr, sh, shea, shr, sw, swea, swr, swx, lbui, lhui, lwi, lli,
5724+ sbi, shi, sli, swi, msrset, msrclr, tuqula, mbi_fadd, frsub, mbi_fmul, mbi_fdiv, 5733+ sbi, shi, sli, swi, msrset, msrclr, tuqula, mbi_fadd, frsub, mbi_fmul, mbi_fdiv,
5725 fcmp_lt, fcmp_eq, fcmp_le, fcmp_gt, fcmp_ne, fcmp_ge, fcmp_un, flt, 5734 fcmp_lt, fcmp_eq, fcmp_le, fcmp_gt, fcmp_ne, fcmp_ge, fcmp_un, flt,
5726 fint, fsqrt, 5735 /* 'fsqrt' is a glibc:math.h symbol. */
5727 tget, tcget, tnget, tncget, tput, tcput, tnput, tncput, 5736 fint, microblaze_fsqrt,
5728@@ -58,6 +59,18 @@ enum microblaze_instr 5737@@ -59,6 +60,18 @@ enum microblaze_instr
5729 aputd, taputd, caputd, tcaputd, naputd, tnaputd, ncaputd, tncaputd, 5738 aputd, taputd, caputd, tcaputd, naputd, tnaputd, ncaputd, tncaputd,
5730 eagetd, teagetd, ecagetd, tecagetd, neagetd, tneagetd, necagetd, tnecagetd, 5739 eagetd, teagetd, ecagetd, tecagetd, neagetd, tneagetd, necagetd, tnecagetd,
5731 eaputd, teaputd, ecaputd, tecaputd, neaputd, tneaputd, necaputd, tnecaputd, 5740 eaputd, teaputd, ecaputd, tecaputd, neaputd, tneaputd, necaputd, tnecaputd,
@@ -5744,7 +5753,7 @@ index aa53dfe6bb5..ad8b8ce345b 100644
5744 invalid_inst 5753 invalid_inst
5745 }; 5754 };
5746 5755
5747@@ -129,18 +142,25 @@ enum microblaze_instr_type 5756@@ -130,18 +143,25 @@ enum microblaze_instr_type
5748 #define RB_LOW 11 /* Low bit for RB. */ 5757 #define RB_LOW 11 /* Low bit for RB. */
5749 #define IMM_LOW 0 /* Low bit for immediate. */ 5758 #define IMM_LOW 0 /* Low bit for immediate. */
5750 #define IMM_MBAR 21 /* low bit for mbar instruction. */ 5759 #define IMM_MBAR 21 /* low bit for mbar instruction. */
@@ -5772,5 +5781,5 @@ index aa53dfe6bb5..ad8b8ce345b 100644
5772 #define RFSL_MASK 0x000000F 5781 #define RFSL_MASK 0x000000F
5773 5782
5774-- 5783--
57752.17.1 57842.37.1 (Apple Git-137.1)
5776 5785
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0008-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0006-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch
index abbea266..402d7fe1 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0008-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0006-Patch-MicroBlaze-these-changes-will-make-64-bit-vect.patch
@@ -1,7 +1,7 @@
1From cc8ee172b9145ce488c556a2eb50f931f0676eea Mon Sep 17 00:00:00 2001 1From ef411b49f3b2c9e4048eb273f43ab4ee96f96b7e Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Mon, 19 Apr 2021 14:33:27 +0530 3Date: Mon, 19 Apr 2021 14:33:27 +0530
4Subject: [PATCH 08/10] [Patch,MicroBlaze] : these changes will make 64 bit 4Subject: [PATCH 6/8] [Patch,MicroBlaze] : these changes will make 64 bit
5 vectors as default target types when we built gdb with microblaze 64 bit type 5 vectors as default target types when we built gdb with microblaze 64 bit type
6 targets,for instance microblaze-xilinx-elf64/microblazeel-xilinx-elf64 6 targets,for instance microblaze-xilinx-elf64/microblazeel-xilinx-elf64
7 7
@@ -10,10 +10,10 @@ Subject: [PATCH 08/10] [Patch,MicroBlaze] : these changes will make 64 bit
10 1 file changed, 8 insertions(+) 10 1 file changed, 8 insertions(+)
11 11
12diff --git a/bfd/config.bfd b/bfd/config.bfd 12diff --git a/bfd/config.bfd b/bfd/config.bfd
13index 0f752de267b..4945e7fa3b5 100644 13index 5e9ba3d9805..deb3d078439 100644
14--- a/bfd/config.bfd 14--- a/bfd/config.bfd
15+++ b/bfd/config.bfd 15+++ b/bfd/config.bfd
16@@ -823,7 +823,15 @@ case "${targ}" in 16@@ -856,7 +856,15 @@ case "${targ}" in
17 targ_defvec=metag_elf32_vec 17 targ_defvec=metag_elf32_vec
18 targ_underscore=yes 18 targ_underscore=yes
19 ;; 19 ;;
@@ -30,5 +30,5 @@ index 0f752de267b..4945e7fa3b5 100644
30 targ_defvec=microblaze_elf32_le_vec 30 targ_defvec=microblaze_elf32_le_vec
31 targ_selvecs=microblaze_elf32_vec 31 targ_selvecs=microblaze_elf32_vec
32-- 32--
332.17.1 332.37.1 (Apple Git-137.1)
34 34
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0009-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch
index 35466e8f..59449bfa 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0009-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0007-Patch-MicroBlaze-Added-m64-abi-for-64-bit-target-des.patch
@@ -1,14 +1,17 @@
1From a721a7063f829ccaf6cf8273be04b763b53a735d Mon Sep 17 00:00:00 2001 1From d2f145ec8e4e149e055adc74e92016447af91806 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 9 Nov 2021 16:19:17 +0530 3Date: Tue, 9 Nov 2021 16:19:17 +0530
4Subject: [PATCH 09/10] [Patch,MicroBlaze] : Added m64 abi for 64 bit target 4Subject: [PATCH 7/8] [Patch,MicroBlaze] : Added m64 abi for 64 bit target
5 descriptions. set m64 abi for 64 bit elf. 5 descriptions. set m64 abi for 64 bit elf.
6 6
7Conflicts:
8 gdb/microblaze-tdep.c
9 gdb/microblaze-tdep.h
7--- 10---
8 gdb/features/microblaze64.xml | 1 + 11 gdb/features/microblaze64.xml | 1 +
9 gdb/microblaze-tdep.c | 150 ++++++++++++++++++++++++++++++++-- 12 gdb/microblaze-tdep.c | 159 ++++++++++++++++++++++++++++++++--
10 gdb/microblaze-tdep.h | 11 +++ 13 gdb/microblaze-tdep.h | 13 ++-
11 3 files changed, 155 insertions(+), 7 deletions(-) 14 3 files changed, 165 insertions(+), 8 deletions(-)
12 15
13diff --git a/gdb/features/microblaze64.xml b/gdb/features/microblaze64.xml 16diff --git a/gdb/features/microblaze64.xml b/gdb/features/microblaze64.xml
14index 515d18e65cf..9c1b7d22003 100644 17index 515d18e65cf..9c1b7d22003 100644
@@ -22,10 +25,10 @@ index 515d18e65cf..9c1b7d22003 100644
22 <xi:include href="microblaze64-core.xml"/> 25 <xi:include href="microblaze64-core.xml"/>
23 </target> 26 </target>
24diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c 27diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
25index 667d658adfd..aad6a9cae6e 100644 28index c347bb9516b..d83072cdaef 100644
26--- a/gdb/microblaze-tdep.c 29--- a/gdb/microblaze-tdep.c
27+++ b/gdb/microblaze-tdep.c 30+++ b/gdb/microblaze-tdep.c
28@@ -65,8 +65,94 @@ 31@@ -65,8 +65,95 @@
29 #define IS_SAVE_HIDDEN_PTR(op, rd, ra, rb) \ 32 #define IS_SAVE_HIDDEN_PTR(op, rd, ra, rb) \
30 ((op == add || op == addik) && ra == MICROBLAZE_FIRST_ARGREG && rb == 0) 33 ((op == add || op == addik) && ra == MICROBLAZE_FIRST_ARGREG && rb == 0)
31 34
@@ -39,7 +42,8 @@ index 667d658adfd..aad6a9cae6e 100644
39+enum microblaze_abi 42+enum microblaze_abi
40+microblaze_abi (struct gdbarch *gdbarch) 43+microblaze_abi (struct gdbarch *gdbarch)
41+{ 44+{
42+ return gdbarch_tdep (gdbarch)->microblaze_abi; 45+ microblaze_gdbarch_tdep *tdep = (microblaze_gdbarch_tdep *) gdbarch_tdep (gdbarch);
46+ return tdep->microblaze_abi;
43+} 47+}
44 /* The registers of the Xilinx microblaze processor. */ 48 /* The registers of the Xilinx microblaze processor. */
45 49
@@ -54,7 +58,7 @@ index 667d658adfd..aad6a9cae6e 100644
54+ 58+
55+ /* Force the architecture to update, and (if it's a microblaze architecture) 59+ /* Force the architecture to update, and (if it's a microblaze architecture)
56+ * microblaze_gdbarch_init will take care of the rest. */ 60+ * microblaze_gdbarch_init will take care of the rest. */
57+ gdbarch_info_init (&info); 61+// gdbarch_info_init (&info);
58+ gdbarch_update_p (info); 62+ gdbarch_update_p (info);
59+} 63+}
60+ 64+
@@ -117,10 +121,10 @@ index 667d658adfd..aad6a9cae6e 100644
117+ help_list (setmicroblazecmdlist, "set microblaze ", all_commands, gdb_stdout); 121+ help_list (setmicroblazecmdlist, "set microblaze ", all_commands, gdb_stdout);
118+} 122+}
119+ 123+
120 static const char *microblaze_register_names[] = 124 static const char * const microblaze_register_names[] =
121 { 125 {
122 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", 126 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
123@@ -85,6 +171,18 @@ static const char *microblaze_register_names[] = 127@@ -85,9 +172,21 @@ static const char * const microblaze_register_names[] =
124 static unsigned int microblaze_debug_flag = 0; 128 static unsigned int microblaze_debug_flag = 0;
125 int reg_size = 4; 129 int reg_size = 4;
126 130
@@ -136,13 +140,17 @@ index 667d658adfd..aad6a9cae6e 100644
136+ } 140+ }
137+} 141+}
138+ 142+
139 static void ATTRIBUTE_PRINTF (1, 2) 143 #define microblaze_debug(fmt, ...) \
140 microblaze_debug (const char *fmt, ...) 144 debug_prefixed_printf_cond_nofunc (microblaze_debug_flag, "MICROBLAZE", \
141 { 145- fmt, ## __VA_ARGS__)
142@@ -880,15 +978,30 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 146+ fmt, ## __VA_ARGS__)
143 struct gdbarch_tdep *tdep; 147
148
149 /* Return the name of register REGNUM. */
150@@ -868,15 +967,30 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
151 {
144 struct gdbarch *gdbarch; 152 struct gdbarch *gdbarch;
145 struct tdesc_arch_data *tdesc_data = NULL; 153 tdesc_arch_data_up tdesc_data;
146+ enum microblaze_abi microblaze_abi, found_abi, wanted_abi; 154+ enum microblaze_abi microblaze_abi, found_abi, wanted_abi;
147 const struct target_desc *tdesc = info.target_desc; 155 const struct target_desc *tdesc = info.target_desc;
148 156
@@ -172,7 +180,7 @@ index 667d658adfd..aad6a9cae6e 100644
172 { 180 {
173 tdesc = tdesc_microblaze64; 181 tdesc = tdesc_microblaze64;
174 reg_size = 8; 182 reg_size = 8;
175@@ -903,7 +1016,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 183@@ -891,7 +1005,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
176 int valid_p; 184 int valid_p;
177 int i; 185 int i;
178 186
@@ -181,16 +189,16 @@ index 667d658adfd..aad6a9cae6e 100644
181 feature = tdesc_find_feature (tdesc, 189 feature = tdesc_find_feature (tdesc,
182 "org.gnu.gdb.microblaze64.core"); 190 "org.gnu.gdb.microblaze64.core");
183 else 191 else
184@@ -917,7 +1030,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 192@@ -905,7 +1019,7 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
185 for (i = 0; i < MICROBLAZE_NUM_REGS; i++) 193 for (i = 0; i < MICROBLAZE_NUM_REGS; i++)
186 valid_p &= tdesc_numbered_register (feature, tdesc_data, i, 194 valid_p &= tdesc_numbered_register (feature, tdesc_data.get(), i,
187 microblaze_register_names[i]); 195 microblaze_register_names[i]);
188- if (info.bfd_arch_info->mach == bfd_mach_microblaze64) 196- if (info.bfd_arch_info->mach == bfd_mach_microblaze64)
189+ if ((info.bfd_arch_info->mach == bfd_mach_microblaze64) || (microblaze_abi == MICROBLAZE_ABI_M64)) 197+ if ((info.bfd_arch_info->mach == bfd_mach_microblaze64) || (microblaze_abi == MICROBLAZE_ABI_M64))
190 feature = tdesc_find_feature (tdesc, 198 feature = tdesc_find_feature (tdesc,
191 "org.gnu.gdb.microblaze64.stack-protect"); 199 "org.gnu.gdb.microblaze64.stack-protect");
192 else 200 else
193@@ -968,7 +1081,8 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) 201@@ -955,7 +1069,8 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
194 set_gdbarch_ptr_bit (gdbarch, 64); 202 set_gdbarch_ptr_bit (gdbarch, 64);
195 break; 203 break;
196 } 204 }
@@ -200,15 +208,21 @@ index 667d658adfd..aad6a9cae6e 100644
200 208
201 /* Map Dwarf2 registers to GDB registers. */ 209 /* Map Dwarf2 registers to GDB registers. */
202 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum); 210 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, microblaze_dwarf2_reg_to_regnum);
203@@ -1027,7 +1141,30 @@ void 211@@ -1014,7 +1129,38 @@ void
204 _initialize_microblaze_tdep () 212 _initialize_microblaze_tdep ()
205 { 213 {
206 register_gdbarch_init (bfd_arch_microblaze, microblaze_gdbarch_init); 214 register_gdbarch_init (bfd_arch_microblaze, microblaze_gdbarch_init);
207-
208+// static struct cmd_list_element *setmicroblazecmdlist = NULL; 215+// static struct cmd_list_element *setmicroblazecmdlist = NULL;
209+// static struct cmd_list_element *showmicroblazecmdlist = NULL; 216+// static struct cmd_list_element *showmicroblazecmdlist = NULL;
210+ 217+
211+ /* Add root prefix command for all "set microblaze"/"show microblaze" commands. */ 218+ /* Add root prefix command for all "set microblaze"/"show microblaze" commands. */
219
220+ add_setshow_prefix_cmd ("microblaze", no_class,
221+ _("Various microblaze specific commands."),
222+ _("Various microblaze specific commands."),
223+ &setmicroblazecmdlist,&showmicroblazecmdlist,
224+ &setlist,&showlist);
225+#if 0
212+ add_prefix_cmd ("microblaze", no_class, set_microblaze_command, 226+ add_prefix_cmd ("microblaze", no_class, set_microblaze_command,
213+ _("Various microblaze specific commands."), 227+ _("Various microblaze specific commands."),
214+ &setmicroblazecmdlist, "set microblaze ", 0, &setlist); 228+ &setmicroblazecmdlist, "set microblaze ", 0, &setlist);
@@ -216,6 +230,7 @@ index 667d658adfd..aad6a9cae6e 100644
216+ add_prefix_cmd ("microblaze", no_class, show_microblaze_command, 230+ add_prefix_cmd ("microblaze", no_class, show_microblaze_command,
217+ _("Various microblaze specific commands."), 231+ _("Various microblaze specific commands."),
218+ &showmicroblazecmdlist, "show microblaze ", 0, &showlist); 232+ &showmicroblazecmdlist, "show microblaze ", 0, &showlist);
233+#endif
219+ 234+
220+ /* Allow the user to override the ABI. */ 235+ /* Allow the user to override the ABI. */
221+ add_setshow_enum_cmd ("abi", class_obscure, microblaze_abi_strings, 236+ add_setshow_enum_cmd ("abi", class_obscure, microblaze_abi_strings,
@@ -232,21 +247,23 @@ index 667d658adfd..aad6a9cae6e 100644
232 initialize_tdesc_microblaze_with_stack_protect (); 247 initialize_tdesc_microblaze_with_stack_protect ();
233 initialize_tdesc_microblaze (); 248 initialize_tdesc_microblaze ();
234 initialize_tdesc_microblaze64_with_stack_protect (); 249 initialize_tdesc_microblaze64_with_stack_protect ();
235@@ -1042,5 +1179,4 @@ When non-zero, microblaze specific debugging is enabled."), 250@@ -1029,5 +1175,4 @@ When non-zero, microblaze specific debugging is enabled."),
236 NULL, 251 NULL,
237 &setdebuglist, &showdebuglist); 252 &setdebuglist, &showdebuglist);
238 253
239- 254-
240 } 255 }
241diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h 256diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
242index e0fa7ef9b12..9cb9628295f 100644 257index f4d810303ca..babd6c36926 100644
243--- a/gdb/microblaze-tdep.h 258--- a/gdb/microblaze-tdep.h
244+++ b/gdb/microblaze-tdep.h 259+++ b/gdb/microblaze-tdep.h
245@@ -19,8 +19,16 @@ 260@@ -19,9 +19,17 @@
246 261
247 #ifndef MICROBLAZE_TDEP_H 262 #ifndef MICROBLAZE_TDEP_H
248 #define MICROBLAZE_TDEP_H 1 263 #define MICROBLAZE_TDEP_H 1
264-
249+#include "objfiles.h" 265+#include "objfiles.h"
266 #include "gdbarch.h"
250 267
251+struct gdbarch; 268+struct gdbarch;
252+enum microblaze_abi 269+enum microblaze_abi
@@ -254,17 +271,17 @@ index e0fa7ef9b12..9cb9628295f 100644
254+ MICROBLAZE_ABI_AUTO = 0, 271+ MICROBLAZE_ABI_AUTO = 0,
255+ MICROBLAZE_ABI_M64, 272+ MICROBLAZE_ABI_M64,
256+ }; 273+ };
257 274+
258+enum microblaze_abi microblaze_abi (struct gdbarch *gdbarch); 275+enum microblaze_abi microblaze_abi (struct gdbarch *gdbarch);
259 /* Microblaze architecture-specific information. */ 276 /* Microblaze architecture-specific information. */
260 struct microblaze_gregset 277 struct microblaze_gregset
261 { 278 {
262@@ -34,11 +42,14 @@ struct gdbarch_tdep 279@@ -35,11 +43,14 @@ struct microblaze_gdbarch_tdep : gdbarch_tdep
263 { 280 {
264 int dummy; // declare something. 281 int dummy; // declare something.
265 282
266+ enum microblaze_abi microblaze_abi; 283+ enum microblaze_abi microblaze_abi {};
267+ enum microblaze_abi found_abi; 284+ enum microblaze_abi found_abi {};
268 /* Register sets. */ 285 /* Register sets. */
269 struct regset *gregset; 286 struct regset *gregset;
270 size_t sizeof_gregset; 287 size_t sizeof_gregset;
@@ -275,5 +292,5 @@ index e0fa7ef9b12..9cb9628295f 100644
275 292
276 /* Register numbers. */ 293 /* Register numbers. */
277-- 294--
2782.17.1 2952.37.1 (Apple Git-137.1)
279 296
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0011-Patch-Microblaze-Depth-Total-number.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0008-Patch-MicroBlaze.patch
index 0e9c1a74..4c96fb49 100644
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0011-Patch-Microblaze-Depth-Total-number.patch
+++ b/meta-microblaze/recipes-devtools/gdb/gdb/0008-Patch-MicroBlaze.patch
@@ -1,13 +1,13 @@
1From 1f6eef2eb2e6974ba9989977d1b1c8dfdeca94f4 Mon Sep 17 00:00:00 2001 1From 0532b1db08b9d8efc670f7288fe2d8168b8ed0d1 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com> 2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Thu, 21 Jul 2022 11:45:01 +0530 3Date: Thu, 21 Jul 2022 11:45:01 +0530
4Subject: [PATCH] =?UTF-8?q?[Patch,MicroBlaze]:=20Depth:=20=20Total=20numbe?= 4Subject: [PATCH 8/8] =?UTF-8?q?[Patch,MicroBlaze]:=20Depth:=20=20Total=20n?=
5 =?UTF-8?q?r=20of=20inline=20functions=20[refer=20inline-frame.c]=20state-?= 5 =?UTF-8?q?umber=20of=20inline=20functions=20[refer=20inline-frame.c]=20st?=
6 =?UTF-8?q?>skipped=5Fframes=20:=20Number=20of=20inline=20functions=20skip?= 6 =?UTF-8?q?ate->skipped=5Fframes=20:=20Number=20of=20inline=20functions=20?=
7 =?UTF-8?q?ped.=20the=20current=20unwind=5Fpc=20is=20causing=20an=20issue?= 7 =?UTF-8?q?skipped.=20the=20current=20unwind=5Fpc=20is=20causing=20an=20is?=
8 =?UTF-8?q?=20when=20we=20try=20to=20step=20into=20inline=20functions[Dept?= 8 =?UTF-8?q?sue=20when=20we=20try=20to=20step=20into=20inline=20functions[D?=
9 =?UTF-8?q?h=20is=20becoming=200].=20It=E2=80=99s=20incrementing=20pc=20by?= 9 =?UTF-8?q?epth=20is=20becoming=200].=20It=E2=80=99s=20incrementing=20pc?=
10 =?UTF-8?q?=208=20even=20with=20si=20instruction.?= 10 =?UTF-8?q?=20by=208=20even=20with=20si=20instruction.?=
11MIME-Version: 1.0 11MIME-Version: 1.0
12Content-Type: text/plain; charset=UTF-8 12Content-Type: text/plain; charset=UTF-8
13Content-Transfer-Encoding: 8bit 13Content-Transfer-Encoding: 8bit
@@ -17,10 +17,10 @@ Content-Transfer-Encoding: 8bit
17 1 file changed, 3 insertions(+), 11 deletions(-) 17 1 file changed, 3 insertions(+), 11 deletions(-)
18 18
19diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c 19diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
20index aad6a9cae6e..41a2eb511d6 100644 20index d83072cdaef..38ba38e8c7d 100644
21--- a/gdb/microblaze-tdep.c 21--- a/gdb/microblaze-tdep.c
22+++ b/gdb/microblaze-tdep.c 22+++ b/gdb/microblaze-tdep.c
23@@ -524,16 +524,8 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, 23@@ -513,16 +513,8 @@ microblaze_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
24 static CORE_ADDR 24 static CORE_ADDR
25 microblaze_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) 25 microblaze_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
26 { 26 {
@@ -38,7 +38,7 @@ index aad6a9cae6e..41a2eb511d6 100644
38 return pc; 38 return pc;
39 } 39 }
40 40
41@@ -564,7 +556,6 @@ microblaze_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc) 41@@ -553,7 +545,6 @@ microblaze_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
42 ostart_pc = microblaze_analyze_prologue (gdbarch, func_start, 0xffffffffUL, 42 ostart_pc = microblaze_analyze_prologue (gdbarch, func_start, 0xffffffffUL,
43 &cache); 43 &cache);
44 44
@@ -46,7 +46,7 @@ index aad6a9cae6e..41a2eb511d6 100644
46 if (ostart_pc > start_pc) 46 if (ostart_pc > start_pc)
47 return ostart_pc; 47 return ostart_pc;
48 return start_pc; 48 return start_pc;
49@@ -670,7 +661,8 @@ static const struct frame_unwind microblaze_frame_unwind = 49@@ -660,7 +651,8 @@ static const struct frame_unwind microblaze_frame_unwind =
50 microblaze_frame_this_id, 50 microblaze_frame_this_id,
51 microblaze_frame_prev_register, 51 microblaze_frame_prev_register,
52 NULL, 52 NULL,
@@ -57,5 +57,5 @@ index aad6a9cae6e..41a2eb511d6 100644
57 57
58 static CORE_ADDR 58 static CORE_ADDR
59-- 59--
602.17.1 602.37.1 (Apple Git-137.1)
61 61
diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Code-changes-for-gdbserver.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Code-changes-for-gdbserver.patch
deleted file mode 100644
index dc38b480..00000000
--- a/meta-microblaze/recipes-devtools/gdb/gdb/0010-Patch-MicroBlaze-Code-changes-for-gdbserver.patch
+++ /dev/null
@@ -1,401 +0,0 @@
1From 01e16382c8fce4448c911a4c5780259e181e83dd Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Fri, 8 Jul 2022 12:53:51 +0530
4Subject: [PATCH 10/10] [Patch,MicroBlaze]: Code changes for gdbserver.
5
6---
7 gdb/features/Makefile | 1 +
8 gdb/features/microblaze-linux.xml | 1 +
9 gdb/regformats/microblaze-linux.dat | 64 +++++++++
10 gdbserver/Makefile.in | 5 +-
11 gdbserver/configure.srv | 1 +
12 ...croblaze-low.c => linux-microblaze-low.cc} | 132 ++++++++++--------
13 6 files changed, 138 insertions(+), 66 deletions(-)
14 create mode 100644 gdb/regformats/microblaze-linux.dat
15 rename gdbserver/{linux-microblaze-low.c => linux-microblaze-low.cc} (72%)
16
17diff --git a/gdb/features/Makefile b/gdb/features/Makefile
18index 131fc14adbf..1b15305862e 100644
19--- a/gdb/features/Makefile
20+++ b/gdb/features/Makefile
21@@ -47,6 +47,7 @@
22 WHICH = mips-linux mips-dsp-linux \
23 microblaze-with-stack-protect \
24 microblaze64-with-stack-protect \
25+ microblaze-linux \
26 mips64-linux mips64-dsp-linux \
27 nios2-linux \
28 rs6000/powerpc-32 \
29diff --git a/gdb/features/microblaze-linux.xml b/gdb/features/microblaze-linux.xml
30index 8983e66eb3d..688a3f83d1e 100644
31--- a/gdb/features/microblaze-linux.xml
32+++ b/gdb/features/microblaze-linux.xml
33@@ -7,6 +7,7 @@
34
35 <!DOCTYPE target SYSTEM "gdb-target.dtd">
36 <target>
37+ <architecture>microblaze</architecture>
38 <osabi>GNU/Linux</osabi>
39 <xi:include href="microblaze-core.xml"/>
40 </target>
41diff --git a/gdb/regformats/microblaze-linux.dat b/gdb/regformats/microblaze-linux.dat
42new file mode 100644
43index 00000000000..b5b49f485cd
44--- /dev/null
45+++ b/gdb/regformats/microblaze-linux.dat
46@@ -0,0 +1,64 @@
47+# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro:
48+# Generated from: microblaze-linux.xml
49+name:microblaze_linux
50+xmltarget:microblaze-linux.xml
51+expedite:r1,rpc
52+32:r0
53+32:r1
54+32:r2
55+32:r3
56+32:r4
57+32:r5
58+32:r6
59+32:r7
60+32:r8
61+32:r9
62+32:r10
63+32:r11
64+32:r12
65+32:r13
66+32:r14
67+32:r15
68+32:r16
69+32:r17
70+32:r18
71+32:r19
72+32:r20
73+32:r21
74+32:r22
75+32:r23
76+32:r24
77+32:r25
78+32:r26
79+32:r27
80+32:r28
81+32:r29
82+32:r30
83+32:r31
84+32:rpc
85+32:rmsr
86+32:rear
87+32:resr
88+32:rfsr
89+32:rbtr
90+32:rpvr0
91+32:rpvr1
92+32:rpvr2
93+32:rpvr3
94+32:rpvr4
95+32:rpvr5
96+32:rpvr6
97+32:rpvr7
98+32:rpvr8
99+32:rpvr9
100+32:rpvr10
101+32:rpvr11
102+32:redr
103+32:rpid
104+32:rzpr
105+32:rtlbx
106+32:rtlbsx
107+32:rtlblo
108+32:rtlbhi
109+32:slr
110+32:shr
111diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
112index 46b5a0c7c60..eaaf6820fe0 100644
113--- a/gdbserver/Makefile.in
114+++ b/gdbserver/Makefile.in
115@@ -184,7 +184,7 @@ SFILES = \
116 $(srcdir)/linux-ia64-low.cc \
117 $(srcdir)/linux-low.cc \
118 $(srcdir)/linux-m68k-low.cc \
119- $(srcdir)/linux-microblaze-low.c \
120+ $(srcdir)/linux-microblaze-low.cc \
121 $(srcdir)/linux-mips-low.cc \
122 $(srcdir)/linux-nios2-low.cc \
123 $(srcdir)/linux-ppc-low.cc \
124@@ -222,7 +222,6 @@ SFILES = \
125 $(srcdir)/../gdb/nat/linux-namespaces.c \
126 $(srcdir)/../gdb/nat/linux-osdata.c \
127 $(srcdir)/../gdb/nat/linux-personality.c \
128- $(srcdir)/../gdb/nat/microblaze-linux.c \
129 $(srcdir)/../gdb/nat/mips-linux-watch.c \
130 $(srcdir)/../gdb/nat/ppc-linux.c \
131 $(srcdir)/../gdb/nat/riscv-linux-tdesc.c \
132@@ -564,8 +563,6 @@ target/%.o: ../gdb/target/%.c
133
134 %-generated.cc: ../gdb/regformats/rs6000/%.dat $(regdat_sh)
135 $(ECHO_REGDAT) $(SHELL) $(regdat_sh) $< $@
136-microblaze-linux.c : $(srcdir)/../regformats/reg-microblaze.dat $(regdat_sh)
137- $(ECHO_REGDAT) $(SHELL) $(regdat_sh) $(srcdir)/../regformats/reg-microblaze.dat microblaze-linux.c
138
139 #
140 # Dependency tracking.
141diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
142index af10cb05683..026b156bd60 100644
143--- a/gdbserver/configure.srv
144+++ b/gdbserver/configure.srv
145@@ -169,6 +169,7 @@ case "${gdbserver_host}" in
146 microblaze*-*-linux*) srv_regobj="microblaze-linux.o"
147 srv_tgtobj="$srv_linux_obj linux-microblaze-low.o "
148 srv_xmlfiles="microblaze-linux.xml"
149+ srv_xmlfiles="${srv_xmlfiles} microblaze-core.xml"
150 srv_linux_regsets=yes
151 srv_linux_usrregs=yes
152 srv_linux_thread_db=yes
153diff --git a/gdbserver/linux-microblaze-low.c b/gdbserver/linux-microblaze-low.cc
154similarity index 72%
155rename from gdbserver/linux-microblaze-low.c
156rename to gdbserver/linux-microblaze-low.cc
157index a2733f3c21c..d30fa102b5e 100644
158--- a/gdbserver/linux-microblaze-low.c
159+++ b/gdbserver/linux-microblaze-low.cc
160@@ -20,12 +20,17 @@
161 #include "server.h"
162 #include "linux-low.h"
163
164+#include "elf/common.h"
165+#include "nat/gdb_ptrace.h"
166+#include <endian.h>
167+
168 #include <asm/ptrace.h>
169 #include <sys/procfs.h>
170 #include <sys/ptrace.h>
171
172 #include "gdb_proc_service.h"
173
174+
175 static int microblaze_regmap[] =
176 {PT_GPR(0), PT_GPR(1), PT_GPR(2), PT_GPR(3),
177 PT_GPR(4), PT_GPR(5), PT_GPR(6), PT_GPR(7),
178@@ -39,14 +44,46 @@ static int microblaze_regmap[] =
179 PT_FSR
180 };
181
182+
183+
184+class microblaze_target : public linux_process_target
185+{
186+public:
187+
188+ const regs_info *get_regs_info () override;
189+
190+ const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
191+ // CORE_ADDR microblaze_reinsert_addr (regcache *regcache);
192+
193+protected:
194+
195+ void low_arch_setup () override;
196+
197+ bool low_cannot_fetch_register (int regno) override;
198+
199+ bool low_cannot_store_register (int regno) override;
200+
201+ // bool low_supports_breakpoints () override;
202+
203+ CORE_ADDR low_get_pc (regcache *regcache) override;
204+
205+ void low_set_pc (regcache *regcache, CORE_ADDR newpc) override;
206+
207+ bool low_breakpoint_at (CORE_ADDR pc) override;
208+};
209+
210+/* The singleton target ops object. */
211+
212+static microblaze_target the_microblaze_target;
213+
214 #define microblaze_num_regs (sizeof (microblaze_regmap) / sizeof (microblaze_regmap[0]))
215
216 /* Defined in auto-generated file microblaze-linux.c. */
217-void init_registers_microblaze (void);
218-extern const struct target_desc *tdesc_microblaze;
219+void init_registers_microblaze_linux (void);
220+extern const struct target_desc *tdesc_microblaze_linux;
221
222-static int
223-microblaze_cannot_store_register (int regno)
224+bool
225+microblaze_target::low_cannot_store_register (int regno)
226 {
227 if (microblaze_regmap[regno] == -1 || regno == 0)
228 return 1;
229@@ -54,14 +91,14 @@ microblaze_cannot_store_register (int regno)
230 return 0;
231 }
232
233-static int
234-microblaze_cannot_fetch_register (int regno)
235+bool
236+microblaze_target::low_cannot_fetch_register (int regno)
237 {
238 return 0;
239 }
240
241-static CORE_ADDR
242-microblaze_get_pc (struct regcache *regcache)
243+CORE_ADDR
244+microblaze_target::low_get_pc (struct regcache *regcache)
245 {
246 unsigned long pc;
247
248@@ -69,8 +106,8 @@ microblaze_get_pc (struct regcache *regcache)
249 return (CORE_ADDR) pc;
250 }
251
252-static void
253-microblaze_set_pc (struct regcache *regcache, CORE_ADDR pc)
254+void
255+microblaze_target::low_set_pc (struct regcache *regcache, CORE_ADDR pc)
256 {
257 unsigned long newpc = pc;
258
259@@ -84,34 +121,35 @@ static const unsigned long microblaze_breakpoint = 0xba0c0018;
260
261 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
262
263-static const gdb_byte *
264-microblaze_sw_breakpoint_from_kind (int kind, int *size)
265+const gdb_byte *
266+microblaze_target::sw_breakpoint_from_kind (int kind, int *size)
267 {
268 *size = microblaze_breakpoint_len;
269 return (const gdb_byte *) &microblaze_breakpoint;
270 }
271
272-static int
273-microblaze_breakpoint_at (CORE_ADDR where)
274+bool
275+microblaze_target::low_breakpoint_at (CORE_ADDR where)
276 {
277 unsigned long insn;
278
279- (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
280+ read_memory (where, (unsigned char *) &insn, 4);
281 if (insn == microblaze_breakpoint)
282 return 1;
283 /* If necessary, recognize more trap instructions here. GDB only uses the
284 one. */
285 return 0;
286 }
287-
288-static CORE_ADDR
289-microblaze_reinsert_addr (struct regcache *regcache)
290+#if 0
291+CORE_ADDR
292+microblaze_target::microblaze_reinsert_addr (struct regcache *regcache)
293 {
294 unsigned long pc;
295 collect_register_by_name (regcache, "r15", &pc);
296 return pc;
297 }
298-
299+#endif
300+#if 0
301 #ifdef HAVE_PTRACE_GETREGS
302
303 static void
304@@ -166,12 +204,15 @@ microblaze_store_gregset (struct regcache *regcache, const void *buf)
305 }
306
307 #endif /* HAVE_PTRACE_GETREGS */
308+#endif
309
310 static struct regset_info microblaze_regsets[] = {
311+#if 0
312 #ifdef HAVE_PTRACE_GETREGS
313 { PTRACE_GETREGS, PTRACE_SETREGS, 0, sizeof (elf_gregset_t), GENERAL_REGS, microblaze_fill_gregset, microblaze_store_gregset },
314 { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
315 #endif /* HAVE_PTRACE_GETREGS */
316+#endif
317 { 0, 0, 0, -1, GENERAL_REGS, NULL, NULL },
318 NULL_REGSET
319 };
320@@ -189,17 +230,17 @@ static struct regsets_info microblaze_regsets_info =
321 NULL, /* disabled_regsets */
322 };
323
324-static struct regs_info regs_info =
325+static struct regs_info microblaze_regs_info =
326 {
327 NULL, /* regset_bitmap */
328 &microblaze_usrregs_info,
329 &microblaze_regsets_info
330 };
331
332-static const struct regs_info *
333-microblaze_regs_info (void)
334+const regs_info *
335+microblaze_target::get_regs_info (void)
336 {
337- return &regs_info;
338+ return &microblaze_regs_info;
339 }
340
341 /* Support for hardware single step. */
342@@ -211,50 +252,17 @@ microblaze_supports_hardware_single_step (void)
343 }
344
345
346-static void
347-microblaze_arch_setup (void)
348+void
349+microblaze_target::low_arch_setup (void)
350 {
351- current_process ()->tdesc = tdesc_microblaze;
352+ current_process ()->tdesc = tdesc_microblaze_linux;
353 }
354
355-struct linux_target_ops the_low_target = {
356- microblaze_arch_setup,
357- microblaze_regs_info,
358- microblaze_cannot_fetch_register,
359- microblaze_cannot_store_register,
360- NULL, /* fetch_register */
361- microblaze_get_pc,
362- microblaze_set_pc,
363- NULL,
364- microblaze_sw_breakpoint_from_kind,
365- NULL,
366- 0,
367- microblaze_breakpoint_at,
368- NULL,
369- NULL,
370- NULL,
371- NULL,
372- NULL,
373- microblaze_collect_ptrace_register,
374- microblaze_supply_ptrace_register,
375- NULL, /* siginfo_fixup */
376- NULL, /* new_process */
377- NULL, /* new_thread */
378- NULL, /* new_fork */
379- NULL, /* prepare_to_resume */
380- NULL, /* process_qsupported */
381- NULL, /* supports_tracepoints */
382- NULL, /* get_thread_area */
383- NULL, /* install_fast_tracepoint_jump_pad */
384- NULL, /* emit_ops */
385- NULL, /* get_min_fast_tracepoint_insn_len */
386- NULL, /* supports_range_stepping */
387- NULL, /* breakpoint_kind_from_current_state */
388- microblaze_supports_hardware_single_step,
389-};
390+linux_process_target *the_linux_target = &the_microblaze_target;
391
392 void
393 initialize_low_arch (void)
394 {
395- init_registers_microblaze ();
396+ init_registers_microblaze_linux ();
397+ initialize_regsets_info (&microblaze_regsets_info);
398 }
399--
4002.17.1
401