Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!orcenl!bengsig From: bengsig@oracle.nl (Bjorn Engsig) Newsgroups: comp.unix.aix Subject: Re: AIX 3.1 ld symbol resolution Message-ID: <1023@nlsun1.oracle.nl> Date: 23 Oct 90 09:34:32 GMT References: <1990Oct18.140050@ead.dsa.com> Reply-To: bengsig@oracle.nl (Bjorn Engsig) Organization: Oracle Europe, The Netherlands Lines: 37 Article <1990Oct18.140050@ead.dsa.com> by schorr@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@oracle.com, bengsig@oracle.nl ORACLE Corporation From IBM: auschs!ibmaus!cs.utexas.edu!uunet!oracle!bengsig "Stepping in others footsteps, doesn't bring you ahead"