diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2020-11-07 10:30:05 +0200 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2020-12-03 20:55:51 +0200 |
commit | 1a83df98b198902ee6d71549231a3af37088d452 (patch) | |
tree | d5855d5b65566302b67eb38b24636b3338433efb | |
parent | 2065720b5b0642cc1a0e08086a434244ebb1abf2 (diff) | |
download | libgcrypt-1a83df98b198902ee6d71549231a3af37088d452.tar.gz |
Prevent link-time optimization from inlining __gcry_burn_stack
* 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@iki.fi>
-rw-r--r-- | src/g10lib.h | 6 | ||||
-rw-r--r-- | src/misc.c | 2 |
2 files changed, 7 insertions, 1 deletions
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 ) @@ -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 |