From owner-svn-src-head@FreeBSD.ORG Tue May 6 18:07:59 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B1E76265; Tue, 6 May 2014 18:07:59 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8500273; Tue, 6 May 2014 18:07:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s46I7xMJ048379; Tue, 6 May 2014 18:07:59 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s46I7xxt048377; Tue, 6 May 2014 18:07:59 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201405061807.s46I7xxt048377@svn.freebsd.org> From: Mark Johnston Date: Tue, 6 May 2014 18:07:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265456 - head/libexec/rtld-elf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 May 2014 18:07:59 -0000 Author: markj Date: Tue May 6 18:07:58 2014 New Revision: 265456 URL: http://svnweb.freebsd.org/changeset/base/265456 Log: Add a postinit debugger hook to rtld. This will be used by dtrace(1) to halt the victim process before its entry point is called, at which point probes and DOF data are registered with the kernel. The r_debug_state hook cannot be used for this purpose, as it is called before the program's init routines are invoked and in particular before DOF data is registered (via drti.o). Reviewed by: kib MFC after: 2 weeks Modified: head/libexec/rtld-elf/Symbol.map head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/Symbol.map ============================================================================== --- head/libexec/rtld-elf/Symbol.map Tue May 6 16:51:07 2014 (r265455) +++ head/libexec/rtld-elf/Symbol.map Tue May 6 18:07:58 2014 (r265456) @@ -30,4 +30,5 @@ FBSDprivate_1.0 { _rtld_atfork_post; _rtld_addr_phdr; _rtld_get_stack_prot; + _rtld_debug_postinit; }; Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Tue May 6 16:51:07 2014 (r265455) +++ head/libexec/rtld-elf/rtld.c Tue May 6 18:07:58 2014 (r265456) @@ -162,6 +162,7 @@ static bool matched_symbol(SymLook *, co const unsigned long); void r_debug_state(struct r_debug *, struct link_map *) __noinline; +void _r_debug_postinit(struct link_map *) __noinline; /* * Data declarations. @@ -637,6 +638,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_ if (obj_main->crt_no_init) preinit_main(); objlist_call_init(&initlist, &lockstate); + _r_debug_postinit(&obj_main->linkmap); objlist_clear(&initlist); dbg("loading filtees"); for (obj = obj_list->next; obj != NULL; obj = obj->next) { @@ -3553,6 +3555,19 @@ r_debug_state(struct r_debug* rd, struct } /* + * A function called after init routines have completed. This can be used to + * break before a program's entry routine is called, and can be used when + * main is not available in the symbol table. + */ +void +_r_debug_postinit(struct link_map *m) +{ + + /* See r_debug_state(). */ + __asm __volatile("" : : : "memory"); +} + +/* * Get address of the pointer variable in the main program. * Prefer non-weak symbol over the weak one. */