From owner-svn-src-stable@FreeBSD.ORG Sat Oct 15 12:02:56 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 071841065687; Sat, 15 Oct 2011 12:02:56 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA3538FC12; Sat, 15 Oct 2011 12:02:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p9FC2tAC012399; Sat, 15 Oct 2011 12:02:55 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9FC2tEC012397; Sat, 15 Oct 2011 12:02:55 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201110151202.p9FC2tEC012397@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 15 Oct 2011 12:02:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226382 - stable/8/libexec/rtld-elf X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Oct 2011 12:02:56 -0000 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);