From owner-svn-src-all@FreeBSD.ORG Fri Aug 29 10:43:58 2014 Return-Path: Delivered-To: svn-src-all@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 1BA243D4; Fri, 29 Aug 2014 10:43:58 +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 EBF421992; Fri, 29 Aug 2014 10:43:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7TAhv6e077586; Fri, 29 Aug 2014 10:43:57 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7TAhv5W077582; Fri, 29 Aug 2014 10:43:57 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201408291043.s7TAhv5W077582@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 29 Aug 2014 10:43:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270802 - in head/libexec/rtld-elf: . amd64 i386 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2014 10:43:58 -0000 Author: kib Date: Fri Aug 29 10:43:56 2014 New Revision: 270802 URL: http://svnweb.freebsd.org/changeset/base/270802 Log: Optimize r270798, only do the second pass over non-plt relocations when the first pass found IFUNCs. Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Modified: head/libexec/rtld-elf/amd64/reloc.c head/libexec/rtld-elf/i386/reloc.c head/libexec/rtld-elf/rtld.c head/libexec/rtld-elf/rtld.h Modified: head/libexec/rtld-elf/amd64/reloc.c ============================================================================== --- head/libexec/rtld-elf/amd64/reloc.c Fri Aug 29 10:13:40 2014 (r270801) +++ head/libexec/rtld-elf/amd64/reloc.c Fri Aug 29 10:43:56 2014 (r270802) @@ -176,8 +176,10 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry case R_X86_64_64: case R_X86_64_PC32: case R_X86_64_GLOB_DAT: - if ((flags & SYMLOOK_IFUNC) == 0) + if ((flags & SYMLOOK_IFUNC) == 0) { + obj->non_plt_gnu_ifunc = true; continue; + } symval = (Elf_Addr)rtld_resolve_ifunc( defobj, def); break; Modified: head/libexec/rtld-elf/i386/reloc.c ============================================================================== --- head/libexec/rtld-elf/i386/reloc.c Fri Aug 29 10:13:40 2014 (r270801) +++ head/libexec/rtld-elf/i386/reloc.c Fri Aug 29 10:43:56 2014 (r270802) @@ -161,8 +161,10 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry case R_386_32: case R_386_PC32: case R_386_GLOB_DAT: - if ((flags & SYMLOOK_IFUNC) == 0) + if ((flags & SYMLOOK_IFUNC) == 0) { + obj->non_plt_gnu_ifunc = true; continue; + } symval = (Elf_Addr)rtld_resolve_ifunc( defobj, def); break; Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Fri Aug 29 10:13:40 2014 (r270801) +++ head/libexec/rtld-elf/rtld.c Fri Aug 29 10:43:56 2014 (r270802) @@ -2576,7 +2576,8 @@ relocate_object(Obj_Entry *obj, bool bin * reference other symbols, which must be readily processed * before resolvers are called. */ - if (reloc_non_plt(obj, rtldobj, flags | SYMLOOK_IFUNC, lockstate)) + if (obj->non_plt_gnu_ifunc && + reloc_non_plt(obj, rtldobj, flags | SYMLOOK_IFUNC, lockstate)) return (-1); if (obj->relro_size > 0) { Modified: head/libexec/rtld-elf/rtld.h ============================================================================== --- head/libexec/rtld-elf/rtld.h Fri Aug 29 10:13:40 2014 (r270801) +++ head/libexec/rtld-elf/rtld.h Fri Aug 29 10:43:56 2014 (r270802) @@ -271,6 +271,7 @@ typedef struct Struct_Obj_Entry { bool filtees_loaded : 1; /* Filtees loaded */ bool irelative : 1; /* Object has R_MACHDEP_IRELATIVE relocs */ bool gnu_ifunc : 1; /* Object has references to STT_GNU_IFUNC */ + bool non_plt_gnu_ifunc : 1; /* Object has non-plt IFUNC references */ bool crt_no_init : 1; /* Object' crt does not call _init/_fini */ bool valid_hash_sysv : 1; /* A valid System V hash hash tag is available */ bool valid_hash_gnu : 1; /* A valid GNU hash tag is available */