<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: An __builtin_return_address problem? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525441#M651685</link>
    <description>Hello again :)&lt;BR /&gt;I seem to have bumped into a problem using _Asm_get_rp().&lt;BR /&gt;&lt;BR /&gt;I created a test shared object file lib.so&lt;BR /&gt;&lt;BR /&gt;#include&lt;STDIO.H&gt;&lt;BR /&gt;#include&lt;DLFCN.H&gt;&lt;BR /&gt;#include &lt;MACHINE&gt;&lt;BR /&gt;&lt;BR /&gt;void mycall()&lt;BR /&gt;{&lt;BR /&gt;void *p=_Asm_get_rp();&lt;BR /&gt;printf("%lx\n",p);&lt;BR /&gt;Dl_info info;&lt;BR /&gt;dladdr(p,&amp;amp;info);&lt;BR /&gt;printf("%s : %s\n",info.dli_sname,info.dli_fname);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;And i created a try.c that would use this lib.so &lt;BR /&gt;&lt;BR /&gt;#include &lt;MACHINE&gt;&lt;BR /&gt;#include&lt;DLFCN.H&gt;&lt;BR /&gt;#include&lt;STDIO.H&gt;&lt;BR /&gt;void Iwillallocate();&lt;BR /&gt;void func();&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;func();&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void func(){&lt;BR /&gt;    Iwillallocate();&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void Iwillallocate(){&lt;BR /&gt;    mycall();&lt;BR /&gt;}&lt;BR /&gt;--------------------------------------------&lt;BR /&gt;&lt;BR /&gt;I am compiling this using aCC&lt;BR /&gt;Created .so using aCC and all object files.&lt;BR /&gt;&lt;BR /&gt;Te problem that i am facing is... &lt;BR /&gt;The return function name is coming out as &lt;BR /&gt;main()&lt;BR /&gt;instead of&lt;BR /&gt;Iwillallocate()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Could you please tell me what might I be doing wrong?&lt;BR /&gt;&lt;BR /&gt;Thanks a million&lt;BR /&gt;Regards&lt;/STDIO.H&gt;&lt;/DLFCN.H&gt;&lt;/MACHINE&gt;&lt;/MACHINE&gt;&lt;/DLFCN.H&gt;&lt;/STDIO.H&gt;</description>
    <pubDate>Wed, 04 Nov 2009 10:24:49 GMT</pubDate>
    <dc:creator>Wkdunreal</dc:creator>
    <dc:date>2009-11-04T10:24:49Z</dc:date>
    <item>
      <title>An __builtin_return_address problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525438#M651682</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Am using the native compiler (aCC) to compile.&lt;BR /&gt;In my source code at one instance , there is a need for __builtin_return_address to give me the return address of the function.&lt;BR /&gt;&lt;BR /&gt;Using gcc it gets compiled but using aCC I seem to be having a lil bit of problem.&lt;BR /&gt;&lt;BR /&gt;Can someone guide me whether there is a function similar to __builtin_return_address which can give me the function's return address on aCC compiler.&lt;BR /&gt;&lt;BR /&gt;__builtin_return_address(LEVEL)&lt;BR /&gt;&lt;BR /&gt;if i pass LEVEL=1 i get the address of a function a step higher in the stack .&lt;BR /&gt;&lt;BR /&gt;Am using the HP-US 11.31 ia64.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance to all the Stalwarts of this community :)&lt;BR /&gt;Regards</description>
      <pubDate>Mon, 02 Nov 2009 07:32:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525438#M651682</guid>
      <dc:creator>Wkdunreal</dc:creator>
      <dc:date>2009-11-02T07:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: An __builtin_return_address problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525439#M651683</link>
      <description>&amp;gt;whether there is a function similar to __builtin_return_address&lt;BR /&gt;&lt;BR /&gt;Go through the aC++ documentation:&lt;BR /&gt;&lt;A href="http://www.hp.com/go/cpp" target="_blank"&gt;http://www.hp.com/go/cpp&lt;/A&gt;&lt;BR /&gt;Inline assembly for Itanium-based HP-UX&lt;BR /&gt;&lt;A href="http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=4308e2f5bde02110e2f5bde02110275d6e10RCRD" target="_blank"&gt;http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=4308e2f5bde02110e2f5bde02110275d6e10RCRD&lt;/A&gt;&lt;BR /&gt;Table 1-7 Miscellaneous Opcodes&lt;BR /&gt;Table 1-40 Miscellaneous Opcodes&lt;BR /&gt;#include &lt;MACHINE&gt;&lt;BR /&gt;_Asm_get_rp(void);&lt;BR /&gt;&lt;BR /&gt;&amp;gt;if I pass LEVEL=1 I get the address of a function a step higher in the stack.&lt;BR /&gt;&lt;BR /&gt;Chances are, not even GNU can do any levels higher than 0, except for every simple architectures, like HP 3000.&lt;BR /&gt;&lt;BR /&gt;You'll need to use libunwind to get higher than 0.  Your previous thread:&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1369744" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1369744&lt;/A&gt;&lt;/MACHINE&gt;</description>
      <pubDate>Mon, 02 Nov 2009 08:07:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525439#M651683</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-11-02T08:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: An __builtin_return_address problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525440#M651684</link>
      <description>BINGO!!!!&lt;BR /&gt;&lt;BR /&gt;Thanks Dennis :D Thanks a million&lt;BR /&gt;The _Asm_get_rp(void);  worked.&lt;BR /&gt;&lt;BR /&gt;As soon as I run into other dead ends here will get back here :D.&lt;BR /&gt;&lt;BR /&gt;Thanks again :):):)</description>
      <pubDate>Mon, 02 Nov 2009 09:17:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525440#M651684</guid>
      <dc:creator>Wkdunreal</dc:creator>
      <dc:date>2009-11-02T09:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: An __builtin_return_address problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525441#M651685</link>
      <description>Hello again :)&lt;BR /&gt;I seem to have bumped into a problem using _Asm_get_rp().&lt;BR /&gt;&lt;BR /&gt;I created a test shared object file lib.so&lt;BR /&gt;&lt;BR /&gt;#include&lt;STDIO.H&gt;&lt;BR /&gt;#include&lt;DLFCN.H&gt;&lt;BR /&gt;#include &lt;MACHINE&gt;&lt;BR /&gt;&lt;BR /&gt;void mycall()&lt;BR /&gt;{&lt;BR /&gt;void *p=_Asm_get_rp();&lt;BR /&gt;printf("%lx\n",p);&lt;BR /&gt;Dl_info info;&lt;BR /&gt;dladdr(p,&amp;amp;info);&lt;BR /&gt;printf("%s : %s\n",info.dli_sname,info.dli_fname);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;And i created a try.c that would use this lib.so &lt;BR /&gt;&lt;BR /&gt;#include &lt;MACHINE&gt;&lt;BR /&gt;#include&lt;DLFCN.H&gt;&lt;BR /&gt;#include&lt;STDIO.H&gt;&lt;BR /&gt;void Iwillallocate();&lt;BR /&gt;void func();&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;func();&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void func(){&lt;BR /&gt;    Iwillallocate();&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void Iwillallocate(){&lt;BR /&gt;    mycall();&lt;BR /&gt;}&lt;BR /&gt;--------------------------------------------&lt;BR /&gt;&lt;BR /&gt;I am compiling this using aCC&lt;BR /&gt;Created .so using aCC and all object files.&lt;BR /&gt;&lt;BR /&gt;Te problem that i am facing is... &lt;BR /&gt;The return function name is coming out as &lt;BR /&gt;main()&lt;BR /&gt;instead of&lt;BR /&gt;Iwillallocate()&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Could you please tell me what might I be doing wrong?&lt;BR /&gt;&lt;BR /&gt;Thanks a million&lt;BR /&gt;Regards&lt;/STDIO.H&gt;&lt;/DLFCN.H&gt;&lt;/MACHINE&gt;&lt;/MACHINE&gt;&lt;/DLFCN.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Wed, 04 Nov 2009 10:24:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525441#M651685</guid>
      <dc:creator>Wkdunreal</dc:creator>
      <dc:date>2009-11-04T10:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: An __builtin_return_address problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525442#M651686</link>
      <description>&amp;gt;Could you please tell me what might I be doing wrong?&lt;BR /&gt;&lt;BR /&gt;You are optimizing and that inlines everything:&lt;BR /&gt;$ aCC -AA +DD64 itrc_get_rp.c -g&lt;BR /&gt;$ a.out&lt;BR /&gt;4000000000001290&lt;BR /&gt;_Z13Iwillallocatev: ./a.out&lt;BR /&gt;$ aCC -AA +DD64 itrc_get_rp.c -g +O2 +Oinfo&lt;BR /&gt;procedure func: info #20023-D: Inlined call to Iwillallocate&lt;BR /&gt;procedure main: info #20023-D: Inlined call to func&lt;BR /&gt;$ a.out&lt;BR /&gt;4000000000000e80&lt;BR /&gt;main: ./a.out&lt;BR /&gt;&lt;BR /&gt;&amp;gt;printf("%lx\n", p);&lt;BR /&gt;&lt;BR /&gt;You should use %p for pointers.</description>
      <pubDate>Wed, 04 Nov 2009 10:37:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525442#M651686</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-11-04T10:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: An __builtin_return_address problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525443#M651687</link>
      <description>Thanks for reply Dennis.&lt;BR /&gt;&lt;BR /&gt;Are you creating a .so file (a library which contains mycall() ) or areyou inclusing mycall() in itrc_get_rp.c itself?&lt;BR /&gt;&lt;BR /&gt;Could you show the exact contents of your vitrc_get_rp.c file?&lt;BR /&gt;&lt;BR /&gt;Cause when I do not create an SO and include all the code in one file itself, it seems to give the right answer...&lt;BR /&gt;&lt;BR /&gt;The problem comes when i create a separate library and try to call functions from this library (as I had shown in the code above.. the lib.c is the library file and try.c is the caller file.)&lt;BR /&gt;&lt;BR /&gt;Thanks and regards</description>
      <pubDate>Wed, 04 Nov 2009 11:08:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525443#M651687</guid>
      <dc:creator>Wkdunreal</dc:creator>
      <dc:date>2009-11-04T11:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: An __builtin_return_address problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525444#M651688</link>
      <description>&amp;gt;Are you creating a .so file (a library which contains mycall()) or are you including mycall() in itrc_get_rp.c itself?&lt;BR /&gt;&lt;BR /&gt;The latter, the former is too hard.  ;-)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Could you show the exact contents of your vitrc_get_rp.c file?&lt;BR /&gt;&lt;BR /&gt;All of your source in one file.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;when I do not create an SO and include all the code in one file itself, it seems to give the right answer.&lt;BR /&gt;&lt;BR /&gt;Not when I optimize.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;The problem comes when i create a separate library and try to call functions from this library&lt;BR /&gt;&lt;BR /&gt;That only fails when I optimize the executable.&lt;BR /&gt;You can add +d to stop inlining.</description>
      <pubDate>Wed, 04 Nov 2009 11:50:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525444#M651688</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-11-04T11:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: An __builtin_return_address problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525445#M651689</link>
      <description>:D&lt;BR /&gt;&lt;BR /&gt;I suppose the former is indeed hard, sadly that is the only way I can proceed .... by making a library file....&lt;BR /&gt;&lt;BR /&gt;When using gcc I never had these issues...&lt;BR /&gt;aCC seems a bit grumpy :|:|&lt;BR /&gt;&lt;BR /&gt;I tried using the +d option as you had suggested... removing the inlining optimization... but then again when trying to use the "library creation method and calling the library function in a caller file" the +d gave the same result always pointing to main....&lt;BR /&gt;&lt;BR /&gt;I really wonder what might be causing this problem ... Is it some other optimization that Is doing this... or maybe the way the .so file is made or called?&lt;BR /&gt;&lt;BR /&gt;Very pinching indeed :|&lt;BR /&gt;&lt;BR /&gt;Thanks a lot Dennis :D:D</description>
      <pubDate>Thu, 05 Nov 2009 05:37:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525445#M651689</guid>
      <dc:creator>Wkdunreal</dc:creator>
      <dc:date>2009-11-05T05:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: An __builtin_return_address problem?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525446#M651690</link>
      <description>&amp;gt;by making a library file.&lt;BR /&gt;&lt;BR /&gt;I couldn't duplicate it when I made a shlib.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;When using gcc I never had these issues...&lt;BR /&gt;aCC seems a bit grumpy&lt;BR /&gt;&lt;BR /&gt;This likely nothing to do with aC++ if +d doesn't fix it.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I really wonder what might be causing this problem &lt;BR /&gt;&lt;BR /&gt;You should also use gdb and set a breakpoint where you call _Asm_get_rp and see what it thinks is the caller.&lt;BR /&gt;&lt;BR /&gt;It could be dladdr(3) is broken.</description>
      <pubDate>Thu, 05 Nov 2009 09:33:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/an-builtin-return-address-problem/m-p/4525446#M651690</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-11-05T09:33:24Z</dc:date>
    </item>
  </channel>
</rss>

