Initialize TLS before any application code is run.

Since e19d702b8e33, dlsym and friends use recursive mutexes that
require the current thread id, which is not available before the libc
constructor. This prevents us from using dlsym() in .preinit_array.

This change moves TLS initialization from libc constructor to the earliest
possible point - immediately after linker itself is relocated. As a result,
pthread_internal_t for the initial thread is available from the start.

As a bonus, values stored in TLS in .preinit_array are not lost when libc is
initialized.

Change-Id: Iee5a710ee000173bff63e924adeb4a4c600c1e2d
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index 655b8f3..268cacf 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -47,6 +47,8 @@
 } pthread_internal_t;
 
 extern void _init_thread(pthread_internal_t * thread, pid_t kernel_id, pthread_attr_t * attr, void * stack_base);
+void _pthread_internal_add( pthread_internal_t*  thread );
+pthread_internal_t* __get_thread(void);
 
 /* needed by posix-timers.c */