[meta-xilinx] [PATCH 27/29] gcc-source: Add patch to fix MicroBlaze ABI bug

Nathan Rossi nathan at nathanrossi.com
Wed Sep 28 08:15:54 PDT 2016


Add a patch which fixes a bug in GCC regarding the usage of the r20 and
r21 registers specifically for the use in Linux.

Signed-off-by: Nathan Rossi <nathan at nathanrossi.com>
---
 ...microblaze-Make-r21-fixed-due-to-Linux-AB.patch | 48 ++++++++++++++++++++++
 recipes-microblaze/gcc/gcc-source_6.%.bbappend     |  1 +
 2 files changed, 49 insertions(+)
 create mode 100644 recipes-microblaze/gcc/files/gcc-config-microblaze-Make-r21-fixed-due-to-Linux-AB.patch

diff --git a/recipes-microblaze/gcc/files/gcc-config-microblaze-Make-r21-fixed-due-to-Linux-AB.patch b/recipes-microblaze/gcc/files/gcc-config-microblaze-Make-r21-fixed-due-to-Linux-AB.patch
new file mode 100644
index 0000000000..373b158ad3
--- /dev/null
+++ b/recipes-microblaze/gcc/files/gcc-config-microblaze-Make-r21-fixed-due-to-Linux-AB.patch
@@ -0,0 +1,48 @@
+From 3a73b9abccefa81cdee4cdf28f8b3b8fb0ed6c6e Mon Sep 17 00:00:00 2001
+From: Nathan Rossi <nathan at nathanrossi.com>
+Date: Tue, 27 Sep 2016 04:14:50 +1000
+Subject: [PATCH] gcc/config/microblaze: Make r21 fixed due to Linux ABI
+
+Commit 6dcad60c0ef48af584395a40feeb256fb82986a8 introduced a change to
+how the r20 and r21 registers are handled for MicroBlaze. Specifically
+removing the fixed nature of the r21 register.
+
+In the Linux ABI the r21 register is reserved as a fixed register for
+the purposes of storing a pointer to the thread related object. This is
+of particular importance for libc (glibc and musl) which use this
+register and expect it to be fixed for this purpose.
+
+GCC uses the r20 register for GOT pointing. This commit mentioned above
+confusingly states it preserved the fixed nature but in fact changes r20
+to be non-fixed. This patch fixes that up.
+
+Signed-off-by: Nathan Rossi <nathan at nathanrossi.com>
+Upstream-Status: Pending
+---
+ gcc/config/microblaze/microblaze.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
+index dbfb6522c7..e115c42839 100644
+--- a/gcc/config/microblaze/microblaze.h
++++ b/gcc/config/microblaze/microblaze.h
+@@ -253,14 +253,14 @@ extern enum pipeline_type microblaze_pipe;
+ #define FIXED_REGISTERS							\
+ {									\
+   1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,			\
+-  1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			\
++  1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			\
+   1, 1, 1, 1 								\
+ }
+ 
+ #define CALL_USED_REGISTERS						\
+ {									\
+   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,			\
+-  1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			\
++  1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,			\
+   1, 1, 1, 1								\
+ }
+ #define GP_REG_FIRST    0
+-- 
+2.9.3
+
diff --git a/recipes-microblaze/gcc/gcc-source_6.%.bbappend b/recipes-microblaze/gcc/gcc-source_6.%.bbappend
index 50075f0d42..76b4f60cda 100644
--- a/recipes-microblaze/gcc/gcc-source_6.%.bbappend
+++ b/recipes-microblaze/gcc/gcc-source_6.%.bbappend
@@ -3,5 +3,6 @@
 FILESEXTRAPATHS_append := "${THISDIR}/files:"
 SRC_URI_append = " \
 		file://microblaze.md-Improve-adddi3-and-subdi3-insn-definit.patch \
+		file://gcc-config-microblaze-Make-r21-fixed-due-to-Linux-AB.patch \
 		"
 
-- 
2.9.3



More information about the meta-xilinx mailing list