Use weak symbols to prevent LTO if this is an option.
Idea from Matthew Dempsky.
This commit is contained in:
parent
c7418dfd58
commit
957315035a
10
configure.ac
10
configure.ac
@ -375,6 +375,16 @@ __asm__ __volatile__ ("xchgl %%ebx, %k1; cpuid; xchgl %%ebx, %k1" :
|
|||||||
])
|
])
|
||||||
AC_SUBST(HAVE_CPUID_V)
|
AC_SUBST(HAVE_CPUID_V)
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(if weak symbols are supported)
|
||||||
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||||
|
__attribute__((weak)) void __dummy(void *x) { }
|
||||||
|
void f(void *x) { __dummy(x); }
|
||||||
|
]], [[ ]]
|
||||||
|
)],
|
||||||
|
[AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE([HAVE_WEAK_SYMBOLS], [1], [weak symbols are supported])],
|
||||||
|
[AC_MSG_RESULT(no)])
|
||||||
|
|
||||||
AS_CASE([$host_cpu],
|
AS_CASE([$host_cpu],
|
||||||
[i*86 | x86_64 | powerpc* | s390*],
|
[i*86 | x86_64 | powerpc* | s390*],
|
||||||
[AC_MSG_NOTICE([data alignment is not required on this target])],
|
[AC_MSG_NOTICE([data alignment is not required on this target])],
|
||||||
|
@ -19,6 +19,11 @@
|
|||||||
# include <wincrypt.h>
|
# include <wincrypt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_WEAK_SYMBOLS
|
||||||
|
__attribute__((weak)) void
|
||||||
|
__sodium_dummy_symbol_to_prevent_lto(void * const pnt, const size_t len) { }
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
sodium_memzero(void * const pnt, const size_t len)
|
sodium_memzero(void * const pnt, const size_t len)
|
||||||
{
|
{
|
||||||
@ -30,6 +35,9 @@ sodium_memzero(void * const pnt, const size_t len)
|
|||||||
}
|
}
|
||||||
#elif defined(HAVE_EXPLICIT_BZERO)
|
#elif defined(HAVE_EXPLICIT_BZERO)
|
||||||
explicit_bzero(pnt, len);
|
explicit_bzero(pnt, len);
|
||||||
|
#elif HAVE_WEAK_SYMBOLS
|
||||||
|
memset(pnt, 0, len);
|
||||||
|
__sodium_dummy_symbol_to_prevent_lto(pnt, len);
|
||||||
#else
|
#else
|
||||||
volatile unsigned char *pnt_ = (volatile unsigned char *) pnt;
|
volatile unsigned char *pnt_ = (volatile unsigned char *) pnt;
|
||||||
size_t i = (size_t) 0U;
|
size_t i = (size_t) 0U;
|
||||||
|
Loading…
Reference in New Issue
Block a user