Bug 21213
Summary: | shared library globals broken | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | Need Real Name <bfc> |
Component: | binutils | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED DEFERRED | QA Contact: | David Lawrence <dkl> |
Severity: | low | Docs Contact: | |
Priority: | low | ||
Version: | 6.1 | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i686 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2001-01-18 10:53:25 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Need Real Name
2000-11-22 00:47:26 UTC
Perhaps I've alienated the Linux gurus with the uuencoded posting, so here's the simple version, assuming that tmp1.c, tmp2.c, and tmp.h are put into /tmp: ------------- build script ----------- #!/bin/sh cc -fPIC -D_REENTRANT -O1 -g -Wall -c tmp2.c /usr/bin/ld -shared -o libmytmp.so -Bsymbolic tmp2.o cc -fPIC -D_REENTRANT -O1 -g -Wall -c tmp1.c cc -fPIC -D_REENTRANT -O1 -g -Wall -Wl,-rpath-link=/tmp -Wl,-rpath=/tmp -o tmp tmp1.o -L/tmp -lmytmp ----------- tmp1.c --------------------- #include <stdio.h> #include "tmp.h" int main(argc,argv) int argc; char *argv[]; { void sub(); sub(); /*sets foo to 2*/ if (!foo) foo = 1; printf("%d\n",foo); if (foo == 2) { printf("Passed\n"); return(0); } else { printf("FAILED\n"); return(1); } } --------------------- tmp2.c --------------- #define DO_DEFINES #include "tmp.h" void sub(void) { foo = 2; } ------------------- tmp.h ------------------- #ifdef DO_DEFINES int foo; #else extern int foo; #endif IMHO you just should upgrade to ld which works for you. I don't have 6.1 installed anywhere, I've checked 6.2 and this passes there (binutils-2.9.5.0.22-6), so you could e.g. upgrade to that binutils rpm. BTW: You should use cc -shared, not ld directly when linking shared libraries. I agree, we should use 6.2, but it was still under discussion for other reasons. Wanted to make sure I wasn't missing something obvious -- seemed too blatant a bug. You just led me to the answer, though, thanks! Using ld or cc to link, and dumping the -Bsymbolic makes it work. I would have guessed the opposite from the man page, but it should really have NO effect, since I only have a definition within the shared library. I'll mark this as closed. |