deferred library call resolution

deferred library call resolution

Post by Ye L » Sun, 14 Oct 2001 16:22:29



Greets,

I have a question on deferred resolution of library calls. My
application is linked by "-brtl" option.

When the loader resolve the library call, i.e., a C run time library
call malloc(),
how does it do it? My understanding is that the loader saerch each
directory in
$LIBPATH and in each directory, it search each library's exported
table by order
to load the first match. If in /lib, there are two C run time
libraries:  libA and libB,
the loader will always load libA.

Is there a way in linking, I put some information in the executable to
guide load,
"Hey, I only use libB for all C run time lirary calls".

I hitted a problem that my application is not running correctly in a
box having the
same hardware and OS maintenance level as mine, where it runs
perfectly. The
only thing I know is that it has two C run time: one from OS and one
from C/C++
5.0. It is a customer remote box and I have not checked its
environment yet.

The following is the output of dump -Hv of the application:

aaa
                        ***Loader Section***
                      Loader Header Information
VERSION#         #SYMtableENT     #RELOCent        LENidSTR
0x00000001       0x000002b8       0x00006ed1       0x000002a6

#IMPfilID        OFFidSTR         LENstrTBL        OFFstrTBL
0x00000013       0x0005732c       0x00004a4e       0x000575d2

                        ***Import File Strings***
INDEX  PATH                          BASE                MEMBER
0      .:S:rs_43_xlrc:rs_43_xlrc/S:/tsi/ae/tools/rv/6.6/pro/aix43/power/lib:/tsi
/ae/tools/SDK/3.2.4/rs_43_xlrc/lib:/tsi/ae/tools/rogue/1.2.4/rs_43/workspaces/RS
6000/POWER/12d/lib:/tsi/ae/tools/odbc/3.70/rs_43_xlrc/lib:/tsi/build/workspace/s
uren/Activedb/Activedb-dev330/export/rs_43_xlrc_Release/lib:/usr/lib/threads:/us
r/ibmcxx/lib:/usr/lib:/lib
1                                    libC.a              shr.o
2                                    libC.a              shr2.o
3                                    libtls12d.a         shr.o
4                                    libthr12d.a         shr.o
5                                    libstd12d.a         shr.o
6                                    libmaverick32_shr.a
7                                    librepo32_shr.a
8                                    libTibUtil32_shr.a
9                                    libtibrvcm.so
10                                   libtibrv.so
11                                   libtibrvcmq.so
12                                   libtibrvft.so
13                                   libodbc.a           odbc.so
14                                   libadbaltermsg_shr.a
15                                   libpthreads.a       shr_comm.o
16                                   libpthreads.a       shr_xpg5.o
17                                   libc_r.a            shr.o
18                                   librtl.a            shr.o

If I don't link /usr/ibmcxx/lib, can it solve the problem?

Regards

--ye

 
 
 

deferred library call resolution

Post by Gary R. Hoo » Fri, 19 Oct 2001 01:13:05



> I have a question on deferred resolution of library calls. My
> application is linked by "-brtl" option.

> When the loader resolve the library call, i.e., a C run time library
> call malloc(),
> how does it do it? My understanding is that the loader saerch each
> directory in
> $LIBPATH and in each directory, it search each library's exported
> table by order
> to load the first match. If in /lib, there are two C run time
> libraries:  libA and libB,
> the loader will always load libA.

Use dump -HTv on a module to see where an import comes from.  The
default behavior is that symbol resolution is defined at link time.
The referenced module must be found in the LIBPATH.  Note that only
one file of any given name can exist in a specific directory, unless
I misunderstand your last sentence above.

In RTL (when the main application is linked with the -brtl option,
symbol resolution is also reevaluated at exec time.  Based upon the
order of the modules specified in the loader header of the main
application, the RTL library will search for a definition of each
imported symbol.  If a new definition of a symbol is found, references
to that symbol are redirected to the first one found.

Quote:> Is there a way in linking, I put some information in the executable to
> guide load,
> "Hey, I only use libB for all C run time lirary calls".

Every application is going to use the C runtime library libc.a(shr.o).
You can't avoid this, as the system layer API is at libc, not the
kernel.

Quote:> I hitted a problem that my application is not running correctly in a
> box having the
> same hardware and OS maintenance level as mine, where it runs
> perfectly. The
> only thing I know is that it has two C run time: one from OS and one
> from C/C++
> 5.0. It is a customer remote box and I have not checked its
> environment yet.

You should do so.  The most obvious thing to look at is their
level of xlC.rte.  You should both be using the latest level,
which is 5.0.2.0 or greater.  The C++ runtime is not part of
the base operating system, so AIX MLs have no affect upon it.
It is updated separately.

--
Gary R. Hook / AIX PartnerWorld for Developers / These opinions are MINE
________________________________________________________________________

 
 
 

1. How to defer the loading of shared libraries?

Assume I compile and link for a C++ program as follows:
$CC myFile.C -L/dir1/dir2 -lsharedLib1 -lsharedLib2

An executable called 'a.out' is produced now.

If I execute a.out now, it tries to load the shared libraries,
libsharedLib1.so and libsharedLib2.so, at the start-up. I suppose this
is the default behaviour that exists.

But, what I would like to do is:
 - To disable the loading of libsharedLib2.so, at the start-up
 - To dynamically load libsharedLib2.so, at a later stage during
runtime(i.e.only in specific conditions)

Is there a possibility to do it? How exactly this can be done?

2. Help - Xconfigurator not configurating

3. System Call, Library Call and Process Size

4. kernel c programming

5. How does Linux implement the time calls and what's the resolution?

6. Sound Woes

7. Dynamic Library resolution for binary distributions

8. VNC takes a hit running KDE

9. Symbol resolution when using shared libraries

10. What library for host name resolution?

11. name resolution in shared libraries?

12. libraries libraries libraries

13. getdomainname library call in solaris 2.4