From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 18514 invoked from network); 5 Aug 1998 16:33:43 -0000 Received: from relay5.uu.net (192.48.96.15) by mail2.redhat.com with SMTP; 5 Aug 1998 16:33:43 -0000 Received: from uucp1.uu.net by relay5.UU.NET with SMTP (peer crosschecked as: uucp1.uu.net [192.48.96.81]) id QQfbdi29804; Wed, 5 Aug 1998 12:33:41 -0400 (EDT) Received: from applix.UUCP by uucp1.uu.net with UUCP/RMAIL ; Wed, 5 Aug 1998 12:33:42 -0400 Received: from tuxedo by applix.com (4.1/SMI-4.1.3JJM) id AA25732; Wed, 5 Aug 98 12:17:01 EDT Received: from tuxedo (ericding@localhost [127.0.0.1]) by tuxedo (8.8.7/8.8.7) with ESMTP id MAA23543 for ; Wed, 5 Aug 1998 12:16:58 -0400 Message-Id: <199808051616.MAA23543@tuxedo> X-Face: Z~3)^x:wz~+J\.2@_+t*U3Gy|[!M`)vi:fn(o2o15zG?T-uy0KT>&T%40fcFqQ>P:#vJ[Ay=wJ53@{c6^)\6CC-Z]LN,`.F2KI)j3}7 To: axp-list@redhat.com Subject: BUG: probs with resolving functions in shared library X-Mailer: MH [Version nmh-0.24]; mh-e [Emacs version 20.2] X-Emacs: Emacs 20.2 (with raw setting) Mime-Version: 1.0 (generated by SEMI 1.8.4 - "Takaoka") Content-Type: text/plain; charset=US-ASCII Date: Wed, 05 Aug 1998 12:16:57 -0400 From: Eric Ding 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 and the latest binutils-2.9.1.0.4 RPM update. 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 #include 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 void testme() { printf("hello there from test2\n"); } /* end of test3.c */