- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- An __builtin_return_address problem?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2009 11:32 PM
тАО11-01-2009 11:32 PM
Am using the native compiler (aCC) to compile.
In my source code at one instance , there is a need for __builtin_return_address to give me the return address of the function.
Using gcc it gets compiled but using aCC I seem to be having a lil bit of problem.
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.
__builtin_return_address(LEVEL)
if i pass LEVEL=1 i get the address of a function a step higher in the stack .
Am using the HP-US 11.31 ia64.
Thanks in advance to all the Stalwarts of this community :)
Regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2009 12:07 AM
тАО11-02-2009 12:07 AM
SolutionGo through the aC++ documentation:
http://www.hp.com/go/cpp
Inline assembly for Itanium-based HP-UX
http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=4308e2f5bde02110e2f5bde02110275d6e10RCRD
Table 1-7 Miscellaneous Opcodes
Table 1-40 Miscellaneous Opcodes
#include
_Asm_get_rp(void);
>if I pass LEVEL=1 I get the address of a function a step higher in the stack.
Chances are, not even GNU can do any levels higher than 0, except for every simple architectures, like HP 3000.
You'll need to use libunwind to get higher than 0. Your previous thread:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1369744
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2009 01:17 AM
тАО11-02-2009 01:17 AM
Re: An __builtin_return_address problem?
Thanks Dennis :D Thanks a million
The _Asm_get_rp(void); worked.
As soon as I run into other dead ends here will get back here :D.
Thanks again :):):)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2009 02:24 AM
тАО11-04-2009 02:24 AM
Re: An __builtin_return_address problem?
I seem to have bumped into a problem using _Asm_get_rp().
I created a test shared object file lib.so
#include
#include
#include
void mycall()
{
void *p=_Asm_get_rp();
printf("%lx\n",p);
Dl_info info;
dladdr(p,&info);
printf("%s : %s\n",info.dli_sname,info.dli_fname);
}
And i created a try.c that would use this lib.so
#include
#include
#include
void Iwillallocate();
void func();
main()
{
func();
}
void func(){
Iwillallocate();
}
void Iwillallocate(){
mycall();
}
--------------------------------------------
I am compiling this using aCC
Created .so using aCC and all object files.
Te problem that i am facing is...
The return function name is coming out as
main()
instead of
Iwillallocate()
Could you please tell me what might I be doing wrong?
Thanks a million
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2009 02:37 AM
тАО11-04-2009 02:37 AM
Re: An __builtin_return_address problem?
You are optimizing and that inlines everything:
$ aCC -AA +DD64 itrc_get_rp.c -g
$ a.out
4000000000001290
_Z13Iwillallocatev: ./a.out
$ aCC -AA +DD64 itrc_get_rp.c -g +O2 +Oinfo
procedure func: info #20023-D: Inlined call to Iwillallocate
procedure main: info #20023-D: Inlined call to func
$ a.out
4000000000000e80
main: ./a.out
>printf("%lx\n", p);
You should use %p for pointers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2009 03:08 AM
тАО11-04-2009 03:08 AM
Re: An __builtin_return_address problem?
Are you creating a .so file (a library which contains mycall() ) or areyou inclusing mycall() in itrc_get_rp.c itself?
Could you show the exact contents of your vitrc_get_rp.c file?
Cause when I do not create an SO and include all the code in one file itself, it seems to give the right answer...
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.)
Thanks and regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2009 03:50 AM
тАО11-04-2009 03:50 AM
Re: An __builtin_return_address problem?
The latter, the former is too hard. ;-)
>Could you show the exact contents of your vitrc_get_rp.c file?
All of your source in one file.
>when I do not create an SO and include all the code in one file itself, it seems to give the right answer.
Not when I optimize.
>The problem comes when i create a separate library and try to call functions from this library
That only fails when I optimize the executable.
You can add +d to stop inlining.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2009 09:37 PM
тАО11-04-2009 09:37 PM
Re: An __builtin_return_address problem?
I suppose the former is indeed hard, sadly that is the only way I can proceed .... by making a library file....
When using gcc I never had these issues...
aCC seems a bit grumpy :|:|
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....
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?
Very pinching indeed :|
Thanks a lot Dennis :D:D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2009 01:33 AM
тАО11-05-2009 01:33 AM
Re: An __builtin_return_address problem?
I couldn't duplicate it when I made a shlib.
>When using gcc I never had these issues...
aCC seems a bit grumpy
This likely nothing to do with aC++ if +d doesn't fix it.
>I really wonder what might be causing this problem
You should also use gdb and set a breakpoint where you call _Asm_get_rp and see what it thinks is the caller.
It could be dladdr(3) is broken.