Implement link-time optimization safe explicit_bzero()?

Manuel López-Ibáñez manuel.lopez-ibanez@manchester.ac.uk
Thu Feb 11 16:25:00 GMT 2016


On 11/02/16 14:29, Sebastian Huber wrote:
> Hello,
>
> how can I implement a link-time optimization safe explicit_bzero() that works with a fully LTO enabled statically linked program?

My understanding by reading this thread 
(https://sourceware.org/ml/libc-alpha/2016-01/msg00208.html) is that this is 
not possible at the moment because of lacking compiler support. See also 
https://sourceware.org/ml/libc-alpha/2015-11/msg00467.html and follow-ups.

If I were to tackle this problem, I would try first to implement a 
__builtin_explicit_bzero() directly in GCC such that GCC will know exactly how 
to handle it. This would be faster, safer and more portable than any trick you 
may get working now (since LTO keeps improving), and it will provide the basis 
for a gnu libc implementation.

Even if a builtin is not the right way, the process of proposing such a patch 
may point to a better way. And even if you cannot wait for your patch to be in 
the next GCC release, the process of developing it will teach you about how a 
workaround may work with current releases.

Of course, there is the question of whether explicit_bzero() or similar 
functions are a solution at all to any problem 
(https://sourceware.org/ml/libc-alpha/2016-01/msg00208.html)

Cheers,

Manuel.



More information about the Gcc-help mailing list