Enable __cxa_atexit && __cxa_finalize for linker

 This allows adding destructors to classes used
 for global variables.

(cherry picked from commit 14241402de0faa4b244b1bd6b1f0799ce169b880)

Change-Id: I1d8776130d1e01a8c53d23a2949f5010f4c96b16
diff --git a/linker/linker.cpp b/linker/linker.cpp
index e4a6523..6aba394 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -2199,16 +2199,6 @@
  * and other non-local data at this point.
  */
 static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(Addr) linker_base) {
-    /* NOTE: we store the args pointer on a special location
-     *       of the temporary TLS area in order to pass it to
-     *       the C Library's runtime initializer.
-     *
-     *       The initializer must clear the slot and reset the TLS
-     *       to point to a different location to ensure that no other
-     *       shared library constructor can access it.
-     */
-  __libc_init_tls(args);
-
 #if TIMING
     struct timeval t0, t1;
     gettimeofday(&t0, 0);
@@ -2435,6 +2425,8 @@
     _exit(EXIT_FAILURE);
   }
 
+  __libc_init_tls(args);
+
   // Initialize the linker's own global variables
   linker_so.CallConstructors();
 
@@ -2444,7 +2436,6 @@
   solist = get_libdl_info();
   sonext = get_libdl_info();
 
-
   // We have successfully fixed our own relocations. It's safe to run
   // the main part of the linker now.
   args.abort_message_ptr = &g_abort_message;