TLS in ARM-nptl - a question

Richard Earnshaw rearnsha@arm.com
Tue Sep 14 09:55:00 GMT 2010


On Fri, 2010-09-10 at 00:10 +0530, Uma shankar wrote:
> Hi,
> 
> I  am trying to understand a  particular  program-crash  i am looking
> at now, coming from  libpthread.so  library in ARM.    I  am using
> NPTL and glibc  4.2.1
> 
> >From stack-trace , i figured that  pthread_self() is being called.
> 
> >From source, I saw that this calls __builtin_thread_pointer().  This
> function has been synthesized in gcc-source  by a macro.
> 
> The  assembly of  the  function  __builtin_thread_pointer()  ( from
> objdump of lib )   looks like
> 
> mvn  r0, 0xF000
> sub  pc,  r0, 0x1F8
> 
> This  does not make sense.   I  thought of the possibility thagt
> maybe  this is a address-value  which gets  relocated, but this is
> text-region of a shared library ( libpthread) and so is not relocated.
> 
> I  have 2 questions  -
> a)  What is the meaning  of the above  asm code ?
> b)  As the program  branches to invalid address  0xE8  somewhere after
> pthread_self( ),  what could be wrong ?
> 
> I guess this is some kind  of  TLS-data corruption.
> I  would be reading about  TLS in ARM tomorrow.
> 
>            Thanks

The code is jumping to a 'well-known' address exported by the linux
kernel.  That address contains a processor-specific sequence of
instructions that will return the TLS base for the current address.

Of course, if you're not running on top of the Linux kernel, then you'll
need to find another way of making all that work.  If your CPU is based
on ARMv7-A then the compiler will (should) use a CP-15 register directly
as it's more efficient (but that register did not exist on earlier
cores).

R.



More information about the Gcc-help mailing list