[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
two instances of global from shared lib linked with -Bsymbolic
From: |
Rafal Dabrowa |
Subject: |
two instances of global from shared lib linked with -Bsymbolic |
Date: |
Tue, 6 Apr 2004 11:20:34 +0200 |
User-agent: |
KMail/1.6.1 |
Earlier I have sent the bug to sources.redhat.com (bug #105), but
I see that it is probably a linker bug. Namely:
I have created a global (integer) variable in shared library.
The library is linked with -Bsymbolic option. Main program
sees this variable as a separate copy: any changes of this
variable aren't seen in library and vice versa.
How to repeat: see code below.
file: mylib.c
int MyGlob; /* variable with two instances at runtime */
void libf() { printf("libf: &MyGlob = %p\n", &MyGlob); }
file: ts.c
extern int MyGlob; /* extern only ! Defined in libmy.a */
int main() {
printf("main: &MyGlob = %p\n", &MyGlob);
libf();
}
Makefile:
ts: libmy.a ts.o
gcc ts.o -o ts -L. -lmy
libmy.a: mylib.o
gcc -o libmy.a -shared -Wl,-Bsymbolic mylib.o
.c.o:
gcc -g -c $<
After compile and run I see:
main: &MyGlob = 0x8049714
libf: &MyGlob = 0x4001a8e8
The variable has really two different instances, as I have mentioned
above.
When I use readelf program to read ts program symbol table, I see:
3: 080483d0 29 FUNC GLOBAL DEFAULT UND libf
....
6: 0804970c 4 OBJECT GLOBAL DEFAULT 22 MyGlob
A "libf" symbol is undefined, but "MyGlob" symbol *is* defined. Is this
correct ?
Rafal
- two instances of global from shared lib linked with -Bsymbolic,
Rafal Dabrowa <=
- Re: two instances of global from shared lib linked with -Bsymbolic, Ian Lance Taylor, 2004/04/06
- Re: two instances of global from shared lib linked with -Bsymbolic, Rafal Dabrowa, 2004/04/06
- Re: two instances of global from shared lib linked with -Bsymbolic, Ian Lance Taylor, 2004/04/06
- Re: two instances of global from shared lib linked with -Bsymbolic, Rafal Dabrowa, 2004/04/06
- Re: two instances of global from shared lib linked with -Bsymbolic, Ian Lance Taylor, 2004/04/06
- Re: two instances of global from shared lib linked with -Bsymbolic, Alan Modra, 2004/04/06
- Re: two instances of global from shared lib linked with -Bsymbolic, Ian Lance Taylor, 2004/04/06
- Re: two instances of global from shared lib linked with -Bsymbolic, Alan Modra, 2004/04/06
- Re: two instances of global from shared lib linked with -Bsymbolic, Rafal Dabrowa, 2004/04/07
- Re: two instances of global from shared lib linked with -Bsymbolic, Alan Modra, 2004/04/07