Some mips compilers insert 64-bit division into the
code compiled from libgcrypt source and possibly others.
Rether than fighting it, simply provide the function in
question.

Signed-off-by: Vladimir Serbinenko <phco...@gmail.com>
---
 grub-core/kern/compiler-rt.c | 32 ++++++++++++++++++--------------
 include/grub/compiler-rt.h   |  4 ++++
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c
index eda689a0c..c83cf3d2d 100644
--- a/grub-core/kern/compiler-rt.c
+++ b/grub-core/kern/compiler-rt.c
@@ -82,20 +82,6 @@ __modsi3 (grub_int32_t a, grub_int32_t b)
   return ret;
 }
 
-grub_uint64_t
-__udivdi3 (grub_uint64_t a, grub_uint64_t b)
-{
-  return grub_divmod64 (a, b, 0);
-}
-
-grub_uint64_t
-__umoddi3 (grub_uint64_t a, grub_uint64_t b)
-{
-  grub_uint64_t ret;
-  grub_divmod64 (a, b, &ret);
-  return ret;
-}
-
 grub_int64_t
 __divdi3 (grub_int64_t a, grub_int64_t b)
 {
@@ -112,6 +98,24 @@ __moddi3 (grub_int64_t a, grub_int64_t b)
 
 #endif
 
+#if GRUB_DIVISION_IN_SOFTWARE || defined(__mips__)
+
+grub_uint64_t
+__udivdi3 (grub_uint64_t a, grub_uint64_t b)
+{
+  return grub_divmod64 (a, b, 0);
+}
+
+grub_uint64_t
+__umoddi3 (grub_uint64_t a, grub_uint64_t b)
+{
+  grub_uint64_t ret;
+  grub_divmod64 (a, b, &ret);
+  return ret;
+}
+
+#endif
+
 #endif
 
 #ifdef NEED_CTZDI2
diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h
index 43fd8f4d7..979c3db16 100644
--- a/include/grub/compiler-rt.h
+++ b/include/grub/compiler-rt.h
@@ -45,6 +45,10 @@ EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b);
 grub_int64_t
 EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b);
 
+#endif
+
+#if (defined(GRUB_DIVISION_IN_SOFTWARE) && GRUB_DIVISION_IN_SOFTWARE) || 
defined(__mips__)
+
 grub_uint64_t
 EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b);
 
-- 
2.49.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to