Originally posted by Gary R. Hook
> > find out in an object file if a system call is run-time linking
> or static?
> Huh? What, exactly, do you mean?
I think I understand what you mean, and the way you find out if a symbol
is linked to a library is to use the "dump" command. I find this
dump -Hov executable_name
The output will show you the built-in libpath for the executable, the
libraries referenced, and each externally defined symbol will show you
the library linked to.
If a symbol you discover in the "nm" output is missing from the dump
command output, it means the library containing the symbol was
Some terminology adjustment is necessary for AIX:
- Most system libraries (libc.a) are shared libraries; one copy of the
programs exist in memory; the data segment used by shared libraries
is unique to the process.
- "run time linking" is a separate beast, and is activated by the
compiler/linker flag: -brtl
Hint: If you don't know why you need runtime linking, you do not need
it! It has very specialized use, in my experience.
- Dynamic Link Libraries (foo.so)
The suffix ".so" is just a convention; you could name it anything,
and pass the name to dlopen() call to get the library loaded.
".so" libraries are also shared libraries in the same sense that the
".a" libraries described above are.
Code in ".so" libraries can be dynamically loaded ... it can also be
"bound" to the executable in exactly the same way that ".a" shared
But ... there is a trick, and it took me a long time to find it.
The compiler/loader will not look for ".so" libraries to resolve
symbols, UNLESS you say the magic combination of linker flags, which is:
xlc_r -qbrtl -bnortllib -lfoo -o mymod xxx.c
With that combination, you are telling the loader:
a) That you want to find either "libfoo.a" or "libfoo.so"
b) That you do NOT want run-time linking
(You still don't know why you need it, right? Ask Gary.)
Posted via http://www.veryComputer.com/