Usage of the ELF STATIC_TLS flag & TLS type discovery at relocation

Florian Weimer fweimer@redhat.com
Tue Jul 23 11:26:33 GMT 2024


* Szabolcs Nagy:

>> The link editor could warn about mismatched accesses (especially if we
>> could mark an object for dynamic TLS, too).  Currently, you can have
>> mixed relocations within one object and nothing warns about it.
>> Theoretically, symbols could interposed, so the different TLS models
>> could be used for real, but that's really unusual, probably a bug, and
>> not really an argument against a linker warning (or an error).
>
> what if there is no mismatched access, because there is no access?
>
> mod1.so:
>   __thread int x; // no access
>   int *f(void);
>   int *bar(){return f();}
>
> mod2.so:
>   extern __thread int x;
>   int *f(){return &x;}

I think it would make sense to nudge the authors of mod1.so towards
declaring a preference for static or dynamic TLS for their object.  We'd
need two flags—absence of STATIC_TLS wouldn't indicate a preference for
dynamic TLS.

Thanks,
Florian



More information about the Binutils mailing list