svn commit: r293069 - head/libexec/rtld-elf

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


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

Log:
  If md_exec_hook is defined, provide a way to create the strings
  for the environment variables we look up at runtime. Otherwise,
  there's no way they will change, optimize it at compile time.
  
  Differential Review: https://reviews.freebsd.org/D2718

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Sun Jan  3 04:32:05 2016	(r293068)
+++ head/libexec/rtld-elf/rtld.c	Sun Jan  3 04:32:13 2016	(r293069)
@@ -204,8 +204,6 @@ extern Elf_Dyn _DYNAMIC;
 #define	RTLD_IS_DYNAMIC()	(&_DYNAMIC != NULL)
 #endif
 
-#define _LD(x)	LD_ x
-
 int dlclose(void *) __exported;
 char *dlerror(void) __exported;
 void *dlopen(const char *, int) __exported;
@@ -325,6 +323,24 @@ ld_utrace_log(int event, void *handle, v
 	utrace(&ut, sizeof(ut));
 }
 
+#ifdef RTLD_VARIANT_ENV_NAMES
+/*
+ * construct the env variable based on the type of binary that's
+ * running.
+ */
+static inline const char *
+_LD(const char *var)
+{
+	static char buffer[128];
+
+	strlcpy(buffer, ld_env_prefix, sizeof(buffer));
+	strlcat(buffer, var, sizeof(buffer));
+	return (buffer);
+}
+#else
+#define _LD(x)	LD_ x
+#endif
+
 /*
  * Main entry point for dynamic linking.  The first argument is the
  * stack pointer.  The stack is expected to be laid out as described


More information about the svn-src-all mailing list