AIX 3.1 ld symbol resolution

Bjorn Engsig bengsig at oracle.nl
Tue Oct 23 19:34:32 AEST 1990


Article <1990Oct18.140050 at ead.dsa.com> by schorr at ead.dsa.com (Andrew J. Schorr) says:
|According to the man page for ld,
|
|      In this version of ld, the first definition of each symbol in
|  the link always takes precedence and is  used  even  if the first
|  reference follows the definition.
|
|  For some
|applications, I want to substitute my own version of printf for the
|one in libc.a.
It has always been a bad habit to define your own version of a standard
function - I would recommend using a routine my_printf, of which you have
tow versions, one calling printf and one doing it your way.
|I think I understand why this happens: the printf in the shared
|library is resolved when the shared library is linked, not when
|the application program is linked.  
Yes, printf is part of the big shared object in libc.a.  There is no way
to omit parts of this of course.  See what ar tv libc.a gives you.
|If not, will it be fixed?
I don't think there is anything to fix.  The C compiler plus environments like
ld, work exactly like ANSI says it should.

Andrew also said:
|N.B. It seems tempting to leave out the SHDEPLIBS and use the -r flag
|     in step 2.  This will appear to work, but will give you an error
|     at run-time.
So true, this is almost something that should be put in a FAQ list, so to
rephrase:

   Shared objects (in shared archives or not) MUST be fully linked, i.e.
   no unresolved references are allowed in shared objects.

-- 
Bjorn Engsig,         E-mail: bengsig at oracle.com, bengsig at oracle.nl
ORACLE Corporation    From IBM: auschs!ibmaus!cs.utexas.edu!uunet!oracle!bengsig

            "Stepping in others footsteps, doesn't bring you ahead"



More information about the Comp.unix.aix mailing list