Force global-dynamic TLS model

Florian Weimer fweimer@redhat.com
Wed Jun 24 08:59:31 GMT 2020


* Nikos Dragazis:

> For example, let's say we have an ELF executable that defines and
> accesses a TLS variable. From gcc's man page, I read that, in this case,
> gcc will use the initial-exec TLS model by default. My question is if we
> can change that and, say, use the global-dynamic model. To this end, I
> have tried the `-ftls-model=global-dynamic` option and the `tls_model`
> gcc variable attribute. None of these worked.

Try -ftls-model=global-dynamic -fpic.  This will prevent GCC from
performing relaxation.  For many targets, the link editor still performs
relaxation.  To turn this off, you will have to link the executable with
-shared, I think, with some hackery to produce an executable that can
actually be run.

Thanks,
Florian



More information about the Gcc-help mailing list