From owner-svn-src-head@FreeBSD.ORG Tue Mar 27 14:10:16 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A16FC106566B; Tue, 27 Mar 2012 14:10:16 +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 803138FC0C; Tue, 27 Mar 2012 14:10:16 +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 q2REAGYQ089067; Tue, 27 Mar 2012 14:10:16 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2REAGwD089064; Tue, 27 Mar 2012 14:10:16 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201203271410.q2REAGwD089064@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 27 Mar 2012 14:10:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233546 - head/libexec/rtld-elf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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, 27 Mar 2012 14:10:16 -0000 Author: kib Date: Tue Mar 27 14:10:15 2012 New Revision: 233546 URL: http://svn.freebsd.org/changeset/base/233546 Log: Prevent rtld_verify_object_versions() from being called several times for the same object. This can happen when object is a dependency of the dlopen()ed dso. When called several times, we waste time due to unneeded processing, and memory, because obj->vertab is allocated anew on each iteration. Reviewed by: kan MFC after: 2 weeks Modified: head/libexec/rtld-elf/rtld.c head/libexec/rtld-elf/rtld.h Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Tue Mar 27 14:05:12 2012 (r233545) +++ head/libexec/rtld-elf/rtld.c Tue Mar 27 14:10:15 2012 (r233546) @@ -4158,6 +4158,10 @@ rtld_verify_object_versions(Obj_Entry *o const Obj_Entry *depobj; int maxvernum, vernum; + if (obj->ver_checked) + return (0); + obj->ver_checked = true; + maxvernum = 0; /* * Walk over defined and required version records and figure out Modified: head/libexec/rtld-elf/rtld.h ============================================================================== --- head/libexec/rtld-elf/rtld.h Tue Mar 27 14:05:12 2012 (r233545) +++ head/libexec/rtld-elf/rtld.h Tue Mar 27 14:10:15 2012 (r233546) @@ -230,6 +230,7 @@ typedef struct Struct_Obj_Entry { bool mainprog : 1; /* True if this is the main program */ bool rtld : 1; /* True if this is the dynamic linker */ bool relocated : 1; /* True if processed by relocate_objects() */ + bool ver_checked : 1; /* True if processed by rtld_verify_object_versions */ bool textrel : 1; /* True if there are relocations to text seg */ bool symbolic : 1; /* True if generated with "-Bsymbolic" */ bool bind_now : 1; /* True if all relocations should be made first */