On Tue, Nov 14, 2017 at 11:36 AM, Jorge Almeida <jjalme...@gmail.com> wrote:
> On Fri, Nov 10, 2017 at 12:09 PM, Jorge Almeida <jjalme...@gmail.com> wrote:
>
>> http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html
>>
>>
>>>> Of course, what would really solve the optimize-into-oblivion problem
>>>> is a pragma that when invoked on a particular block of code (maybe
>>>> only a function definition) would tell the compiler to do what the
>>>> programmer says rather than viewing a function as a kind of black box.
>>>>
>>>
>
> It seems a solution exists with gcc:
>
> https://stackoverflow.com/questions/2219829/how-to-prevent-gcc-optimizing-some-statements-in-c
>
> The last reply:
>
> void __attribute__((optimize("O0"))) foo(unsigned char data) {
>     // unmodifiable compiler code
> }
>
> Any comments, anyone? Yes, it's gcc, but IMO this should be in the
> language itself. Am I right to assume this is a poorly known feature
> of gcc?
> It allows, for example,  to replace sensitive data by random bytes,
> existing system callls like memset() or getrandom() can be used as
> they are, no reimplementation needed.
>

Very interesting. I imagine the opinion of the standards committee
would be that the variability in code generation precludes a standard
interface to optimization controls. This might seem unusual, but
languages with a very controlling standard (like Java or C#) are a new
concept.

What I am wondering about is if C code which uses
__attribute__((optimize(...))) is against Gentoo package standards and
would have to be removed from the Portage tree.

Cheers,
     R0b0t1

Reply via email to