This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Linux/Alpha BUG: probs with resolving functions in shared library
- To: egcs-bugs at cygnus dot com
- Subject: Linux/Alpha BUG: probs with resolving functions in shared library
- From: Eric Ding <ericding at applix dot com>
- Date: Wed, 05 Aug 1998 16:39:19 -0400
Hi,
I've looked over the Linux-Alpha FAQ; this question is not the same as
the gdb issue with dynamic functions. I'm running on a RedHat 5.1
system with egcs 1.0.3a. Summary: the linker seems to be improperly
resolving global function references within a shared library.
I have three files: test.c, test2.c, test3.c, as included below. I
compile test.c into an executable which loads libtest2.so, a shared
library created with test2.o and test3.o. In test.c, I call a function
in test2.c which calls testme(), a function defined in both the
executable and in the shared library.
Note that I do link the shared library with the -Bsymbolic flag, so I
expect testme() to be resolved to the shared library's version.
1) On Linux/Intel, this produces expected results: a message "hello
there from test2". On Linux/Alpha, I get a segmentation fault when
testme() is called from within test2().
2) If I combine the contents of test2.c and test3.c and link the
resulting object file into a shared library, then I get the expected
message rather than a segmentation fault.
While #2 is an acceptable workaround in my test case, it indicates to me
that there's a significant linker (?) bug that I can't work around in the
case of the software I'm actually porting (Applixware). Any thoughts?
Am I doing something wrong?
Thanks,
Eric
BTW, here's my compile and link commmands:
gcc -g -c -fPIC test2.c
gcc -g -c -fPIC test3.c
gcc -shared -Xlinker -Bsymbolic -Xlinker --noinhibit-exec -o libtest2.so \
test2.o test3.o
gcc -g -c test.c
gcc -o test test.o -ldl
And here's the test case source code:
/* ---- clip here ---- */
/* beginning of test.c */
#include <stdio.h>
#include <dlfcn.h>
void testme();
int main(int argc, char **argv) {
void *handle;
void* (*test2)();
handle = dlopen("./libtest2.so", RTLD_NOW);
test2 = dlsym(handle, "test2");
(*test2)();
dlclose(handle);
return(0);
}
void testme() {
fprintf(stderr, "OOPS! called testme() from test.c\n");
}
/* end of test.c */
/* ---- clip here ---- */
/* beginning of test2.c */
extern void testme();
void test2() {
testme();
}
/* end of test2.c */
/* ---- clip here ---- */
/* beginning of test3.c */
#include <stdio.h>
void testme() {
printf("hello there from test2\n");
}
/* end of test3.c */
Subject:
--------