Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jan 2016 04:32:13 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r293069 - head/libexec/rtld-elf
Message-ID:  <201601030432.u034WDnl043683@repo.freebsd.org>

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



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