This is the mail archive of the libc-help@sourceware.org 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: Local binding for new files in nptl


Hi,

Global symbol in GLIBC are exported through a linker script definition
created from 'Version' file.  The files define which symbols binding
to which version will be exported.  The NPTL case for instance:

libc {
  GLIBC_2.0 {
    pthread_attr_destroy; pthread_attr_init;
    pthread_attr_getdetachstate; pthread_attr_setdetachstate;
    pthread_attr_getinheritsched; pthread_attr_setinheritsched;
    pthread_attr_getschedparam; pthread_attr_setschedparam;
    pthread_attr_getschedpolicy;  pthread_attr_setschedpolicy;
    pthread_attr_getscope; pthread_attr_setscope;
    pthread_condattr_destroy; pthread_condattr_init;
    pthread_cond_broadcast; pthread_cond_destroy;
    pthread_cond_init; pthread_cond_signal; pthread_cond_wait;
    pthread_cond_timedwait;
    pthread_equal; pthread_exit;
    pthread_getschedparam; pthread_setschedparam;
    pthread_mutex_destroy; pthread_mutex_init;
    pthread_mutex_lock; pthread_mutex_unlock;
    pthread_self;
    pthread_setcancelstate; pthread_setcanceltype;
  }

states that the symbol 'pthread_attr_destroy' will be exported by libc.so
with binding version of GLIBC_2.0.  A readelf command, for instance, will
show:

$ readelf -s /lib/x86_64-linux-gnu/libc.so.6| grep pthread_attr_destroy
  1891: 0000000000107b80    38 FUNC    GLOBAL DEFAULT   12 pthread_attr_destroy@@GLIBC_2.2.5

The GLIBC_2.0 itself is a macro that might be redefined depending of the
architecture.  So for your case, it will require to add the C11 thread
symbol in current libpthread version. 


On 13-04-2015 13:34, Juan Manuel Torres Palma wrote:
> Hello there!
>
> I'm trying to add some functions (C11 threads) to the nptl folder,
> being able to compile it, and see the code of the functions with
> objdump, read the symbols with nm, etc.
>
> However, when trying to build an application with this version of
> libpthread.so, I'm getting linking error, basically undefined
> references to all the functions created. After a bit of reseach I
> found out that those symbols had local bindings, while all the
> pthread_* symbols were global.
>
> My symbols are all declared without static keyword, so I still don't
> get why this is happening and I have been looking through the source
> to find an explanation but I can't get it yet. I would really
> appreciate if someone can show some light on this as I'm getting
> frustrated.
>
> Obviously, it's not a glibc bug or issue, but a lack of knowledge for me.
>
> Thanks for your help.
>
> Cheers.
>


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