[PATCH COMMITTED] x86: Fix THREAD_SELF definition to avoid ld.so crash (bug 27004)

Florian Weimer fweimer@redhat.com
Thu Dec 3 16:01:57 GMT 2020


* Adhemerval Zanella via Libc-alpha:

>> diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
>> index b74347bacd..ab98c24a02 100644
>> --- a/sysdeps/i386/nptl/tls.h
>> +++ b/sysdeps/i386/nptl/tls.h
>> @@ -234,11 +234,16 @@ tls_fill_user_desc (union user_desc_init *desc,
>>     assignments like
>>  	pthread_descr self = thread_self();
>>     do not get optimized away.  */
>> -# define THREAD_SELF \
>> +# if __GNUC_PREREQ (6, 0)
>> +#  define THREAD_SELF \
>> +  (*(struct pthread *__seg_gs *) offsetof (struct pthread, header.self))
>> +# else
>> +#  define THREAD_SELF \
>>    ({ struct pthread *__self;						      \
>>       asm ("movl %%gs:%c1,%0" : "=r" (__self)				      \
>>  	  : "i" (offsetof (struct pthread, header.self)));		      \
>>       __self;})
>> +# endif
>>  
>>  /* Magic for libthread_db to know how to do THREAD_SELF.  */
>>  # define DB_THREAD_SELF \
>
> Do wee need to __GLIBC_PREREQ here? This is an internal header and the minimum
> required gcc should be suffice here.

I think we can rework the header to use __seg_fs/__seg_gs throughout,
yes.  I assumed we were still supporting GCC 5, which I see is not the
case.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill



More information about the Libc-alpha mailing list