[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Specify how undefined weak symbol should be resolved in executable



Hi,

On Tue, 23 Feb 2016, Szabolcs Nagy wrote:

> libgcc/gthr-posix.h checks 'multi-threadedness' by looking
> at a weakref (if it's zero then single-threaded execution
> is assumed).
> 
> on glibc the weakref is __pthread_key_create nowadays,
> but on other systems or older libgcc it's pthread_cancel.

Yep, that's the one.

> so the address of this weakref is taken, the other pthread weakrefs are 
> called only if this weakref was non-zero.
> 
> i'm not sure how the proposed changes affect this use-case,

Some of the variants will make this use-case work also for non-PIC
executables, at the expense of one more unsharable .text page on some 
architectures (the one where this adress-checking takes place).

> but this way of deciding single-threadedness is broken and a bug that 
> gcc should eventually fix.  (e.g. a static linked multi-threaded c++ 
> application may not have a pthread_cancel symbol defined and thus 
> libstdc++ may not use locks where necessary or crash when pthread_cancel 
> is defined but other weakrefs are not).

Yep, that's one problem of our current behaviour with addresses of weak 
symbols on non-PIC.


Ciao,
Michael.