This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Support Sun symbol versioning in libstdc++-v3


On Wed, Feb 24, 2010 at 03:51:39PM +0100, Rainer Orth wrote:
>   So here's the experiment:
> 
> $ cat libfunc.c
> #include <stdio.h>
> 
> void
> func_10 (void)
> {
>   printf ("FUNC_1.0\n");
> }
> 
> void
> func_20 (void)
> {
>   printf ("FUNC_2.0\n");
> }
> 
> __asm__ (".symver func_10, func@FUNC_1.0");
> __asm__ (".symver func_20, func@@FUNC_2.0");
> $ cat libfunc.ver
> FUNC_1.0 {
>   global:
>     func;
>   local:
>     *;
> };
> 
> FUNC_2.0 {
>   global:
>     func;
>   local:
>     *;
> } FUNC_1.0;
> # This is a gcc built with both gas and gld
> $ gcc -shared -static-libgcc -Wl,--version-script,libfunc.ver -h libfunc.so.1 -o libfunc.so.1 libfunc.c
> $ pvs -dsv libfunc.so.1
>         libfunc.so.1 [BASE]:
>         FUNC_1.0:
>                 FUNC_1.0;
>         FUNC_2.0:               {FUNC_1.0}:
>                 func;
>                 FUNC_2.0;
> # As you can see, func is *not* present in FUNC_1.0, although it should.

The problem is that you used a Sun tool in the experiment, and that tool
clearly has no clue about GNU symbol versioning.  You should have used readelf or objdump
instead.  Doing the same (with s/-h /,-Wl,-soname,/) on Linux followed by:
readelf -Wa libfunc.so.1 | grep func
 0x000000000000000e (SONAME)             Library soname: [libfunc.so.1]
     7: 000000000000059e    18 FUNC    GLOBAL DEFAULT   12 func@@FUNC_2.0
     9: 000000000000058c    18 FUNC    GLOBAL DEFAULT   12 func@FUNC_1.0
    40: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS libfunc.c
    41: 000000000000059e    18 FUNC    LOCAL  DEFAULT   12 func_20
    44: 000000000000058c    18 FUNC    LOCAL  DEFAULT   12 func_10
    57: 000000000000059e    18 FUNC    GLOBAL DEFAULT   12 func@@FUNC_2.0
    59: 000000000000058c    18 FUNC    GLOBAL DEFAULT   12 func@FUNC_1.0
  000000: Rev: 1  Flags: BASE   Index: 1  Cnt: 1  Name: libfunc.so.1
shows that both func@FUNC_1.0 and func@@FUNC_2.0 are present.  func@FUNC_1.0
is a non-default symbol version, so new libraries/programs linking against this
library will always pick func@@FUNC_2.0, but libraries/programs already
linked against older version of the library which just had func@@FUNC_1.0
will continue to work.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]