Re: dladdr returning _DYNAMIC as function name! (200 Views)
Reply
Advisor
Wkdunreal
Posts: 25
Registered: ‎09-08-2009
Message 1 of 4 (200 Views)
Accepted Solution

dladdr returning _DYNAMIC as function name!

[ Edited ]

Hello :)

I have been using dladdr() for converting code address into symbolic address. I get function name to the corresponding address.

I have a caller function call.c in which I have defined some functions like
" Iwillallocate() "

which call malloc() etc.

Now i creased an external.so which has a function

void call()

which calls malloc too.

Now when i link this .so with the exe file for call.c ,the dladdr function successfully returns me the fucntion names of the functions in call.c but it returns _DYNAMIC for the fucntion in external.so and does not return the function name call().

when I use nm command n search the symbol table I get:

4: 60000000c0a1b790 : call() + 0x190 (./external.so)
5: 0000000004000bc0 : _Z13Iwillallocatev() + 0x20 (./test)
6: 0000000004000b10 : main() + 0x60 (./test)
7: 60000000c004ddb0 : main_opd_entry() + 0x50 (/usr/lib/hpux32/dld.so)

Ass you can see it gives 60000000c0a1b790 address for call() in external.so 0000000004000bc0 address for Iwillallocate() in ./test (which is my exe file i created)

The address for call() is too high in value.. and hence we get _DYNAMIC as a result when i pass this address in dladdr() and not call() :(.

Now 2 questions:

Q1) Is there any other fucntion other than dladdr which would serve my purpose?

Q2)Are there any switches to be used while making .so or .o or the exe file test which need to be used so that this _DYNAMIC error does not come and I get the correct function names present in external.so .

Thank you experts very much in advance.
Regards

 

 

P.S. This thread has been moved from HP-UX > General to HP-UX > Languages and Scripting - HP Forums Moderator

Advisor
Wkdunreal
Posts: 25
Registered: ‎09-08-2009
Message 2 of 4 (200 Views)

Re: dladdr returning _DYNAMIC as function name!

4: 60000000c0a1b790 : call() + 0x190 (./external.so)
5: 0000000004000bc0 : _Z13Iwillallocatev() + 0x20 (./test)
6: 0000000004000b10 : main() + 0x60 (./test)
7: 60000000c004ddb0 : main_opd_entry() + 0x50 (/usr/lib/hpux32/dld.so)

Is the result of PSTACK not NM sorry :D:D!

Regards
Acclaimed Contributor
Dennis Handly
Posts: 25,274
Registered: ‎03-06-2006
Message 3 of 4 (200 Views)

Re: dladdr returning _DYNAMIC as function name!

>I have been using dladdr() for converting code address into symbolic address.

In general this won't work. It doesn't handle hidden nor static functions. And for PA, it doesn't handle stubs.

>Q1) Is there any other function other than dladdr which would serve my purpose?

Try looking at the Unwind lib: unwind(5)

>Q2) Are there any switches to be used while making .so or .o or the exe file ...

By default they should be there unless you use tricky compiler/linker options or the function is static.

>Is the result of PSTACK not NM

U_STACK_TRACE(3) should also work.
Advisor
Wkdunreal
Posts: 25
Registered: ‎09-08-2009
Message 4 of 4 (200 Views)

Re: dladdr returning _DYNAMIC as function name!


Thanks Dennis :)

That helped a lot :)
I managed to find one more function which works similar to dladdr()

uwx_get_sym_info()

This gave me the desired result.

Regards :)
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.