Date: Sat, 15 Oct 2011 12:02:55 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r226382 - stable/8/libexec/rtld-elf Message-ID: <201110151202.p9FC2tEC012397@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110151202.p9FC2tEC012397>