TLS descriptors for ARM

Nathan Sidwell nathan@codesourcery.com
Wed Jan 5 11:57:00 GMT 2011


This patch adds support for TLS descriptors for ARM.  Refer to 
http://www.codesourcery.com/publications/RFC-TLSDESC-ARM.txt for the current 
specification.

The patch is a reworking of the patch posted at 
http://sourceware.org/ml/binutils/2006-08/msg00165.html.  Please refer to that 
email thread for some background.

This version of the patch:
*) uses ARM-blessed reloc numbering (see ELF for ARM Architecture r2.08)
*) adds thumb2 support
*) adds support for out-of-range branches to the PLT trampolines
*) fixes a design issues discovered during implementation

The ARM EABI specifies 2 thumb tlsdesc relocs (R_ARM_THM_TLS_DESCSEQ{16,32}). 
During implementation I discovered separating these two cases to be both hard 
(because the assembler needs to know the size of the next instruction) and 
unnecessary (because the linker has to decode the instruction being pointed at 
anyway).  Thus we implement only a single relocation (using the 
R_ARM_THM_TLS_DESCSEQ16 number).  This change has been blessed by ARM, and I 
understand there will be an updated ABI document at some point reflecting this.

The design issue concerns local TLS symbols, which turned out to not be 
supported in the original specification.  The new specification says of TLS_DESC 
dynamic relocations:

'For a local TLS symbol, the first slot is set to the symbol's offset within the 
TLS segment -- in essence this is an addend.  For global symbols that are
lazily resolved, it is set to the symbol's index in the symbol table, ored with 
0x80000000 in order to distinguish it from a local symbol offset.'

The x86 ABI has a similar issue, but doesn't need the top bit set to 
distinguish, as it has two dynamic resolvers to which the first slot can be 
initialized, and thereby distinguish.  The ARM ABI only has a single resolver 
(and cannot have 2, because of the PLT trampoline it needs), and so must encode 
this distinction directly in the second slot.  This change was also agreed with ARM.

I will be posting gcc and glibc patches later.

built and tested for arm-none-linux-gnueabi, ok?

nathan

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::         CodeSourcery

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tls.patch
Type: text/x-patch
Size: 147115 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20110105/ad246a31/attachment.bin>


More information about the Binutils mailing list