From owner-svn-src-stable@freebsd.org Tue Jun 30 15:21:19 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4144498FD40; Tue, 30 Jun 2015 15:21:19 +0000 (UTC) (envelope-from des@FreeBSD.org) 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 3131410E0; Tue, 30 Jun 2015 15:21:19 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5UFLJW5051039; Tue, 30 Jun 2015 15:21:19 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5UFLI9G051037; Tue, 30 Jun 2015 15:21:18 GMT (envelope-from des@FreeBSD.org) Message-Id: <201506301521.t5UFLI9G051037@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: des set sender to des@FreeBSD.org using -f From: Dag-Erling Smørgrav Date: Tue, 30 Jun 2015 15:21:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r284955 - in stable/9: libexec/rtld-elf usr.bin/kdump X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 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: Tue, 30 Jun 2015 15:21:19 -0000 Author: des Date: Tue Jun 30 15:21:18 2015 New Revision: 284955 URL: https://svnweb.freebsd.org/changeset/base/284955 Log: MFH (r277695): allow tracing dlfunc() / dlsym() events Modified: stable/9/libexec/rtld-elf/rtld.c stable/9/usr.bin/kdump/kdump.c Directory Properties: stable/9/ (props changed) stable/9/libexec/rtld-elf/ (props changed) stable/9/usr.bin/ (props changed) stable/9/usr.bin/kdump/ (props changed) Modified: stable/9/libexec/rtld-elf/rtld.c ============================================================================== --- stable/9/libexec/rtld-elf/rtld.c Tue Jun 30 14:17:02 2015 (r284954) +++ stable/9/libexec/rtld-elf/rtld.c Tue Jun 30 15:21:18 2015 (r284955) @@ -259,6 +259,8 @@ bool ld_library_path_rpath = true; #define UTRACE_PRELOAD_FINISHED 8 #define UTRACE_INIT_CALL 9 #define UTRACE_FINI_CALL 10 +#define UTRACE_DLSYM_START 11 +#define UTRACE_DLSYM_STOP 12 struct utrace_rtld { char sig[4]; /* 'RTLD' */ @@ -2957,6 +2959,7 @@ do_dlsym(void *handle, const char *name, #ifndef __ia64__ tls_index ti; #endif + void *sym; int res; def = NULL; @@ -2966,6 +2969,7 @@ do_dlsym(void *handle, const char *name, req.flags = flags | SYMLOOK_IN_PLT; req.lockstate = &lockstate; + LD_UTRACE(UTRACE_DLSYM_START, handle, NULL, 0, 0, name); rlock_acquire(rtld_bind_lock, &lockstate); if (sigsetjmp(lockstate.env, 0) != 0) lock_upgrade(rtld_bind_lock, &lockstate); @@ -2975,6 +2979,7 @@ do_dlsym(void *handle, const char *name, if ((obj = obj_from_addr(retaddr)) == NULL) { _rtld_error("Cannot determine caller's shared object"); lock_release(rtld_bind_lock, &lockstate); + LD_UTRACE(UTRACE_DLSYM_STOP, handle, NULL, 0, 0, name); return NULL; } if (handle == NULL) { /* Just the caller's shared object. */ @@ -3022,6 +3027,7 @@ do_dlsym(void *handle, const char *name, } else { if ((obj = dlcheck(handle)) == NULL) { lock_release(rtld_bind_lock, &lockstate); + LD_UTRACE(UTRACE_DLSYM_STOP, handle, NULL, 0, 0, name); return NULL; } @@ -3068,23 +3074,26 @@ do_dlsym(void *handle, const char *name, * the relocated value of the symbol. */ if (ELF_ST_TYPE(def->st_info) == STT_FUNC) - return (make_function_pointer(def, defobj)); + sym = make_function_pointer(def, defobj); else if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) - return (rtld_resolve_ifunc(defobj, def)); + sym = rtld_resolve_ifunc(defobj, def); else if (ELF_ST_TYPE(def->st_info) == STT_TLS) { #ifdef __ia64__ return (__tls_get_addr(defobj->tlsindex, def->st_value)); #else ti.ti_module = defobj->tlsindex; ti.ti_offset = def->st_value; - return (__tls_get_addr(&ti)); + sym = __tls_get_addr(&ti); #endif } else - return (defobj->relocbase + def->st_value); + sym = defobj->relocbase + def->st_value; + LD_UTRACE(UTRACE_DLSYM_STOP, handle, sym, 0, 0, name); + return (sym); } _rtld_error("Undefined symbol \"%s\"", name); lock_release(rtld_bind_lock, &lockstate); + LD_UTRACE(UTRACE_DLSYM_STOP, handle, NULL, 0, 0, name); return NULL; } Modified: stable/9/usr.bin/kdump/kdump.c ============================================================================== --- stable/9/usr.bin/kdump/kdump.c Tue Jun 30 14:17:02 2015 (r284954) +++ stable/9/usr.bin/kdump/kdump.c Tue Jun 30 15:21:18 2015 (r284955) @@ -1283,6 +1283,8 @@ ktrcsw(struct ktr_csw *cs) #define UTRACE_PRELOAD_FINISHED 8 #define UTRACE_INIT_CALL 9 #define UTRACE_FINI_CALL 10 +#define UTRACE_DLSYM_START 11 +#define UTRACE_DLSYM_STOP 12 struct utrace_rtld { char sig[4]; /* 'RTLD' */ @@ -1361,6 +1363,13 @@ ktruser_rtld(int len, unsigned char *p) printf("RTLD: fini %p for %p (%s)\n", ut->mapbase, ut->handle, ut->name); break; + case UTRACE_DLSYM_START: + printf("RTLD: dlsym(%p, %s)\n", ut->handle, ut->name); + break; + case UTRACE_DLSYM_STOP: + printf("RTLD: %p = dlsym(%p, %s)\n", ut->mapbase, ut->handle, + ut->name); + break; default: p += 4; len -= 4;