Operating System - Linux
1748151 Members
3423 Online
108758 Solutions
New Discussion юеВ

Re: Wondering how to create linker map ?

 
kraft
Occasional Contributor

Wondering how to create linker map ?

I am on hp-ux itanium the compiler and linker I am using is aCC, tried -m option, but still can get it work. Anything I am overlooked? Thanks!
10 REPLIES 10
A. Clay Stephenson
Acclaimed Contributor

Re: Wondering how to create linker map ?

You have to tell the compiler to send the -m option to the linker phase of the operation. Something like this:

aCC -Wl,-m myfile.c

This will output a map on stdout.
If it ain't broke, I can fix that.
kraft
Occasional Contributor

Re: Wondering how to create linker map ?

Thanks! This works. One more question, how to display the library ( eg .o, .so) that my program linked with ?
A. Clay Stephenson
Acclaimed Contributor

Re: Wondering how to create linker map ?

ldd myprogram. ldd -> list dynamic dependencies. Man ldd for details.
If it ain't broke, I can fix that.
Peter Nikitka
Honored Contributor

Re: Wondering how to create linker map ?

Hi,

call
chatr yourlinkedobject

that will tell used runtime libraries (and more).

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
kraft
Occasional Contributor

Re: Wondering how to create linker map ?

Thank you every one. Bear with me I am quite new in hp-ux. One more question what's the different between .o and .so. Is .so like dll on windows?
A. Clay Stephenson
Acclaimed Contributor

Re: Wondering how to create linker map ?

Well, it would be more accurate to say that .DLL's are like .so's since UNIX had them before there was even a Windows but .so are shared objects. Essentially that means that you have to turn on some compiler options to make the code relocatable. In HP-UX, .so's are more often .sl's but it's the same thing. You need to become familiar with two commands: nm and file. For example, file myfile.so will tell you what kind of file myfile.so is. nm will dump the symbol table of an object file, library, or executable. Man file and nm for details.
If it ain't broke, I can fix that.
kraft
Occasional Contributor

Re: Wondering how to create linker map ?

Again, Thank you for your help
Dennis Handly
Acclaimed Contributor

Re: Wondering how to create linker map?

Why would you want to use -m?

You can get this info from elfdump(1):
$ elfdump -S -h a.out

You can use aCC +help or the following for aC++ help:
http://docs.hp.com/en/8759/index.htm

If you want to display the objects/libs you are linked with: -Wl,-t

>Clay: Essentially that means that you have to turn on some compiler options to make the code relocatable. In HP-UX, .so's are more often .sl's

The default on IPF is PIC, so no options are needed. Also on IPF, you should name your shlibs as .so, not the the PA convention of .sl.

>nm will dump the symbol table of an object file, library, or executable.

elfdump -t is the correct tool to work on shlibs and executables, if you are using tricky linker options:
$ elfdump -s -n .dynsym a.out

kraft
Occasional Contributor

Re: Wondering how to create linker map ?

Dennis, these works as well. Thanks!

Rather starting a new thread, I would like ask here, this is regarding stack trace. I know there are a macro we can use U_STACK_TRACE, just wondering if there are any other ways ? I have a program which crashed very strangely. I don't know the signal would be when it crashes. I tried SIGQUIT, but it wasn't. What I would like to do is whenever it crashes, it creates a stack trace. Any suggestions ?