summaryrefslogtreecommitdiffstats
path: root/meta-sota/recipes-bsp/u-boot/u-boot-ota/0002-Replace-wraps-with-built-in-code-to-remove-dependenc.patch
blob: 7540b74677e86c9cb3966b0dfa80ecf7a1c2fc76 (plain)
1

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.h
From ab0d7e270d89f6eb99582197d2d58bf60c9c3d26 Mon Sep 17 00:00:00 2001
From: Anton Gerasimov <anton@advancedtelematic.com>
Date: Thu, 15 Sep 2016 16:49:32 +0200
Subject: [PATCH 2/2] Replace wraps with built-in code to remove dependency on
 multilib

---
 arch/x86/config.mk |   2 --
 arch/x86/lib/gcc.c | 104 ++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 87 insertions(+), 19 deletions(-)

diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 999143e..139576e 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -22,5 +22,3 @@ PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
 PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions -m elf_i386
 
 LDFLAGS_FINAL += --gc-sections -pie
-LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
-LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
diff --git a/arch/x86/lib/gcc.c b/arch/x86/lib/gcc.c
index 497ad75..c321b11 100644
--- a/arch/x86/lib/gcc.c
+++ b/arch/x86/lib/gcc.c
@@ -19,22 +19,92 @@
 
 #ifdef __GNUC__
 
-/*
- * GCC's libgcc handling is quite broken. While the libgcc functions
- * are always regparm(0) the code that calls them uses whatever the
- * compiler call specifies. Therefore we need a wrapper around those
- * functions. See gcc bug PR41055 for more information.
- */
-#define WRAP_LIBGCC_CALL(type, name) \
-	type __normal_##name(type a, type b) __attribute__((regparm(0))); \
-	type __wrap_##name(type a, type b); \
-	type __attribute__((no_instrument_function)) \
-		__wrap_##name(type a, type b) \
-		 { return __normal_##name(a, b); }
-
-WRAP_LIBGCC_CALL(long long, __divdi3)
-WRAP_LIBGCC_CALL(unsigned long long, __udivdi3)
-WRAP_LIBGCC_CALL(long long, __moddi3)
-WRAP_LIBGCC_CALL(unsigned long long, __umoddi3)
+#include <stdint.h>
+#include <stddef.h>
+
+uint64_t __udivmoddi4 ( uint64_t num,
+                       uint64_t den,
+                       uint64_t *rem_p )
+{
+       uint64_t quot = 0, qbit = 1;
+
+       if ( den == 0 ) {
+               return 1/((unsigned)den); /* Intentional divide by zero, without
+                                            triggering a compiler warning which
+                                            would abort the build */
+       }
+
+       /* Left-justify denominator and count shift */
+       while ( (int64_t)den >= 0 ) {
+               den <<= 1;
+               qbit <<= 1;
+       }
+
+       while ( qbit ) {
+               if ( den <= num ) {
+                       num -= den;
+                       quot += qbit;
+               }
+               den >>= 1;
+               qbit >>= 1;
+       }
+
+       if ( rem_p )
+               *rem_p = num;
+
+       return quot;
+}      
+uint64_t __udivdi3( uint64_t num, uint64_t den )
+{
+       return __udivmoddi4(num, den, NULL);
+}
+
+uint64_t __umoddi3 ( uint64_t num, uint64_t den )
+{
+       uint64_t v;
+
+       (void) __udivmoddi4(num, den, &v);
+       return v;
+}
+
+int64_t __divmoddi4 ( int64_t num,
+               int64_t den,
+               int64_t* rem_p )
+{
+       int minus = 0;
+       int64_t v;
+
+       if ( num < 0 ) {
+               num = -num;
+               minus = 1;
+       }
+       if ( den < 0 ) {
+               den = -den;
+               minus ^= 1;
+       }
+
+       v = __udivmoddi4(num, den, (uint64_t *)rem_p);
+       if ( minus ) {
+               v = -v;
+               if ( rem_p )
+                       *rem_p = -(*rem_p);
+       }
+
+       return v;
+}
+
+
+int64_t __moddi3 (int64_t num, int64_t den)
+{
+       int64_t v;
+
+       (void) __divmoddi4(num, den, &v);
+       return v;
+}
+
+int64_t __divdi3(int64_t num, int64_t den)
+{
+       return __divmoddi4(num, den, NULL);
+}
 
 #endif
-- 
2.9.3