SPRAB89A September 2011 – March 2014
Thread-pointer relative addressing cannot be used for weak references, since there is no way to generate a zero address if the symbol is undefined. Therefore, the Local Dynamic form must be used for weak references in the Static Executable and Bare-Metal Dynamic Linking access model.
In static and bare-metal dynamic linking the following addressing is generated for weak references:
MVK $TPR_S16(x), A5 ; reloc R_C6000_TPR_S16
|| CALLP __c6xabi_get_addr,B3 ; A4 has the address of x at return
The C6x eabi function __c6xabi_get_addr() has the following signature:
void * __c6xabi_get_addr(ptrdiff_t TPR_offst);
This function accepts a 32-bit TPR offset and returns the address of the thread-local variable. A special value of -1 for the TPR offset is used to indicate a weak undefined reference. A zero is returned in this case.
The static linker and dynamic linker resolve TPR_S16 relocations to -1 for a weak undefined reference.