<div dir="ltr"><div class="gmail_default" style="font-family:&#39;courier new&#39;,monospace">why can not <span style="font-family:arial,sans-serif;font-size:12.800000190734863px">__builtin_return_address() be made *never* inline and use current level+1 to get the return address of the function of interest.  For any stack introspection, having 1 more level will not hurt functionality. </span></div>
<div class="gmail_default" style="font-family:&#39;courier new&#39;,monospace"><br></div><div class="gmail_default" style="font-family:&#39;courier new&#39;,monospace">given its explanation below </div><div class="gmail_default" style="font-family:&#39;courier new&#39;,monospace">
<br></div><div class="gmail_default" style="font-family:&#39;courier new&#39;,monospace"><span style="color:rgb(0,0,0);font-family:&#39;Times New Roman&#39;;font-size:medium">— Built-in Function: void * </span><b style="color:rgb(0,0,0);font-family:&#39;Times New Roman&#39;;font-size:medium">__builtin_return_address</b><span style="color:rgb(0,0,0);font-family:&#39;Times New Roman&#39;;font-size:medium"> (</span><var style="color:rgb(0,0,0);font-family:&#39;Times New Roman&#39;;font-size:medium">unsigned int level</var><span style="color:rgb(0,0,0);font-family:&#39;Times New Roman&#39;;font-size:medium">)</span><var style="color:rgb(0,0,0);font-family:&#39;Times New Roman&#39;;font-size:medium"><a name="index-g_t_005f_005fbuiltin_005freturn_005faddress-3207"></a></var><br style="color:rgb(0,0,0);font-family:&#39;Times New Roman&#39;;font-size:medium">
<blockquote style="color:rgb(0,0,0);font-family:&#39;Times New Roman&#39;;font-size:medium"><p>This function returns the return address of the current function, or of one of its callers. The <var>level</var> argument is number of frames to scan up the call stack. A value of <code>0</code> yields the return address of the current function, a value of <code>1</code> yields the return address of the caller of the current function, and so forth. When inlining the expected behavior is that the function returns the address of the function that is returned to. To work around this behavior use the <code>noinline</code> function attribute.</p>
<p><br></p></blockquote></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 30, 2014 at 11:18 AM,  <span dir="ltr">&lt;<a href="mailto:Valdis.Kletnieks@vt.edu" target="_blank">Valdis.Kletnieks@vt.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, 30 Jul 2014 09:03:38 -0500, Xin Tong said:<br>
<br>
&gt; Ive heard that one can not build the entire Linux kernel with -O0 option.<br>
&gt; why is that ? being a compiler developer, i can not think of reasons why<br>
&gt; that is the case.<br>
<br>
</div></div>The short answer:  -O0 completely suppresses function inlining, and there<br>
are several places where the kernel depends on inlining for correct<br>
operation (most notably with things like __builtin_return_address()<br>
and friends for introspecting the stack, but there&#39;s a few other<br>
corner cases I can&#39;t remember at the moment...)<br>
</blockquote></div><br></div>