<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>BX LR generation</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/26973/bx-lr-generation</link><description> 
Hello, 

 
I hope somebody can clarify this issue for me - I am sure it is
somewhere in th ABI for it escapes me. 
Using ARM7 architecture (LPC2478), I have a function written in C
that is called (BL) from the startup file. The problem is that the
compiler</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: BX LR generation</title><link>https://community.arm.com/thread/104298?ContentTypeID=1</link><pubDate>Fri, 08 Oct 2010 00:25:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:96f8cc11-fd40-4f2e-9830-377718f612d5</guid><dc:creator>Marcus Harnisch</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;gt; Well, another good reason for a compiler to omit a return
from a function is the case when&lt;br /&gt;
&amp;gt; the function doesn&amp;#39;t ever return, like a typical main().&lt;/p&gt;

&lt;p&gt;
Or in case the compiler applied tail-call optimization.&lt;/p&gt;

&lt;pre&gt;
int var;

int bar()
{
   return var;
}

int foo()
{
   return bar();
}
&lt;/pre&gt;

&lt;p&gt;
(assuming the compiler doesn&amp;#39;t inline this silly example)&lt;/p&gt;

&lt;p&gt;
--&lt;br /&gt;
Marcus&lt;br /&gt;
&lt;a href="http://www.doulos.com/arm/"&gt;http://www.doulos.com/arm/&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BX LR generation</title><link>https://community.arm.com/thread/104297?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2010 23:35:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9166a4e6-229b-4d06-8450-fe26d4ed11ed</guid><dc:creator>Non Keil Related</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;Well, another good reason for a compiler to omit a return from
a function is the case when the function doesn&amp;#39;t ever return, like a
typical main().&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
A valid point, I&amp;#39;d forgotten that one.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BX LR generation</title><link>https://community.arm.com/thread/104295?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2010 23:11:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3288ccb3-105c-4d26-a571-0535b923d98f</guid><dc:creator>Tamiryan Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Mike,&lt;/p&gt;

&lt;p&gt;
I have an enormous amount of work now. I will try to post a code
snippet in the very near future.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BX LR generation</title><link>https://community.arm.com/thread/90662?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2010 23:01:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:af36390d-6b2e-4078-94e3-508ca2131f8f</guid><dc:creator>Mike Kleshov</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;The only instance I know of where the compiler does not
generate a return from a function is when it is an __asm function, so
you add it to the function yourself.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Well, another good reason for a compiler to omit a return from a
function is the case when the function doesn&amp;#39;t ever return, like a
typical main().&lt;br /&gt;
So yes, some actual source code would be in order.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BX LR generation</title><link>https://community.arm.com/thread/90658?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2010 09:11:35 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c9e32d1d-ad75-492a-b4e7-27ab284657c8</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;if I place the function that is called from startup code in a
separate C module - a &amp;quot;BX LR&amp;quot; is generated!&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
And you&amp;#39;re sure that&amp;#39;s not just because the compiler inlined that
function, and thus there was no need to return from it?&lt;/p&gt;

&lt;p&gt;
A little actual source and actual assembler output of both that
function and its caller would go a long way towards clarifying this
puzzle...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BX LR generation</title><link>https://community.arm.com/thread/116056?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2010 08:24:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5f6fc3de-06da-461e-b129-36a073b4235c</guid><dc:creator>Tamiryan Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Mid-October? First it was mid-September, then beginning October,
and now this...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BX LR generation</title><link>https://community.arm.com/thread/104299?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2010 07:49:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e7b184b7-2a26-4c96-b504-c14b0a7d416a</guid><dc:creator>Non Keil Related</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;YES!&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
OMG. Sounds nasty!&lt;/p&gt;

&lt;p&gt;
I reported a problem with compiler produced code a few weeks ago
(-O3 was creating faulty inline code) and was told that there should
be a compiler update around mid-October.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BX LR generation</title><link>https://community.arm.com/thread/90657?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2010 07:42:28 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d1d7a2f3-f95d-46df-af72-86e22ba41aa4</guid><dc:creator>Tamiryan Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;Are you saying that your one C function just falls through to
the next?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
YES!&lt;/p&gt;

&lt;p&gt;
I will try to send this program to Keil so they can see it. This
cause me SO MUCH heard ache today (when combined with other
changes...).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BX LR generation</title><link>https://community.arm.com/thread/58736?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2010 07:09:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f0fdd5a2-2490-4aa1-b7ea-a2d4f80584a9</guid><dc:creator>Non Keil Related</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;...the compiler does not generate a &amp;quot;BX LR&amp;quot; instruction at its
end.&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
The only instance I know of where the compiler does not generate a
return from a function is when it is an &lt;b&gt;__asm&lt;/b&gt; function, so you
add it to the function yourself.&lt;/p&gt;

&lt;p&gt;
If you look at the assembler produced for the C module, you surely
see the returns in other functions?&lt;/p&gt;

&lt;p&gt;
Are you saying that your one C function just falls through to the
next?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BX LR generation</title><link>https://community.arm.com/thread/58737?ContentTypeID=1</link><pubDate>Thu, 07 Oct 2010 07:07:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6dc1bf8e-f639-4e6f-a03b-4b8b38371de0</guid><dc:creator>Tamiryan Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
I think this is a tool chain but - if I place the function that is
called from startup code in a separate C module - a &amp;quot;BX LR&amp;quot; is
generated!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>