[PATCH 3/3] Prevent link-time optimization from inlining __gcry_burn_stack
Jussi Kivilinna
jussi.kivilinna at iki.fi
Wed Dec 2 20:08:38 CET 2020
* src/g10lib.h (NOINLINE_FUNC): New attribute macro.
* src/misc.c (__gcry_burn_stack): Add NOINLINE_FUNC attribute.
--
LTO can cause inline of __gcry_burn_stack and result tail-call
to _gcry_fast_wipememory and defeat tail-call prevention in
_gcry_burn_stack macro. Mark __gcry_burn_stack with 'noinline'
attribute to prevent unwanted inlining of this function in
LTO builds.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
src/g10lib.h | 6 ++++++
src/misc.c | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/g10lib.h b/src/g10lib.h
index c85e6649..ffd71018 100644
--- a/src/g10lib.h
+++ b/src/g10lib.h
@@ -75,6 +75,12 @@
#define GCC_ATTR_UNUSED
#endif
+#if __GNUC__ > 3
+#define NOINLINE_FUNC __attribute__((noinline))
+#else
+#define NOINLINE_FUNC
+#endif
+
#if __GNUC__ >= 3
#define LIKELY(expr) __builtin_expect( !!(expr), 1 )
#define UNLIKELY(expr) __builtin_expect( !!(expr), 0 )
diff --git a/src/misc.c b/src/misc.c
index 283e3a72..4db2d9a4 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -545,7 +545,7 @@ _gcry_fast_wipememory2 (void *ptr, int set, size_t len)
}
-void
+void NOINLINE_FUNC
__gcry_burn_stack (unsigned int bytes)
{
#ifdef HAVE_VLA
--
2.27.0
More information about the Gcrypt-devel
mailing list