Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Aug 2014 10:43:57 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
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
Message-ID:  <201408291043.s7TAhv5W077582@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408291043.s7TAhv5W077582>