svn commit: r293066 - in head/libexec/rtld-elf: . aarch64 amd64 arm i386 mips powerpc powerpc64 sparc64

Warner Losh imp at FreeBSD.org
Sun Jan 3 04:32:04 UTC 2016


Author: imp
Date: Sun Jan  3 04:32:02 2016
New Revision: 293066
URL: https://svnweb.freebsd.org/changeset/base/293066

Log:
  Create a generalized exec hook that different architectures can hook
  into if they need to, but default to no action.
  
  Differential Review: https://reviews.freebsd.org/D2718

Modified:
  head/libexec/rtld-elf/aarch64/rtld_machdep.h
  head/libexec/rtld-elf/amd64/rtld_machdep.h
  head/libexec/rtld-elf/arm/reloc.c
  head/libexec/rtld-elf/arm/rtld_machdep.h
  head/libexec/rtld-elf/i386/rtld_machdep.h
  head/libexec/rtld-elf/mips/rtld_machdep.h
  head/libexec/rtld-elf/paths.h
  head/libexec/rtld-elf/powerpc/rtld_machdep.h
  head/libexec/rtld-elf/powerpc64/rtld_machdep.h
  head/libexec/rtld-elf/rtld.c
  head/libexec/rtld-elf/sparc64/rtld_machdep.h

Modified: head/libexec/rtld-elf/aarch64/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/aarch64/rtld_machdep.h	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/aarch64/rtld_machdep.h	Sun Jan  3 04:32:02 2016	(r293066)
@@ -80,4 +80,6 @@ extern void *__tls_get_addr(tls_index *t
 #define	RTLD_DEFAULT_STACK_PF_EXEC	PF_X
 #define	RTLD_DEFAULT_STACK_EXEC		PROT_EXEC
 
+#define md_abi_variant_hook(x)
+
 #endif

Modified: head/libexec/rtld-elf/amd64/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/amd64/rtld_machdep.h	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/amd64/rtld_machdep.h	Sun Jan  3 04:32:02 2016	(r293066)
@@ -79,4 +79,6 @@ void *__tls_get_addr(tls_index *ti) __ex
 #define	RTLD_DEFAULT_STACK_PF_EXEC	PF_X
 #define	RTLD_DEFAULT_STACK_EXEC		PROT_EXEC
 
+#define md_abi_variant_hook(x)
+
 #endif

Modified: head/libexec/rtld-elf/arm/reloc.c
==============================================================================
--- head/libexec/rtld-elf/arm/reloc.c	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/arm/reloc.c	Sun Jan  3 04:32:02 2016	(r293066)
@@ -18,6 +18,41 @@ __FBSDID("$FreeBSD$");
 #include "paths.h"
 
 void
+arm_abi_variant_hook(Elf_Auxinfo **aux_info)
+{
+	Elf_Word ehdr;
+
+	/*
+	 * If we're running an old kernel that doesn't provide any data fail
+	 * safe by doing nothing.
+	 */
+	if (aux_info[AT_EHDRFLAGS] == NULL)
+		return;
+	ehdr = aux_info[AT_EHDRFLAGS]->a_un.a_val;
+
+	/*
+	 * Hard float ABI binaries are the default, and use the default paths
+	 * and such.
+	 */
+	if ((ehdr & EF_ARM_VFP_FLOAT) != 0)
+		return;
+
+	/*
+	 * This is a soft float ABI binary. We need to use the soft float
+	 * settings. For the moment, the standard library path includes the hard
+	 * float paths as well. When upgrading, we need to execute the wrong
+	 * kind of binary until we've installed the new binaries. We could go
+	 * off whether or not /libsoft exists, but the simplicity of having it
+	 * in the path wins.
+	 */
+	ld_elf_hints_default = _PATH_SOFT_ELF_HINTS;
+	ld_path_libmap_conf = _PATH_SOFT_LIBMAP_CONF;
+	ld_path_rtld = _PATH_SOFT_RTLD;
+	ld_standard_library_path = SOFT_STANDARD_LIBRARY_PATH;
+	ld_env_prefix = LD_SOFT_;
+}
+
+void
 init_pltgot(Obj_Entry *obj)
 {       
 	if (obj->pltgot != NULL) {

Modified: head/libexec/rtld-elf/arm/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/arm/rtld_machdep.h	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/arm/rtld_machdep.h	Sun Jan  3 04:32:02 2016	(r293066)
@@ -75,4 +75,9 @@ extern void *__tls_get_addr(tls_index *t
 #define	RTLD_DEFAULT_STACK_PF_EXEC	PF_X
 #define	RTLD_DEFAULT_STACK_EXEC		PROT_EXEC
 
+extern void arm_abi_variant_hook(Elf_Auxinfo **);
+
+#define md_abi_variant_hook(x)		arm_abi_variant_hook(x)
+#define RTLD_VARIANT_ENV_NAMES
+
 #endif

Modified: head/libexec/rtld-elf/i386/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/i386/rtld_machdep.h	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/i386/rtld_machdep.h	Sun Jan  3 04:32:02 2016	(r293066)
@@ -80,4 +80,6 @@ void *__tls_get_addr(tls_index *ti) __ex
 #define	RTLD_DEFAULT_STACK_PF_EXEC	PF_X
 #define	RTLD_DEFAULT_STACK_EXEC		PROT_EXEC
 
+#define md_abi_variant_hook(x)
+
 #endif

Modified: head/libexec/rtld-elf/mips/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/mips/rtld_machdep.h	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/mips/rtld_machdep.h	Sun Jan  3 04:32:02 2016	(r293066)
@@ -75,4 +75,6 @@ extern void *__tls_get_addr(tls_index *t
 #define	RTLD_DEFAULT_STACK_PF_EXEC	PF_X
 #define	RTLD_DEFAULT_STACK_EXEC		PROT_EXEC
 
+#define md_abi_variant_hook(x)
+
 #endif

Modified: head/libexec/rtld-elf/paths.h
==============================================================================
--- head/libexec/rtld-elf/paths.h	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/paths.h	Sun Jan  3 04:32:02 2016	(r293066)
@@ -1,8 +1,6 @@
 /*-
  * Copyright 1996, 1997, 1998, 1999, 2000 John D. Polstra.
  * Copyright 2003 Alexander Kabaev <kan at FreeBSD.ORG>.
- * Copyright 2009-2012 Konstantin Belousov <kib at FreeBSD.ORG>.
- * Copyright 2012 John Marino <draco at marino.st>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -61,7 +59,13 @@
 #define	LD_			"LD_"
 #endif
 
-extern char *ld_path_elf_hints;
+#define	_PATH_SOFT_ELF_HINTS	"/var/run/ld-elf-soft.so.hints"
+#define	_PATH_SOFT_LIBMAP_CONF	"/etc/libmap-soft.conf"
+#define	_PATH_SOFT_RTLD		"/libexec/ld-elf.so.1"
+#define	SOFT_STANDARD_LIBRARY_PATH "/libsoft:/usr/libsoft:/lib:/usr/lib"
+#define	LD_SOFT_		"LD_SOFT_"
+
+extern char *ld_elf_hints_default;
 extern char *ld_path_libmap_conf;
 extern char *ld_path_rtld;
 extern char *ld_standard_library_path;

Modified: head/libexec/rtld-elf/powerpc/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/powerpc/rtld_machdep.h	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/powerpc/rtld_machdep.h	Sun Jan  3 04:32:02 2016	(r293066)
@@ -90,4 +90,6 @@ extern void *__tls_get_addr(tls_index* t
 #define	RTLD_DEFAULT_STACK_PF_EXEC	PF_X
 #define	RTLD_DEFAULT_STACK_EXEC		PROT_EXEC
 
+#define md_abi_variant_hook(x)
+
 #endif

Modified: head/libexec/rtld-elf/powerpc64/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/powerpc64/rtld_machdep.h	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/powerpc64/rtld_machdep.h	Sun Jan  3 04:32:02 2016	(r293066)
@@ -82,4 +82,6 @@ extern void *__tls_get_addr(tls_index* t
 #define	RTLD_DEFAULT_STACK_PF_EXEC	PF_X
 #define	RTLD_DEFAULT_STACK_EXEC		PROT_EXEC
 
+#define md_abi_variant_hook(x)
+
 #endif

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/rtld.c	Sun Jan  3 04:32:02 2016	(r293066)
@@ -419,6 +419,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_
 
     trust = !issetugid();
 
+    md_abi_variant_hook(aux_info);
+
     ld_bind_now = getenv(_LD("BIND_NOW"));
     /* 
      * If the process is tainted, then we un-set the dangerous environment

Modified: head/libexec/rtld-elf/sparc64/rtld_machdep.h
==============================================================================
--- head/libexec/rtld-elf/sparc64/rtld_machdep.h	Sat Jan  2 23:14:52 2016	(r293065)
+++ head/libexec/rtld-elf/sparc64/rtld_machdep.h	Sun Jan  3 04:32:02 2016	(r293066)
@@ -71,4 +71,6 @@ extern void *__tls_get_addr(tls_index *t
 #define	RTLD_DEFAULT_STACK_PF_EXEC	0
 #define	RTLD_DEFAULT_STACK_EXEC		0
 
+#define md_abi_variant_hook(x)
+
 #endif


More information about the svn-src-all mailing list