rtld: increase TLS storage space (bug 2566)
authorJohn Marino <draco@marino.st>
Tue, 11 Jun 2013 11:11:21 +0000 (13:11 +0200)
committerJohn Marino <draco@marino.st>
Tue, 11 Jun 2013 11:34:13 +0000 (13:34 +0200)
commit4b2454d14575fe90aff242d1b282429ae99e2fea
tree3ca0013d3e8bfc0edbb8b1f8264c211581ee2d79
parente6d54dab69fef3a753ecae88cf737d268d86e1c5
rtld: increase TLS storage space (bug 2566)

It appears that the TLS storage space, which is currently defined as 256
bytes on both platforms, is insufficient to handle libc TLS data.
Due to nmalloc setting of the thr_mags structure as Thread Local Storage,
the TLS elf section of x86-64 libc is 1172 bytes, while the i386 libc TLS
section weighs in at 588 bytes.  For comparison, the FreeBSD libc TLS
section is 17 bytes, and FreeBSD rtld only reserves 128 bytes for TLS.

The requirements for dmalloc are more modest, so this shortfall was likely
an unintended side-effect of switching from dmalloc back to nmalloc.

This commit sets the reserved TLS space to 1280 bytes for x86-64 and 640
bytes for i386.  This should allow 3.4 packages to continue to work on
the latest 3.5 branch as long as libc.so.7 is present.  For world upgrades
this is the normal case, but the libraries can be obtained by installing
misc/compat34x from dports as well.

Even if the libc TLS space requirements drop significantly, the large
RTLD_STATIC_TLS_EXTRA value needs to be maintained as long as
compatibility with old libc (3.4 and earlier) libraries is required.
sys/cpu/i386/include/tls.h
sys/cpu/x86_64/include/tls.h