nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0142-Files-reorganization-and-include-some-libgcc-fuction.patch

23d2ea
From 034afc94f6126bd352587265f03fa383f998f0fc Mon Sep 17 00:00:00 2001
39700a
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
39700a
Date: Wed, 13 Aug 2014 19:00:19 +0000
27a4da
Subject: [PATCH 142/260] Files reorganization and include some libgcc fuctions
39700a
39700a
As we avoid libgcc dependency for powerpc64el, we moved some functions
39700a
to other files and add the necessary ones.
39700a
39700a
* Makefile.core.def: Include compiler-rt.S.
39700a
* misc.c: Add the necessary libgcc functions.
39700a
* compiler-rt.S: New file.
39700a
* libgcc.h: Move some content from here ...
39700a
* compiler.h: ... to here.
39700a
39700a
Also-By: Brent Baude <bbaude@redhat.com>
39700a
Also-By: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
39700a
---
39700a
 grub-core/Makefile.core.def          |   1 +
39700a
 grub-core/kern/misc.c                | 107 ++++++++++++++++++++++++++++
39700a
 grub-core/kern/powerpc/compiler-rt.S | 130 +++++++++++++++++++++++++++++++++++
39700a
 include/grub/compiler.h              |  61 ++++++++++++++++
39700a
 include/grub/libgcc.h                |  67 ------------------
39700a
 5 files changed, 299 insertions(+), 67 deletions(-)
39700a
 create mode 100644 grub-core/kern/powerpc/compiler-rt.S
39700a
39700a
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
27a4da
index 7bf1c8a58..9ff9ae5a3 100644
39700a
--- a/grub-core/Makefile.core.def
39700a
+++ b/grub-core/Makefile.core.def
39700a
@@ -252,6 +252,7 @@ kernel = {
39700a
 
39700a
   powerpc_ieee1275 = kern/powerpc/cache.S;
39700a
   powerpc_ieee1275 = kern/powerpc/dl.c;
39700a
+  powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
39700a
 
39700a
   sparc64_ieee1275 = kern/sparc64/cache.S;
39700a
   sparc64_ieee1275 = kern/sparc64/dl.c;
39700a
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
27a4da
index a56cfe789..a3e5056db 100644
39700a
--- a/grub-core/kern/misc.c
39700a
+++ b/grub-core/kern/misc.c
39700a
@@ -1345,3 +1345,110 @@ grub_real_boot_time (const char *file,
39700a
   grub_error_pop ();
39700a
 }
39700a
 #endif
39700a
+
39700a
+#if defined (NO_LIBGCC)
39700a
+
39700a
+/* Based on libgcc2.c from gcc suite.  */
39700a
+int
39700a
+__ucmpdi2 (grub_uint64_t a, grub_uint64_t b)
39700a
+{
39700a
+  union component64 ac, bc;
39700a
+  ac.full = a;
39700a
+  bc.full = b;
39700a
+
39700a
+  if (ac.high < bc.high)
39700a
+    return 0;
39700a
+  else if (ac.high > bc.high)
39700a
+    return 2;
39700a
+
39700a
+  if (ac.low < bc.low)
39700a
+    return 0;
39700a
+  else if (ac.low > bc.low)
39700a
+    return 2;
39700a
+  return 1;
39700a
+}
39700a
+
39700a
+
39700a
+/* Based on libgcc2.c from gcc suite.  */
39700a
+grub_uint64_t
39700a
+__lshrdi3 (grub_uint64_t u, int b)
39700a
+{
39700a
+  if (b == 0)
39700a
+    return u;
39700a
+
39700a
+  const union component64 uu = {.full = u};
39700a
+  const int bm = 32 - b;
39700a
+  union component64 w;
39700a
+
39700a
+  if (bm <= 0)
39700a
+    {
39700a
+      w.high = 0;
39700a
+      w.low = (grub_uint32_t) uu.high >> -bm;
39700a
+    }
39700a
+  else
39700a
+    {
39700a
+      const grub_uint32_t carries = (grub_uint32_t) uu.high << bm;
39700a
+
39700a
+      w.high = (grub_uint32_t) uu.high >> b;
39700a
+      w.low = ((grub_uint32_t) uu.low >> b) | carries;
39700a
+    }
39700a
+
39700a
+  return w.full;
39700a
+}
39700a
+
39700a
+/* Based on libgcc2.c from gcc suite.  */
39700a
+grub_uint64_t
39700a
+__ashrdi3 (grub_uint64_t u, int b)
39700a
+{
39700a
+  if (b == 0)
39700a
+    return u;
39700a
+
39700a
+  const union component64 uu = {.full = u};
39700a
+  const int bm = 32 - b;
39700a
+  union component64 w;
39700a
+
39700a
+  if (bm <= 0)
39700a
+    {
39700a
+      /* w.high = 1..1 or 0..0 */
39700a
+      w.high = uu.high >> (32 - 1);
39700a
+      w.low = uu.high >> -bm;
39700a
+    }
39700a
+  else
39700a
+    {
39700a
+      const grub_uint32_t carries = (grub_uint32_t) uu.high << bm;
39700a
+
39700a
+      w.high = uu.high >> b;
39700a
+      w.low = ((grub_uint32_t) uu.low >> b) | carries;
39700a
+    }
39700a
+
39700a
+  return w.full;
39700a
+}
39700a
+
39700a
+/* Based on libgcc2.c from gcc suite.  */
39700a
+grub_uint64_t
39700a
+__ashldi3 (grub_uint64_t u, int b)
39700a
+{
39700a
+  if (b == 0)
39700a
+    return u;
39700a
+
39700a
+  const union component64 uu = {.full = u};
39700a
+  const int bm = 32 - b;
39700a
+  union component64 w;
39700a
+
39700a
+  if (bm <= 0)
39700a
+    {
39700a
+      w.low = 0;
39700a
+      w.high = (grub_uint32_t) uu.low << -bm;
39700a
+    }
39700a
+  else
39700a
+    {
39700a
+      const grub_uint32_t carries = (grub_uint32_t) uu.low >> bm;
39700a
+
39700a
+      w.low = (grub_uint32_t) uu.low << b;
39700a
+      w.high = ((grub_uint32_t) uu.high << b) | carries;
39700a
+    }
39700a
+
39700a
+  return w.full;
39700a
+}
39700a
+
39700a
+#endif
39700a
diff --git a/grub-core/kern/powerpc/compiler-rt.S b/grub-core/kern/powerpc/compiler-rt.S
39700a
new file mode 100644
27a4da
index 000000000..63e3a0d4e
39700a
--- /dev/null
39700a
+++ b/grub-core/kern/powerpc/compiler-rt.S
39700a
@@ -0,0 +1,130 @@
39700a
+/*
39700a
+ * Special support for eabi and SVR4
39700a
+ *
39700a
+ *   Copyright (C) 1995-2014 Free Software Foundation, Inc.
39700a
+ *   Written By Michael Meissner
39700a
+ *   64-bit support written by David Edelsohn
39700a
+ *
39700a
+ * This file is free software; you can redistribute it and/or modify it
39700a
+ * under the terms of the GNU General Public License as published by the
39700a
+ * Free Software Foundation; either version 3, or (at your option) any
39700a
+ * later version.
39700a
+ *
39700a
+ * This file is distributed in the hope that it will be useful, but
39700a
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
39700a
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
39700a
+ * General Public License for more details.
39700a
+ *
39700a
+ * Under Section 7 of GPL version 3, you are granted additional
39700a
+ * permissions described in the GCC Runtime Library Exception, version
39700a
+ * 3.1, as published by the Free Software Foundation.
39700a
+ *
39700a
+ * You should have received a copy of the GNU General Public License and
39700a
+ * a copy of the GCC Runtime Library Exception along with this program;
39700a
+ * see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
39700a
+ * <http://www.gnu.org/licenses/>.
39700a
+ */
39700a
+
39700a
+/* Do any initializations needed for the eabi environment */
39700a
+
39700a
+#include <grub/symbol.h>
39700a
+#include <grub/dl.h>
39700a
+
39700a
+	.section ".text"
39700a
+
39700a
+#define CFI_RESTORE(reg)		.cfi_restore reg
39700a
+#define CFI_OFFSET(reg, off)		.cfi_offset reg, off
39700a
+#define CFI_DEF_CFA_REGISTER(reg)	.cfi_def_cfa_register reg
39700a
+#define CFI_STARTPROC			.cfi_startproc
39700a
+#define CFI_ENDPROC			.cfi_endproc
39700a
+
39700a
+/* Routines for restoring integer registers, called by the compiler.  */
39700a
+/* Called with r11 pointing to the stack header word of the caller of the */
39700a
+/* function, just beyond the end of the integer restore area.  */
39700a
+
39700a
+CFI_STARTPROC
39700a
+CFI_DEF_CFA_REGISTER (11)
39700a
+CFI_OFFSET (65, 4)
39700a
+CFI_OFFSET (14, -72)
39700a
+CFI_OFFSET (15, -68)
39700a
+CFI_OFFSET (16, -64)
39700a
+CFI_OFFSET (17, -60)
39700a
+CFI_OFFSET (18, -56)
39700a
+CFI_OFFSET (19, -52)
39700a
+CFI_OFFSET (20, -48)
39700a
+CFI_OFFSET (21, -44)
39700a
+CFI_OFFSET (22, -40)
39700a
+CFI_OFFSET (23, -36)
39700a
+CFI_OFFSET (24, -32)
39700a
+CFI_OFFSET (25, -28)
39700a
+CFI_OFFSET (26, -24)
39700a
+CFI_OFFSET (27, -20)
39700a
+CFI_OFFSET (28, -16)
39700a
+CFI_OFFSET (29, -12)
39700a
+CFI_OFFSET (30, -8)
39700a
+CFI_OFFSET (31, -4)
39700a
+FUNCTION(_restgpr_14_x)	lwz	14,-72(11)	/* restore gp registers */
39700a
+CFI_RESTORE (14)
39700a
+FUNCTION(_restgpr_15_x)	lwz	15,-68(11)
39700a
+CFI_RESTORE (15)
39700a
+FUNCTION(_restgpr_16_x)	lwz	16,-64(11)
39700a
+CFI_RESTORE (16)
39700a
+FUNCTION(_restgpr_17_x)	lwz	17,-60(11)
39700a
+CFI_RESTORE (17)
39700a
+FUNCTION(_restgpr_18_x)	lwz	18,-56(11)
39700a
+CFI_RESTORE (18)
39700a
+FUNCTION(_restgpr_19_x)	lwz	19,-52(11)
39700a
+CFI_RESTORE (19)
39700a
+FUNCTION(_restgpr_20_x)	lwz	20,-48(11)
39700a
+CFI_RESTORE (20)
39700a
+FUNCTION(_restgpr_21_x)	lwz	21,-44(11)
39700a
+CFI_RESTORE (21)
39700a
+FUNCTION(_restgpr_22_x)	lwz	22,-40(11)
39700a
+CFI_RESTORE (22)
39700a
+FUNCTION(_restgpr_23_x)	lwz	23,-36(11)
39700a
+CFI_RESTORE (23)
39700a
+FUNCTION(_restgpr_24_x)	lwz	24,-32(11)
39700a
+CFI_RESTORE (24)
39700a
+FUNCTION(_restgpr_25_x)	lwz	25,-28(11)
39700a
+CFI_RESTORE (25)
39700a
+FUNCTION(_restgpr_26_x)	lwz	26,-24(11)
39700a
+CFI_RESTORE (26)
39700a
+FUNCTION(_restgpr_27_x)	lwz	27,-20(11)
39700a
+CFI_RESTORE (27)
39700a
+FUNCTION(_restgpr_28_x)	lwz	28,-16(11)
39700a
+CFI_RESTORE (28)
39700a
+FUNCTION(_restgpr_29_x)	lwz	29,-12(11)
39700a
+CFI_RESTORE (29)
39700a
+FUNCTION(_restgpr_30_x)	lwz	30,-8(11)
39700a
+CFI_RESTORE (30)
39700a
+FUNCTION(_restgpr_31_x)	lwz	0,4(11)
39700a
+				lwz	31,-4(11)
39700a
+CFI_RESTORE (31)
39700a
+				mtlr	0
39700a
+CFI_RESTORE (65)
39700a
+				mr	1,11
39700a
+CFI_DEF_CFA_REGISTER (1)
39700a
+				blr
39700a
+CFI_ENDPROC
39700a
+
39700a
+CFI_STARTPROC
39700a
+FUNCTION(_savegpr_14)	stw	14,-72(11)	/* save gp registers */
39700a
+FUNCTION(_savegpr_15)	stw	15,-68(11)
39700a
+FUNCTION(_savegpr_16)	stw	16,-64(11)
39700a
+FUNCTION(_savegpr_17)	stw	17,-60(11)
39700a
+FUNCTION(_savegpr_18)	stw	18,-56(11)
39700a
+FUNCTION(_savegpr_19)	stw	19,-52(11)
39700a
+FUNCTION(_savegpr_20)	stw	20,-48(11)
39700a
+FUNCTION(_savegpr_21)	stw	21,-44(11)
39700a
+FUNCTION(_savegpr_22)	stw	22,-40(11)
39700a
+FUNCTION(_savegpr_23)	stw	23,-36(11)
39700a
+FUNCTION(_savegpr_24)	stw	24,-32(11)
39700a
+FUNCTION(_savegpr_25)	stw	25,-28(11)
39700a
+FUNCTION(_savegpr_26)	stw	26,-24(11)
39700a
+FUNCTION(_savegpr_27)	stw	27,-20(11)
39700a
+FUNCTION(_savegpr_28)	stw	28,-16(11)
39700a
+FUNCTION(_savegpr_29)	stw	29,-12(11)
39700a
+FUNCTION(_savegpr_30)	stw	30,-8(11)
39700a
+FUNCTION(_savegpr_31)	stw	31,-4(11)
39700a
+			blr
39700a
+CFI_ENDPROC
39700a
diff --git a/include/grub/compiler.h b/include/grub/compiler.h
27a4da
index c9e1d7a73..a9a684ccb 100644
39700a
--- a/include/grub/compiler.h
39700a
+++ b/include/grub/compiler.h
39700a
@@ -48,4 +48,65 @@
39700a
 #  define WARN_UNUSED_RESULT
39700a
 #endif
39700a
 
39700a
+#include "types.h"
39700a
+
39700a
+union component64
39700a
+{
39700a
+  grub_uint64_t full;
39700a
+  struct
39700a
+  {
39700a
+#ifdef GRUB_CPU_WORDS_BIGENDIAN
39700a
+    grub_uint32_t high;
39700a
+    grub_uint32_t low;
39700a
+#else
39700a
+    grub_uint32_t low;
39700a
+    grub_uint32_t high;
39700a
+#endif
39700a
+  };
39700a
+};
39700a
+
39700a
+#if defined (__powerpc__)
39700a
+grub_uint64_t EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b);
39700a
+grub_uint64_t EXPORT_FUNC (__ashrdi3) (grub_uint64_t u, int b);
39700a
+grub_uint64_t EXPORT_FUNC (__ashldi3) (grub_uint64_t u, int b);
39700a
+int EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b);
39700a
+void EXPORT_FUNC (_restgpr_14_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_15_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_16_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_17_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_18_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_19_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_20_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_21_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_22_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_23_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_24_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_25_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_26_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_27_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_28_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_29_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_30_x) (void);
39700a
+void EXPORT_FUNC (_restgpr_31_x) (void);
39700a
+void EXPORT_FUNC (_savegpr_14) (void);
39700a
+void EXPORT_FUNC (_savegpr_15) (void);
39700a
+void EXPORT_FUNC (_savegpr_16) (void);
39700a
+void EXPORT_FUNC (_savegpr_17) (void);
39700a
+void EXPORT_FUNC (_savegpr_18) (void);
39700a
+void EXPORT_FUNC (_savegpr_19) (void);
39700a
+void EXPORT_FUNC (_savegpr_20) (void);
39700a
+void EXPORT_FUNC (_savegpr_21) (void);
39700a
+void EXPORT_FUNC (_savegpr_22) (void);
39700a
+void EXPORT_FUNC (_savegpr_23) (void);
39700a
+void EXPORT_FUNC (_savegpr_24) (void);
39700a
+void EXPORT_FUNC (_savegpr_25) (void);
39700a
+void EXPORT_FUNC (_savegpr_26) (void);
39700a
+void EXPORT_FUNC (_savegpr_27) (void);
39700a
+void EXPORT_FUNC (_savegpr_28) (void);
39700a
+void EXPORT_FUNC (_savegpr_29) (void);
39700a
+void EXPORT_FUNC (_savegpr_30) (void);
39700a
+void EXPORT_FUNC (_savegpr_31) (void);
39700a
+
39700a
+#endif
39700a
+
39700a
 #endif /* ! GRUB_COMPILER_HEADER */
39700a
diff --git a/include/grub/libgcc.h b/include/grub/libgcc.h
27a4da
index 8e93b6792..5bdb8fb5c 100644
39700a
--- a/include/grub/libgcc.h
39700a
+++ b/include/grub/libgcc.h
39700a
@@ -16,73 +16,6 @@
39700a
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
39700a
  */
39700a
 
39700a
-/* We need to include config-util.h.in for HAVE_*.  */
39700a
-#ifndef __STDC_VERSION__
39700a
-#define __STDC_VERSION__ 0
39700a
-#endif
39700a
-#include <config-util.h>
39700a
-
39700a
-/* On x86 these functions aren't really needed. Save some space.  */
39700a
-#if !defined (__i386__) && !defined (__x86_64__)
39700a
-# ifdef HAVE___ASHLDI3
39700a
-void EXPORT_FUNC (__ashldi3) (void);
39700a
-# endif
39700a
-# ifdef HAVE___ASHRDI3
39700a
-void EXPORT_FUNC (__ashrdi3) (void);
39700a
-# endif
39700a
-# ifdef HAVE___LSHRDI3
39700a
-void EXPORT_FUNC (__lshrdi3) (void);
39700a
-# endif
39700a
-# ifdef HAVE___UCMPDI2
39700a
-void EXPORT_FUNC (__ucmpdi2) (void);
39700a
-# endif
39700a
-# ifdef HAVE___BSWAPSI2
39700a
-void EXPORT_FUNC (__bswapsi2) (void);
39700a
-# endif
39700a
-# ifdef HAVE___BSWAPDI2
39700a
-void EXPORT_FUNC (__bswapdi2) (void);
39700a
-# endif
39700a
-#endif
39700a
-
39700a
-#ifdef HAVE__RESTGPR_14_X
39700a
-void EXPORT_FUNC (_restgpr_14_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_15_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_16_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_17_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_18_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_19_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_20_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_21_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_22_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_23_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_24_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_25_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_26_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_27_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_28_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_29_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_30_x) (void);
39700a
-void EXPORT_FUNC (_restgpr_31_x) (void);
39700a
-void EXPORT_FUNC (_savegpr_14) (void);
39700a
-void EXPORT_FUNC (_savegpr_15) (void);
39700a
-void EXPORT_FUNC (_savegpr_16) (void);
39700a
-void EXPORT_FUNC (_savegpr_17) (void);
39700a
-void EXPORT_FUNC (_savegpr_18) (void);
39700a
-void EXPORT_FUNC (_savegpr_19) (void);
39700a
-void EXPORT_FUNC (_savegpr_20) (void);
39700a
-void EXPORT_FUNC (_savegpr_21) (void);
39700a
-void EXPORT_FUNC (_savegpr_22) (void);
39700a
-void EXPORT_FUNC (_savegpr_23) (void);
39700a
-void EXPORT_FUNC (_savegpr_24) (void);
39700a
-void EXPORT_FUNC (_savegpr_25) (void);
39700a
-void EXPORT_FUNC (_savegpr_26) (void);
39700a
-void EXPORT_FUNC (_savegpr_27) (void);
39700a
-void EXPORT_FUNC (_savegpr_28) (void);
39700a
-void EXPORT_FUNC (_savegpr_29) (void);
39700a
-void EXPORT_FUNC (_savegpr_30) (void);
39700a
-void EXPORT_FUNC (_savegpr_31) (void);
39700a
-#endif
39700a
-
39700a
 #if defined (__arm__)
39700a
 void EXPORT_FUNC (__aeabi_lasr) (void);
39700a
 void EXPORT_FUNC (__aeabi_llsl) (void);
39700a
-- 
27a4da
2.13.0
39700a