Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F133262063
D28220.id82454.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D28220.id82454.diff
View Options
Index: libexec/rtld-elf/paths.h
===================================================================
--- libexec/rtld-elf/paths.h
+++ libexec/rtld-elf/paths.h
@@ -31,6 +31,14 @@
#undef _PATH_ELF_HINTS
+#if __SIZEOF_POINTER__ == 4
+#define LD_ "LD_32_"
+#elif __SIZEOF_POINTER__ == 8
+#define LD_ "LD_64_"
+#else
+#error "Unsupported pointer size"
+#endif
+
#ifdef COMPAT_32BIT
#define _PATH_ELF_HINTS "/var/run/ld-elf32.so.hints"
#define _PATH_LIBMAP_CONF "/etc/libmap32.conf"
@@ -59,8 +67,8 @@
#define STANDARD_LIBRARY_PATH "/lib/casper:/lib:/usr/lib"
#endif
-#ifndef LD_
-#define LD_ "LD_"
+#ifndef LD_FALLBACK
+#define LD_FALLBACK(var) "LD_" var
#endif
#define _PATH_SOFT_ELF_HINTS "/var/run/ld-elf-soft.so.hints"
Index: libexec/rtld-elf/rtld.1
===================================================================
--- libexec/rtld-elf/rtld.1
+++ libexec/rtld-elf/rtld.1
@@ -127,10 +127,16 @@
recognizes a number of environment variables that can be used to modify
its behaviour.
On 64-bit architectures, the linker for 32-bit objects recognizes
-all the environment variables listed below, but is being prefixed with
-.Ev LD_32_ ,
+all the environment variables listed below but prefixed with
+.Ev LD_32_
+instead of
+.Ev LD_ ,
for example:
.Ev LD_32_TRACE_LOADED_OBJECTS .
+On 64-bit systems,
+.Nm
+also recognizes variables prefixed with
+.Ev LD_64_ .
.Bl -tag -width ".Ev LD_LIBMAP_DISABLE"
.It Ev LD_DUMP_REL_POST
If set,
Index: libexec/rtld-elf/rtld.c
===================================================================
--- libexec/rtld-elf/rtld.c
+++ libexec/rtld-elf/rtld.c
@@ -353,6 +353,20 @@
#define _LD(x) LD_ x
#endif
+/* Check LD_{64,32}_<VAR> and if that is not set fall back to LD_<VAR>. */
+#define get_ld_env(var) _get_ld_env(_LD(var), LD_FALLBACK(var))
+
+static char*
+_get_ld_env(const char* prefixed, const char* fallback)
+{
+ char* result;
+
+ result = getenv(prefixed);
+ if (result == NULL && fallback != NULL)
+ result = getenv(fallback);
+ return (result);
+}
+
/*
* Main entry point for dynamic linking. The first argument is the
* stack pointer. The stack is expected to be laid out as described
@@ -562,7 +576,7 @@
}
}
- ld_bind_now = getenv(_LD("BIND_NOW"));
+ ld_bind_now = get_ld_env("BIND_NOW");
/*
* If the process is tainted, then we un-set the dangerous environment
@@ -580,17 +594,17 @@
rtld_die();
}
}
- ld_debug = getenv(_LD("DEBUG"));
+ ld_debug = get_ld_env("DEBUG");
if (ld_bind_now == NULL)
- ld_bind_not = getenv(_LD("BIND_NOT")) != NULL;
- libmap_disable = getenv(_LD("LIBMAP_DISABLE")) != NULL;
- libmap_override = getenv(_LD("LIBMAP"));
- ld_library_path = getenv(_LD("LIBRARY_PATH"));
- ld_library_dirs = getenv(_LD("LIBRARY_PATH_FDS"));
- ld_preload = getenv(_LD("PRELOAD"));
- ld_elf_hints_path = getenv(_LD("ELF_HINTS_PATH"));
- ld_loadfltr = getenv(_LD("LOADFLTR")) != NULL;
- library_path_rpath = getenv(_LD("LIBRARY_PATH_RPATH"));
+ ld_bind_not = get_ld_env("BIND_NOT") != NULL;
+ libmap_disable = get_ld_env("LIBMAP_DISABLE") != NULL;
+ libmap_override = get_ld_env("LIBMAP");
+ ld_library_path = get_ld_env("LIBRARY_PATH");
+ ld_library_dirs = get_ld_env("LIBRARY_PATH_FDS");
+ ld_preload = get_ld_env("PRELOAD");
+ ld_elf_hints_path = get_ld_env("ELF_HINTS_PATH");
+ ld_loadfltr = get_ld_env("LOADFLTR") != NULL;
+ library_path_rpath = get_ld_env("LIBRARY_PATH_RPATH");
if (library_path_rpath != NULL) {
if (library_path_rpath[0] == 'y' ||
library_path_rpath[0] == 'Y' ||
@@ -602,8 +616,8 @@
dangerous_ld_env = libmap_disable || (libmap_override != NULL) ||
(ld_library_path != NULL) || (ld_preload != NULL) ||
(ld_elf_hints_path != NULL) || ld_loadfltr;
- ld_tracing = getenv(_LD("TRACE_LOADED_OBJECTS"));
- ld_utrace = getenv(_LD("UTRACE"));
+ ld_tracing = get_ld_env("TRACE_LOADED_OBJECTS");
+ ld_utrace = get_ld_env("UTRACE");
if ((ld_elf_hints_path == NULL) || strlen(ld_elf_hints_path) == 0)
ld_elf_hints_path = ld_elf_hints_default;
@@ -735,7 +749,7 @@
exit(0);
}
- if (getenv(_LD("DUMP_REL_PRE")) != NULL) {
+ if (get_ld_env("DUMP_REL_PRE") != NULL) {
dump_relocations(obj_main);
exit (0);
}
@@ -763,7 +777,7 @@
if (do_copy_relocations(obj_main) == -1)
rtld_die();
- if (getenv(_LD("DUMP_REL_POST")) != NULL) {
+ if (get_ld_env("DUMP_REL_POST") != NULL) {
dump_relocations(obj_main);
exit (0);
}
@@ -4665,16 +4679,16 @@
const char *fmt1, *fmt2, *fmt, *main_local, *list_containers;
int c;
- if ((main_local = getenv(_LD("TRACE_LOADED_OBJECTS_PROGNAME"))) == NULL)
+ if ((main_local = get_ld_env("TRACE_LOADED_OBJECTS_PROGNAME")) == NULL)
main_local = "";
- if ((fmt1 = getenv(_LD("TRACE_LOADED_OBJECTS_FMT1"))) == NULL)
+ if ((fmt1 = get_ld_env("TRACE_LOADED_OBJECTS_FMT1")) == NULL)
fmt1 = "\t%o => %p (%x)\n";
- if ((fmt2 = getenv(_LD("TRACE_LOADED_OBJECTS_FMT2"))) == NULL)
+ if ((fmt2 = get_ld_env("TRACE_LOADED_OBJECTS_FMT2")) == NULL)
fmt2 = "\t%o (%x)\n";
- list_containers = getenv(_LD("TRACE_LOADED_OBJECTS_ALL"));
+ list_containers = get_ld_env("TRACE_LOADED_OBJECTS_ALL");
for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) {
Needed_Entry *needed;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 25, 10:57 AM (3 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24170854
Default Alt Text
D28220.id82454.diff (5 KB)
Attached To
Mode
D28220: rtld: Always check LD_64_/LD_32_ environment variables
Attached
Detach File
Event Timeline
Log In to Comment