summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-03-11 20:07:03 -0500
committerJavier Martinez Canillas <javier@dowhile0.org>2021-03-12 10:15:01 +0100
commitb5a7c8ce6012ec8d5f9f2515537f918ef4ca9358 (patch)
tree4aca38dc9cf52fdcad7351385158419ffbaf5682 /include
parent4457d79ce0ea638e7732f5529bf13849e290940d (diff)
downloadefi-boot-shim-b5a7c8ce6012ec8d5f9f2515537f918ef4ca9358.tar.gz
efi-boot-shim-b5a7c8ce6012ec8d5f9f2515537f918ef4ca9358.zip
Don't even try to use builtins, just make sure we have the same types.
For some reason when we try to ever use the builtins, even with the symbol there as a fallback, something goes horribly wrong somewhere around here: | (gdb) bt | #0 strcmp (s1=0x7d492359 "MD5", s2=0x7d492359 "MD5") at include/system/string.h:57 | #1 0x000000007d460419 in getrn (lh=lh@entry=0x7e081318, data=data@entry=0x7e084398, rhash=rhash@entry=0x7f7c9268) at crypto/lhash/lhash.c:415 | #2 0x000000007d46076e in lh_insert (lh=0x7e081318, data=data@entry=0x7e084398) at crypto/lhash/lhash.c:188 | #3 0x000000007d43e027 in OBJ_NAME_add (name=name@entry=0x7d492359 "MD5", type=type@entry=1, data=data@entry=0x7d4ad3a0 <md5_md> "\004") at crypto/objects/o_names.c:202 As much as I love a Sisyphean challenge, in the interest of not having bugs or time, this patch changes it to just not use them for anything other than guaranteeing our implementations have the exact same types as you would expect. Signed-off-by: Peter Jones <pjones@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/system/builtins_begin_.h89
-rw-r--r--include/system/builtins_end_.h11
2 files changed, 35 insertions, 65 deletions
diff --git a/include/system/builtins_begin_.h b/include/system/builtins_begin_.h
index 92ea5e3a..2686c41c 100644
--- a/include/system/builtins_begin_.h
+++ b/include/system/builtins_begin_.h
@@ -1,94 +1,65 @@
// SPDX-License-Identifier: BSD-2-Clause-Patent
/**
- * macros to build builtin wrappers
+ * macros to build function declarations with the same types as builtins
+ * that we apparently really cannot depend on.
*/
-#ifndef mkbi_cat_
-#define mkbi_cat_(a, b) a##b
-#endif
-#ifdef SHIM_STRING_C_
+
+/*
+ * Clang's __builtin_whatever and __typeof__ are broken thusly:
+ * In file included from MokManager.c:2:
+ * In file included from shim.h:47:
+ * include/system/string.h:29:1: error: builtin functions must be directly called
+ * mkbi1_(long int, ffsl, long int, x)
+ * ^
+ */
+#if defined(__clang__)
#ifndef mkbi1_
-#define mkbi1_(rtype, x, typea, a) __typeof__(mkbi_cat_(__builtin_, x)) x;
+#define mkbi1_(rtype, x, typea, a) rtype x(typea a);
#endif
+
#ifndef mkbi2_
-#define mkbi2_(rtype, x, typea, a, typeb, b) __typeof__(mkbi_cat_(__builtin_, x)) x;
+#define mkbi2_(rtype, x, typea, a, typeb, b) rtype x(typea a, typeb b);
#endif
#ifndef mkbi3_
-#define mkbi3_(rtype, x, typea, a, typeb, b, typec, c) __typeof__(mkbi_cat_(__builtin_, x)) x;
+#define mkbi3_(rtype, x, typea, a, typeb, b, typec, c) rtype x(typea a, typeb b, typec c);
#endif
#ifndef mkdepbi1_
-#define mkdepbi1_(rtype, x, typea, a) __typeof__(mkbi_cat_(__builtin_, x)) x;
+#define mkdepbi1_(rtype, x, typea, a) rtype x(typea a);
#endif
#ifndef mkdepbi2_
-#define mkdepbi2_(rtype, x, typea, a, typeb, b) __typeof__(mkbi_cat_(__builtin_, x)) x;
+#define mkdepbi2_(rtype, x, typea, a, typeb, b) rtype x(typea a, typeb b);
#endif
-#else /* ! SHIM_STRING_C_ */
+#else /* !__clang__ */
+
+#ifndef mkbi_cat_
+#define mkbi_cat_(a, b) a##b
+#endif
#ifndef mkbi1_
-#define mkbi1_(rtype, x, typea, a) \
- static inline __attribute__((__unused__)) \
- rtype \
- x(typea a) \
- { \
- return mkbi_cat_(__builtin_, x)(a); \
- }
+#define mkbi1_(rtype, x, typea, a) __typeof__(mkbi_cat_(__builtin_, x)) x;
#endif
#ifndef mkbi2_
-#define mkbi2_(rtype, x, typea, a, typeb, b) \
- static inline __attribute__((__unused__)) \
- rtype \
- x(typea a, typeb b) \
- { \
- return mkbi_cat_(__builtin_, x)(a, b); \
- }
+#define mkbi2_(rtype, x, typea, a, typeb, b) __typeof__(mkbi_cat_(__builtin_, x)) x;
#endif
#ifndef mkbi3_
-#define mkbi3_(rtype, x, typea, a, typeb, b, typec, c) \
- static inline __attribute__((__unused__)) \
- rtype \
- x(typea a, typeb b, typec c) \
- { \
- return mkbi_cat_(__builtin_, x)(a, b,c); \
- }
-#endif
-
-#ifdef SHIM_DEPRECATE_STRLEN
-#ifndef mkdepbi_dep_
-#define mkdepbi_dep_ __attribute__((__deprecated__))
-#endif
-#else /* !SHIM_DEPRECATE_STRLEN */
-#ifndef mkdepbi_dep_
-#define mkdepbi_dep_
+#define mkbi3_(rtype, x, typea, a, typeb, b, typec, c) __typeof__(mkbi_cat_(__builtin_, x)) x;
#endif
-#endif /* SHIM_DEPRECATE_STRLEN */
#ifndef mkdepbi1_
-#define mkdepbi1_(rtype, x, typea, a) \
- static inline __attribute__((__unused__)) \
- mkdepbi_dep_ \
- rtype \
- x(typea a) \
- { \
- return mkbi_cat_(__builtin_, x)(a); \
- }
+#define mkdepbi1_(rtype, x, typea, a) __typeof__(mkbi_cat_(__builtin_, x)) x;
#endif
#ifndef mkdepbi2_
-#define mkdepbi2_(rtype, x, typea, a, typeb, b) \
- static inline __attribute__((__unused__)) \
- mkdepbi_dep_ \
- rtype \
- x(typea a, typeb b) \
- { \
- return mkbi_cat_(__builtin_, x)(a, b); \
- }
+#define mkdepbi2_(rtype, x, typea, a, typeb, b) __typeof__(mkbi_cat_(__builtin_, x)) x;
#endif
-#endif /* SHIM_STRING_C_ */
+
+#endif /* !__clang__ */
// vim:fenc=utf-8:tw=75:noet
diff --git a/include/system/builtins_end_.h b/include/system/builtins_end_.h
index 0a6ad60a..0bcd7661 100644
--- a/include/system/builtins_end_.h
+++ b/include/system/builtins_end_.h
@@ -3,26 +3,25 @@
#ifdef mkbi1_
#undef mkbi1_
#endif
+
#ifdef mkbi2_
#undef mkbi2_
#endif
+
#ifdef mkbi3_
#undef mkbi3_
#endif
+
#ifdef mkdepbi1_
#undef mkdepbi1_
#endif
+
#ifdef mkdepbi2_
#undef mkdepbi2_
#endif
-#ifdef mkdepbi_dep_
-#undef mkdepbi_dep_
-#endif
+
#ifdef mkbi_cat_
#undef mkbi_cat_
#endif
-#ifdef _BUILTINS_BEGIN__H
-#undef _BUILTINS_BEGIN__H
-#endif
// vim:fenc=utf-8:tw=75:noet