Finding the source code for ___tls_get_addr_internal()

Ian Lance Taylor iant@google.com
Thu Jan 17 12:18:00 GMT 2013


On Wed, Jan 16, 2013 at 6:21 PM, Saul Tamari <stamari@gmail.com> wrote:
> I checked the shared library and parts of it are not compiled with -fpic.
> So that could be the cause of the problematic TLS behavior I'm seeing?
> The run-time linker doesn't prepare the loaded TLS variables
> correctly?

If you put code that accesses TLS variables into a shared library, and
that code was not compiled with -fpic/-fPIC nor with
-ftls-model=global-dynamic, then accessing the TLS variables will read
the wrong values.

> Can -fpic compilation cause significant performance or memory
> footprint changes on modern x86 Xeon processors?

Yes, it's about a 3 or 4% performance hit.  Putting code not compiled
with -fPIC in a shared library will slow down program startup, and
make the program less secure because the text segment will be
writable.  Also, the shared library will not actually be shared: each
process will have its own copy in virtual memory.  Whether these
things matter to you depends on how you run your code.

Ian



More information about the Gcc-help mailing list