Author: kib
Date: Sat Oct 15 12:02:55 2011
New Revision: 226382
URL: http://svn.freebsd.org/changeset/base/226382

Log:
  MFC r226155:
  Set TLS block for the main thread after the relocations are processed.

Modified:
  stable/8/libexec/rtld-elf/rtld.c
Directory Properties:
  stable/8/libexec/rtld-elf/   (props changed)

Modified: stable/8/libexec/rtld-elf/rtld.c
==============================================================================
--- stable/8/libexec/rtld-elf/rtld.c    Sat Oct 15 09:29:43 2011        
(r226381)
+++ stable/8/libexec/rtld-elf/rtld.c    Sat Oct 15 12:02:55 2011        
(r226382)
@@ -508,8 +508,12 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
        exit (0);
     }
 
-    /* setup TLS for main thread */
-    dbg("initializing initial thread local storage");
+    /*
+     * Processing tls relocations requires having the tls offsets
+     * initialized.  Prepare offsets before starting initial
+     * relocation processing.
+     */
+    dbg("initializing initial thread local storage offsets");
     STAILQ_FOREACH(entry, &list_main, link) {
        /*
         * Allocate all the initial objects out of the static TLS
@@ -517,7 +521,6 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
         */
        allocate_tls_offset(entry->obj);
     }
-    allocate_initial_tls(obj_list);
 
     if (relocate_objects(obj_main,
        ld_bind_now != NULL && *ld_bind_now != '\0', &obj_rtld) == -1)
@@ -532,6 +535,14 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
        exit (0);
     }
 
+    /*
+     * Setup TLS for main thread.  This must be done after the
+     * relocations are processed, since tls initialization section
+     * might be the subject for relocations.
+     */
+    dbg("initializing initial thread local storage");
+    allocate_initial_tls(obj_list);
+
     dbg("initializing key program variables");
     set_program_var("__progname", argv[0] != NULL ? basename(argv[0]) : "");
     set_program_var("environ", env);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to