Binary compatibility loss regarding errno

H. J. Lu hjl@lucon.org
Mon Dec 30 13:32:00 GMT 2002


On Mon, Dec 30, 2002 at 08:28:37PM +0100, Jakub Jelinek wrote:
> > Do you have a testcase for that?
> 
> Of course:
> 
> cat > lib.c <<EOF
> int y = 12;
> asm (".symver y, x@VERS_1");
> extern int x;
> void foo (void)
> {
>   x = 24;
> }
> EOF
> cat > lib.map <<EOF
> VERS_1 {
>   global: x; foo;
>   local: *;
> };
> EOF
> gcc -shared -O2 -fpic -o lib.so lib.c -Wl,-version-script,lib.map
> 
> This is basically what you tried in your today's errno.c patch.
> The purpose of the code is
> a) to make x unavailable for newly linked programs
> b) for already linked binaries which have R_*_COPY relocs against
>    x@VERS_1, modify the variable in binary's .dynbss, not actually
>    y in the shared library

It works for me. Here is a testcase:

# make
/usr/gcc-3.2/bin/gcc -fPIC -c loser.c
/usr/gcc-3.2/bin/gcc -shared -o loser.so loser.o -Wl,--version-script=loser.v
/usr/gcc-3.2/bin/gcc -o foo loser.so foo.c -Wl,-rpath,.
./foo
12
12
24
20
20
24
/usr/gcc-3.2/bin/gcc -shared -o loser.so loser.c -DNEW -Wl,--version-script=loser.v
./foo
12
12
24
20
20
24
/usr/gcc-3.2/bin/gcc loser.so foo.c -Wl,-rpath,.
/tmp/ccErEs1j.o(.text+0x11): In function `main':
: undefined reference to `x'
/tmp/ccErEs1j.o(.text+0x3b): In function `main':
: undefined reference to `x'
/tmp/ccErEs1j.o(.text+0x51): In function `main':
: undefined reference to `x'
/tmp/ccErEs1j.o(.text+0x5a): In function `main':
: undefined reference to `x'
/tmp/ccErEs1j.o(.text+0x84): In function `main':
: undefined reference to `x'
collect2: ld returned 1 exit status
make: *** [all] Error 1

Did I miss something?


H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: b.tar.gz
Type: application/x-gzip
Size: 594 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20021230/c0c5d9fb/attachment.bin>


More information about the Binutils mailing list