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