This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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: Symbol versioning problem? Different versions of same symbol being called.


On Thu, Jan 24, 2002 at 09:48:30AM -0800, H . J . Lu wrote:
> I don't like libtool. Any particular version of libtool will have
> different bugs. Anyway, please find out if -lc is used for building
> shared library. When -lc is used, all symbols defined in libc should
> have a version name. Please find out why that symbol doesn't have a
> version name.
> 
> H.J.

I am not an expert in the field of dynamic linking etc,
so allow me to dump a lot of info on you ... hopefully
you can then ask me for more specific things:

I now have a single source file from which the sem_*
functions are called, the source file is called
semwrapper.cc.

1) Compilation semwrapper.cc --> semwrapper.lo
==============================================

# g++-3.0.3 -DHAVE_CONFIG_H -I./include -I./include -DCWDEBUG -ggdb3 -pipe -pthread -Wall -Woverloaded-virtual -Wundef -Wpointer-arith -Wwrite-strings -Werror -Winline -c semwrapper.cc -MT semwrapper.lo -MD -MP -MF .deps/semwrapper.TPlo  -fPIC -DPIC -o semwrapper.o -v -save-temps
g++: Warning: -pipe ignored because -save-temps specified
Reading specs from /usr/local/gcc-3.0.3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/specs
Configured with: /usr/src/gcc/gcc-3.0.3/configure --prefix=/usr/local/gcc-3.0.3 --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ --enable-debug --enable-threads
Thread model: posix
gcc version 3.0.3
 /usr/local/gcc-3.0.3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/cpp0 -lang-c++ -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -I./include -I./include -M -MF semwrapper.d -MF .deps/semwrapper.TPlo -MP -MT semwrapper.lo -MQ semwrapper.o -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=3 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Wall -Woverloaded-virtual -Wundef -Wpointer-arith -Wwrite-strings -Werror -Winline -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ -D__PIC__ -D__pic__ -D_REENTRANT -DHAVE_CONFIG_H -DCWDEBUG -DPIC semwrapper.cc semwrapper.ii
GNU CPP version 3.0.3 (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "/usr/local/gcc-3.0.3/i686-pc-linux-gnu/include"
ignoring duplicate directory "include"
#include "..." search starts here:
#include <...> search starts here:
 include
 /usr/local/gcc-3.0.3/include/g++-v3
 /usr/local/gcc-3.0.3/include/g++-v3/i686-pc-linux-gnu
 /usr/local/gcc-3.0.3/include/g++-v3/backward
 /usr/local/include
 /usr/local/gcc-3.0.3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/include
 /usr/include
End of search list.
 /usr/local/gcc-3.0.3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/cc1plus -fpreprocessed semwrapper.ii -quiet -dumpbase semwrapper.cc -ggdb3 -Wall -Woverloaded-virtual -Wundef -Wpointer-arith -Wwrite-strings -Werror -Winline -version -fPIC -o semwrapper.s
GNU CPP version 3.0.3 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0.3 (i686-pc-linux-gnu)
        compiled by GNU C version 3.0.3.
 as --traditional-format -V -Qy -o semwrapper.o semwrapper.s
GNU assembler version 2.11.92.0.12.3 (i386-redhat-linux) using BFD version 2.11.92.0.12.3 20011121

2) Investigation of semwrapper.o
================================

# readelf --symbols semwrapper.o | grep 'UND'

Symbol table '.symtab' contains 27 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
    15: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND _GLOBAL_OFFSET_TABLE_
    16: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_post
    18: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_init
    20: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_wait
    22: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_trywait
    24: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_getvalue
    26: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_destroy

3) Investigation of semwrapper.s
================================

~/c++/libcw/src/libcwd>grep '[^"0-9_]sem_' semwrapper.s
        call    sem_post@PLT
        call    sem_init@PLT
        call    sem_wait@PLT
        call    sem_trywait@PLT
        call    sem_getvalue@PLT
        call    sem_destroy@PLT

4) Linking semwrapper.o --> libcwd.so.0.99.16 libcwd.so
=======================================================

# mv -f semwrapper.o semwrapper.lo
# gcc-3.0.3 -shared  threading.lo elf32.lo bfd.lo debug.lo debugmalloc.lo demangle.lo demangle3.lo semwrapper.lo strerrno.lo type_info.lo -Wl,--whole-archive utils/.libs/libutils.al -Wl,--no-whole-archive  utils/.libs/libutils.al -ldl   -Wl,-soname -Wl,libcwd.so.0 -o .libs/libcwd.so.0.99.16 -v -save-temps
Reading specs from /usr/local/gcc-3.0.3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/specs
Configured with: /usr/src/gcc/gcc-3.0.3/configure --prefix=/usr/local/gcc-3.0.3 --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ --enable-debug --enable-threads
Thread model: posix
gcc version 3.0.3
 /usr/local/gcc-3.0.3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/collect2 -m elf_i386 -shared -o .libs/libcwd.so.0.99.16 /usr/lib/crti.o /usr/local/gcc-3.0.3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/crtbeginS.o -L/usr/local/gcc-3.0.3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3 -L/usr/local/gcc-3.0.3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/../../.. -rpath /usr/local/gcc-3.0.3/lib: threading.lo elf32.lo bfd.lo debug.lo debugmalloc.lo demangle.lo demangle3.lo semwrapper.lo strerrno.lo type_info.lo --whole-archive utils/.libs/libutils.al --no-whole-archive utils/.libs/libutils.al -ldl -soname libcwd.so.0 -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/gcc-3.0.3/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/crtendS.o /usr/lib/crtn.o

As you see, -lc is present.

5) Investigation of libcwd.so.0.99.16
=====================================

# readelf --symbols .libs/libcwd.so.0.99.16 | grep 'UND' | grep 'sem_'
   562: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_destroy
   629: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_wait
   653: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_post
  1178: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_init
  1439: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_trywait
  2051: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_getvalue
  1366: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_destroy
  1433: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_wait
  1457: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_post
  1982: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_init
  2243: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_trywait
  2854: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND sem_getvalue

6) Investigation of executable that links with libcwd.so.0.99.16
================================================================

# ldd threads4
        libcwd.so.0 => /home/carlo/c++/libcw/src/libcwd/.libs/libcwd.so.0 (0x40017000)
        libdl.so.2 => /lib/libdl.so.2 (0x40105000)
        libstdc++.so.3 => /usr/local/gcc-3.0.3/lib/libstdc++.so.3 (0x40109000)
        libm.so.6 => /lib/libm.so.6 (0x401d3000)
        libgcc_s.so.1 => /usr/local/gcc-3.0.3/lib/libgcc_s.so.1 (0x401f4000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x401fd000)
        libc.so.6 => /lib/libc.so.6 (0x40212000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

Where '/home/carlo/c++/libcw/src/libcwd/.libs/libcwd.so.0' is indeed a
symbolic link to the library that we just compiled.

# readelf --symbols /lib/libpthread.so.0 | grep sem_
    34: 0000a25c    86 FUNC    GLOBAL DEFAULT   12 sem_trywait@@GLIBC_2.1
    46: 00009b3c   541 FUNC    GLOBAL DEFAULT   12 sem_wait@@GLIBC_2.1
    67: 00009ef8   686 FUNC    GLOBAL DEFAULT   12 sem_timedwait@@GLIBC_2.2
    71: 0000a2c8    52 FUNC    GLOBAL DEFAULT   12 sem_destroy@@GLIBC_2.1
    97: 0000a1f8    97 FUNC    GLOBAL DEFAULT   12 sem_init@@GLIBC_2.1
   124: 0000c6b4    85 FUNC    GLOBAL DEFAULT   12 sem_trywait@GLIBC_2.0
   130: 0000a1d0    38 FUNC    GLOBAL DEFAULT   12 sem_unlink@@GLIBC_2.1.1
   135: 0000c47c   473 FUNC    GLOBAL DEFAULT   12 sem_wait@GLIBC_2.0
   171: 0000c658    89 FUNC    GLOBAL DEFAULT   12 sem_init@GLIBC_2.0
   172: 00009d5c   373 FUNC    GLOBAL DEFAULT   12 sem_post@@GLIBC_2.1
   190: 0000a1a8    38 FUNC    GLOBAL DEFAULT   12 sem_close@@GLIBC_2.1.1
   253: 00009ed4    35 FUNC    GLOBAL DEFAULT   12 sem_open@@GLIBC_2.1.1
   278: 0000a2b4    18 FUNC    GLOBAL DEFAULT   12 sem_getvalue@@GLIBC_2.1
   292: 0000c7a8    50 FUNC    GLOBAL DEFAULT   12 sem_destroy@GLIBC_2.0
   300: 0000c784    36 FUNC    GLOBAL DEFAULT   12 sem_getvalue@GLIBC_2.0
   301: 0000c70c   118 FUNC    GLOBAL DEFAULT   12 sem_post@GLIBC_2.0
   117: 0000a2fc   197 FUNC    LOCAL  DEFAULT   12 new_sem_extricate_func
   126: 0000c870    10 FUNC    LOCAL  DEFAULT   12 old_sem_extricate_func
   127: 0000c7dc   146 FUNC    LOCAL  DEFAULT   12 sem_restart_list
   137: 0000c6b4    85 FUNC    LOCAL  DEFAULT   12 __old_sem_trywait
   142: 0000a2c8    52 FUNC    LOCAL  DEFAULT   12 __new_sem_destroy
   147: 0000a1f8    97 FUNC    LOCAL  DEFAULT   12 __new_sem_init
   152: 0000c70c   118 FUNC    LOCAL  DEFAULT   12 __old_sem_post
   160: 00009d5c   373 FUNC    LOCAL  DEFAULT   12 __new_sem_post
   180: 0000c658    89 FUNC    LOCAL  DEFAULT   12 __old_sem_init
   192: 00009b3c   541 FUNC    LOCAL  DEFAULT   12 __new_sem_wait
   197: 0000c784    36 FUNC    LOCAL  DEFAULT   12 __old_sem_getvalue
   212: 0000a25c    86 FUNC    LOCAL  DEFAULT   12 __new_sem_trywait
   218: 0000c47c   473 FUNC    LOCAL  DEFAULT   12 __old_sem_wait
   224: 0000c7a8    50 FUNC    LOCAL  DEFAULT   12 __old_sem_destroy
   233: 0000a2b4    18 FUNC    LOCAL  DEFAULT   12 __new_sem_getvalue
   253: 0000a25c    86 FUNC    GLOBAL DEFAULT   12 sem_trywait@@GLIBC_2.1
   265: 00009b3c   541 FUNC    GLOBAL DEFAULT   12 sem_wait@@GLIBC_2.1
   286: 00009ef8   686 FUNC    GLOBAL DEFAULT   12 sem_timedwait
   290: 0000a2c8    52 FUNC    GLOBAL DEFAULT   12 sem_destroy@@GLIBC_2.1
   316: 0000a1f8    97 FUNC    GLOBAL DEFAULT   12 sem_init@@GLIBC_2.1
   343: 0000c6b4    85 FUNC    GLOBAL DEFAULT   12 sem_trywait@GLIBC_2.0
   349: 0000a1d0    38 FUNC    GLOBAL DEFAULT   12 sem_unlink
   354: 0000c47c   473 FUNC    GLOBAL DEFAULT   12 sem_wait@GLIBC_2.0
   390: 0000c658    89 FUNC    GLOBAL DEFAULT   12 sem_init@GLIBC_2.0
   391: 00009d5c   373 FUNC    GLOBAL DEFAULT   12 sem_post@@GLIBC_2.1
   409: 0000a1a8    38 FUNC    GLOBAL DEFAULT   12 sem_close
   472: 00009ed4    35 FUNC    GLOBAL DEFAULT   12 sem_open
   497: 0000a2b4    18 FUNC    GLOBAL DEFAULT   12 sem_getvalue@@GLIBC_2.1
   511: 0000c7a8    50 FUNC    GLOBAL DEFAULT   12 sem_destroy@GLIBC_2.0
   519: 0000c784    36 FUNC    GLOBAL DEFAULT   12 sem_getvalue@GLIBC_2.0
   520: 0000c70c   118 FUNC    GLOBAL DEFAULT   12 sem_post@GLIBC_2.0

Note the fact that @GLIBC_2.0 corresponds to the LOCAL __old_sem_*
functions and @@GLIBC_2.1 corresponds to the LOCAL __new_sem_*
functions.

7) gdb session
==============

(gdb) info shared
>From        To          Syms Read   Shared Object Library
0x4006d4f0  0x400c6ab0  Yes         /home/carlo/c++/libcw/src/libcwd/.libs/libcwd.so.0
0x401061a0  0x40106e90  Yes         /lib/libdl.so.2
0x401505f0  0x401a2430  Yes         /usr/local/gcc-3.0.3/lib/libstdc++.so.3
0x401d6770  0x401ee320  Yes         /lib/libm.so.6
0x401f5330  0x401f9e30  Yes         /usr/local/gcc-3.0.3/lib/libgcc_s.so.1
0x402013d0  0x40209dac  Yes         /lib/libpthread.so.0
0x4022a310  0x4031b130  Yes         /lib/libc.so.6
0x40001790  0x400120d0  Yes         /lib/ld-linux.so.2
(gdb) b 'libcw::debug::_private_::__libcwd_sem_post_wrapper'
Breakpoint 1 at 0x40090572: file semwrapper.cc, line 28.
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/carlo/c++/libcw/src/libcwd/tests/.libs/./threads4
[New Thread 1024 (LWP 567)]
DEBUGDEBUG: 1024: Calling initialize() instance 3
DEBUGDEBUG: res == 0; &S_no_readers_left = 0x400f6634
DEBUGDEBUG: 1024: &S_no_readers_left 0x400f6634 contains value 1
DEBUGDEBUG: 1024: Leaving initialize() instance 3
DEBUGDEBUG: 1024: Calling rwlock_tct<3>::wrlock()
DEBUGDEBUG: 1024: &S_no_readers_left 0x400f6634 contains value 1
DEBUGDEBUG: 1024: Calling sem_wait...
DEBUGDEBUG: 1024: &S_no_readers_left 0x400f6634 now contains value 0
DEBUGDEBUG: 1024: Leaving rwlock_tct<3>::wrlock()
DEBUGDEBUG: 1024: Calling rwlock_tct<3>::wrunlock()
DEBUGDEBUG: 1024: &S_no_readers_left 0x400f6634 contains value 0
DEBUGDEBUG: 1024: Calling sem_post...
[Switching to Thread 1024 (LWP 567)]

Breakpoint 1, libcw::debug::_private_::__libcwd_sem_post_wrapper(sem_t*) (sem=0x400f6634) at semwrapper.cc:28
28        return sem_post(sem);
(gdb) step
__old_sem_post (sem=0x400f6634) at oldsemaphore.c:174
174         oldstatus = sem->sem_status;
Current language:  auto; currently c
(gdb)

It calls __old_sem_post, which is wrong...


Please let me know if I can provide more info
or do other tests.

-- 
Carlo Wood <carlo@alinoe.com>


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