<!DOCTYPE html>
<html><head>
<meta charset="UTF-8">
</head><body>Yep that's what I mean. As I said this is a very simplistic example. Reverse or bypass certain code areas is just one topic. The other equally imported is fault-tolerance.<br>The open question is how to define a set of objects and tell the optimizer <br>to leave them untouched.<br><br><blockquote type="cite">
mats petersson <mats@planetcatfish.com> hat am 23. November 2016 um 12:15 geschrieben:<br><br><div dir="ltr"><div><div>Did you mean *res0 = 1, *res1 = 1?<br><br></div>And you do realize that for anything that is worth reverse engineering, this will just add a few minutes to someones time when trying to reverse engineer/bypass your code?<br><br></div><div>Obviously, if the compiler decides to inline `foo`, and then you haven't got a use for `*res0` and `*res1`, it will still just optimise it away.<br></div><div><br>--<br></div>Mats<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 23 November 2016 at 10:44, Compiler Dragon via cfe-dev <span><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote">Hi Mats,<br>
<br>
thanks for your reply. Basically I want to implement some defensive actions against unauthorized code changes. The artifical introduced variables are used in a specifc manner and should be left untouched<br>
by the optimizer.<br>
<br>
One very basic and simplistic example:<br>
<br>
Original code:<br>
<br>
res = foo(a);<br>
---<br>
int foo(int a) {<br>
int b;<br>
...<br>
b = a + 1;<br>
...<br>
return(b);<br>
}<br>
<br>
Transformed code:<br>
<br>
foo(a0, a1, &res0, &res1);<br>
...<br>
void foo(int a0, int a1, int *res0, int *res1) {<br>
int a0, a1;<br>
...<br>
b0 = a0 + 1;<br>
b1 = a1 + 1;<br>
if ( b0 != b1 )<br>
throw_error();<br>
...<br>
*b0 = 1;<br>
*b1 = 1;<br>
return;<br>
<br>
Thanks<br>
<br>
Marcel<br>
<div class="HOEnZb"><div class="h5"><br>
> If they are not used, why do you want them to remain? `volatile` can be<br>
> used to ensure that the compiler doesn't optimise something away, or<br>
> "explicit use in a way that is never true - but compiler doesn't know it is<br>
> so" (e.g. `if (sin(x) > 1.0) { do stuff that actually never happens }` ) -<br>
> calling `sin` is probably not the best choice, but there may be other ways<br>
> to achieve something similar that is less intrusive but still "unknown to<br>
> the compiler".<br>
><br>
><br>
> Can you give an example piece of code?<br>
><br>
> --<br>
> Mats<br>
><br>
> On 22 November 2016 at 10:37, Compiler Dragon via cfe-dev <<br>
> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> > Hi *,<br>
> ><br>
> > I am currently writing a clang plugin, which add to specific functions for<br>
> > e.g. additional arguments.<br>
> ><br>
> > How can I instruct the optimizer not to throw out these arguments, because<br>
> > they are not used in the function body?<br>
> ><br>
> > With (optnone) we can instruct the optimizer to not optimize the whole<br>
> > function. But this ist not what I want. The function body should be<br>
> > optimized like before.<br>
> ><br>
> > Any idea or hints where to look?<br>
> ><br>
> > Thanks<br>
> ><br>
> > Marcel<br>
______________________________<wbr/>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr/>mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div>
</blockquote>
<br> </body></html>