This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Finding the source code for ___tls_get_addr_internal()


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]