Implement link-time optimization safe explicit_bzero()?
Sebastian Huber
sebastian.huber@embedded-brains.de
Thu Feb 11 14:28:00 GMT 2016
Hello,
how can I implement a link-time optimization safe explicit_bzero() that works with a fully LTO enabled statically linked program?
I guess this trick will not work:
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/explicit_bzero.c?rev=1.4&content-type=text/x-cvsweb-markup
/* $OpenBSD: explicit_bzero.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */
/*
* Public domain.
* Written by Matthew Dempsky.
*/
#include <string.h>
__attribute__((weak)) void
__explicit_bzero_hook(void *buf, size_t len)
{
}
void
explicit_bzero(void *buf, size_t len)
{
memset(buf, 0, len);
__explicit_bzero_hook(buf, len);
}
DEF_WEAK(explicit_bzero);
Do I really need something like this:
http://www.openwall.com/lists/musl/2014/06/11/5
__asm__ volatile ("" : : "r"(buf) : "memory");
Is the "r" constraint available on all architectures?
I could use a memset_s(). Will it be supported in all future GCC versions? The future state of the Annex K is not clear:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1969.htm
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the Gcc-help
mailing list