summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Config.lb2
-rw-r--r--src/lib/Makefile.inc1
-rw-r--r--src/lib/gcc.c34
3 files changed, 37 insertions, 0 deletions
diff --git a/src/lib/Config.lb b/src/lib/Config.lb
index 64682da648..7569d856f0 100644
--- a/src/lib/Config.lb
+++ b/src/lib/Config.lb
@@ -17,6 +17,8 @@ object delay.o
object fallback_boot.o
object compute_ip_checksum.o
object version.o
+object gcc.o
+
# Force version.o to recompile every time
makedefine .PHONY : version.o
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 65abde0d53..ebf6fd2a8d 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -12,6 +12,7 @@ obj-y += version.o
obj-y += cbfs.o
obj-y += lzma.o
#obj-y += lzmadecode.o
+obj-y += gcc.o
initobj-y += uart8250.o
initobj-y += memset.o
diff --git a/src/lib/gcc.c b/src/lib/gcc.c
new file mode 100644
index 0000000000..edd3eb997b
--- /dev/null
+++ b/src/lib/gcc.c
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2009 coresystems GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+/* 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 __real_##name(type a, type b) __attribute__((regparm(0))); \
+ type __wrap_##name(type a, type b) { return __real_##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)
+