[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ldd, shared libs, overriding functions, and undefined symbols
From: |
Duane Ellis |
Subject: |
ldd, shared libs, overriding functions, and undefined symbols |
Date: |
Tue, 11 Mar 2003 19:41:07 -0500 |
Short question:
How do I get a shared library to resolve to symbols - that are
defined in the application at run time - that did not need to
resolve at link time and visa-versa.
This works under SunOS 4.1.3 - but not under Linux.
It does not work under RH Linux 7.3 intel using the
default compiler linker and libraries.
* I have duplicated this problem with a couple of trivial files - see
below for an explination.
* If somebody would like a more complete example I can forward a small
makefile and short c files that demonstrate the problem.
-Duane.
I have a simple program - the main application it includes a call back
that the shared library *MIGHT* but not always need.
>> ----- main.c
>> #include <stdio.h>
>> int
>> main( int argc, char **argv )
>> {
>> custom_lib_init();
>> printf("This is my program\n");
>> }
>>
>> void
>> some_call_back_function( void )
>> {
>> printf("The library called the call back\n");
>> }
>> ----
I create a STUB library - that is used to link against for normal
operation of the program.
>> ---- sublib.c
>> #include <stdio.h>
>>
>> void
>> custom_lib_init(void)
>> {
>> printf("This is a stub - nothing to do\n");
>> /* Stubs don't use the call back function */
>> }
>> ----
When I normally build the application - I link against the STUB shared
library. Everything works.
NOW - I build a full-featured shared library that does something more
in this example - i just call the call back function.
>> ---- fulllib.c
>> #include <stdio.h>
>>
>> void
>> custom_lib_init(void)
>> {
>> printf("This is *NOT* the stub, call the callback. \n");
>> some_call_back_function();
>> }
>> ----
OPTION 0:
LINK with the stub library
RUN with the stub library.
-- It works.
OPTION 1:
LINK with the full library.
RUN with the full library.
-- It works.
OPTION 2:
LINK with the stub library
RUN with the full library.
or
OPTION 3:
LINK with the full library
RUN with the stub library.
Both *FAIL* and this is my problem.
I get a message like this:
>> ./test_prog: relocation error: ./libQA.so.1.0: undefined symbol:
>> some_call_back_function
I am not expecting this.
The main program only requires the "custom_lib_init()" function in the
library - it is defined at run time and already exists.
ld.so should be able to resolve the call back to the main application.
but for some reason it cannot.
I have tried things like LD_PRELOAD and LD_LIBRARY_PATH from
the ld.so man page and I'm getting no where.
I can also duplicate the problem with 'ldd -r test_prog'
in the same manner as running the program.
Again - this basic functionality works under SunOS 4.1 - using gcc and
the standard sun linker.
I'm at a loss to figure out what I have to do here.
Switching to a 100% dlopen(), dlsym(), dlclose() method - where I look
up the symbols is very *NON* trivial - I need access to hundreds of
functions and variables.
Any suggestions or pointers would be very helpful.
-Duane.
- ldd, shared libs, overriding functions, and undefined symbols,
Duane Ellis <=