[speex-dev] Re: does installed lib support _int()s ?

Malcolm Baldridge speex at paypc.com
Tue May 18 04:57:48 PDT 2004



Quoting Segher Boessenkool <segher at kernel.crashing.org>:

> > I wonder if there's a way to "weak-link" against libraries on
> > Linux/GNU-ld-so?  The idea is that a symbol lookup/relocation isn't
> > performed until the call is actually MADE, rather than merely 
> > referenced.
> 
> That's the default behaviour.

No it's not.  The linker/loader (ld.so) expects all of the referenced
symbols to exist in SOME library no matter if they're actually called or not
by the main executable (ELF).  It goes through all of the external symbols
not present in the executable, and tries to find them in the library search
paths.  If it can't find ALL of them, the linker-loader fails to run the
program.

To give one stupid example:

----------- snip -------------
#include <stdio.h>

extern call_non_existent_function(int i, int j, int k);

int main (int argc, **char argv)
{
   if (argc == -1) call_non_existent_function(1,2,3);
   printf("Hello, World\n");
}

With weak-linking, the above program should link *and* run, on any system
whether or not call_non_existent_function() exists on your system.

On some systems (MacOS "Classic" amazingly enough to name one example), this
behaviour can be controlled so that if the executable takes special care, it
can avoid triggering calls to non-existent functions in installed system
libraries, i.e., capabilities detection.

Cheers,

=MB=
--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'speex-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Speex-dev mailing list