Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151825555
D2718.id5899.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
14 KB
Referenced Files
None
Subscribers
None
D2718.id5899.diff
View Options
Index: libexec/rtld-elf/arm/reloc.c
===================================================================
--- libexec/rtld-elf/arm/reloc.c
+++ libexec/rtld-elf/arm/reloc.c
@@ -17,6 +17,41 @@
#include "rtld.h"
void
+arm_exec_hook(Elf_Auxinfo **aux_info)
+{
+ Elf_Word ehdr;
+
+ /*
+ * If we're running an old kenrel 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 binaries are the default, and use the default paths and
+ * such.
+ */
+ if (ehdr & EF_ARM_VFP_FLOAT)
+ return;
+
+ /*
+ * This is a soft float 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 /lib/soft exists, but the simplicity of having it
+ * in the path wins.
+ */
+ ld_path_elf_hints = _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) {
Index: libexec/rtld-elf/arm/rtld_machdep.h
===================================================================
--- libexec/rtld-elf/arm/rtld_machdep.h
+++ libexec/rtld-elf/arm/rtld_machdep.h
@@ -75,4 +75,8 @@
#define RTLD_DEFAULT_STACK_PF_EXEC PF_X
#define RTLD_DEFAULT_STACK_EXEC PROT_EXEC
+extern void arm_exec_hook(Elf_Auxinfo **);
+
+#define md_exec_hook(x) arm_exec_hook(x)
+
#endif
Index: libexec/rtld-elf/libmap.c
===================================================================
--- libexec/rtld-elf/libmap.c
+++ libexec/rtld-elf/libmap.c
@@ -16,15 +16,7 @@
#include "debug.h"
#include "rtld.h"
#include "libmap.h"
-
-#ifndef _PATH_LIBMAP_CONF
-#define _PATH_LIBMAP_CONF "/etc/libmap.conf"
-#endif
-
-#ifdef COMPAT_32BIT
-#undef _PATH_LIBMAP_CONF
-#define _PATH_LIBMAP_CONF "/etc/libmap32.conf"
-#endif
+#include "paths.h"
TAILQ_HEAD(lm_list, lm);
struct lm {
@@ -76,7 +68,7 @@
dbg("lm_init(\"%s\")", libmap_override);
TAILQ_INIT(&lmp_head);
- lmc_parse_file(_PATH_LIBMAP_CONF);
+ lmc_parse_file(ld_path_libmap_conf);
if (libmap_override) {
/*
Index: libexec/rtld-elf/paths.h
===================================================================
--- /dev/null
+++ libexec/rtld-elf/paths.h
@@ -0,0 +1,74 @@
+/*-
+ * Copyright 1996, 1997, 1998, 1999, 2000 John D. Polstra.
+ * Copyright 2003 Alexander Kabaev <kan@FreeBSD.ORG>.
+ * Copyright 2009-2012 Konstantin Belousov <kib@FreeBSD.ORG>.
+ * Copyright 2012 John Marino <draco@marino.st>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef PATHS_H
+#define PATHS_H
+
+#ifdef COMPAT_32BIT
+#define _PATH_ELF_HINTS "/var/run/ld-elf32.so.hints"
+#define _PATH_LIBMAP_CONF "/etc/libmap32.conf"
+#define _PATH_RTLD "/libexec/ld-elf32.so.1"
+#define STANDARD_LIBRARY_PATH "/lib32:/usr/lib32"
+#define LD_ "LD_32_"
+#endif
+
+#ifndef _PATH_ELF_HINTS
+#define _PATH_ELF_HINTS "/var/run/ld-elf.so.hints"
+#endif
+
+#ifndef _PATH_LIBMAP_CONF
+#define _PATH_LIBMAP_CONF "/etc/libmap.conf"
+#endif
+
+#ifndef _PATH_RTLD
+#define _PATH_RTLD "/libexec/ld-elf.so.1"
+#endif
+
+#ifndef STANDARD_LIBRARY_PATH
+#define STANDARD_LIBRARY_PATH "/lib:/usr/lib"
+#endif
+
+#ifndef LD_
+#define LD_ "LD_"
+#endif
+
+#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-soft.so.1"
+#define SOFT_STANDARD_LIBRARY_PATH "/lib/soft:/usr/lib/soft:/lib:/usr/lib"
+#define LD_SOFT_ "LD_SOFT_"
+
+extern char *ld_path_elf_hints;
+extern char *ld_path_libmap_conf;
+extern char *ld_path_rtld;
+extern char *ld_standard_library_path;
+extern char *ld_env_prefix;
+
+#endif /* PATHS_H */
Index: libexec/rtld-elf/rtld.h
===================================================================
--- libexec/rtld-elf/rtld.h
+++ libexec/rtld-elf/rtld.h
@@ -40,22 +40,7 @@
#include "rtld_lock.h"
#include "rtld_machdep.h"
-
-#ifdef COMPAT_32BIT
-#undef STANDARD_LIBRARY_PATH
-#undef _PATH_ELF_HINTS
-#define _PATH_ELF_HINTS "/var/run/ld-elf32.so.hints"
-/* For running 32 bit binaries */
-#define STANDARD_LIBRARY_PATH "/lib32:/usr/lib32"
-#define LD_ "LD_32_"
-#endif
-
-#ifndef STANDARD_LIBRARY_PATH
-#define STANDARD_LIBRARY_PATH "/lib:/usr/lib"
-#endif
-#ifndef LD_
-#define LD_ "LD_"
-#endif
+#include "paths.h"
#define NEW(type) ((type *) xmalloc(sizeof(type)))
#define CNEW(type) ((type *) xcalloc(1, sizeof(type)))
Index: libexec/rtld-elf/rtld.c
===================================================================
--- libexec/rtld-elf/rtld.c
+++ libexec/rtld-elf/rtld.c
@@ -60,12 +60,6 @@
#include "rtld_printf.h"
#include "notes.h"
-#ifndef COMPAT_32BIT
-#define PATH_RTLD "/libexec/ld-elf.so.1"
-#else
-#define PATH_RTLD "/libexec/ld-elf32.so.1"
-#endif
-
/* Types. */
typedef void (*func_ptr_type)();
typedef void * (*path_enum_proc) (const char *path, size_t len, void *arg);
@@ -209,6 +203,10 @@
#define RTLD_IS_DYNAMIC() (&_DYNAMIC != NULL)
#endif
+#ifndef md_exec_hook
+#define md_exec_hook(x)
+#endif
+
int dlclose(void *) __exported;
char *dlerror(void) __exported;
void *dlopen(const char *, int) __exported;
@@ -260,6 +258,15 @@
bool ld_library_path_rpath = false;
/*
+ * Globals for path names, and such
+ */
+char *ld_path_elf_hints = _PATH_ELF_HINTS;
+char *ld_path_libmap_conf = _PATH_LIBMAP_CONF;
+char *ld_path_rtld = _PATH_RTLD;
+char *ld_standard_library_path = STANDARD_LIBRARY_PATH;
+char *ld_env_prefix = LD_;
+
+/*
* Fill in a DoneList with an allocation large enough to hold all of
* the currently-loaded objects. Keep this as a macro since it calls
* alloca and we want that to occur within the scope of the caller.
@@ -319,6 +326,26 @@
utrace(&ut, sizeof(ut));
}
+#ifdef md_exec_hook
+/*
+ * construct the env variable based on the type of binary that's
+ * running. Since this can only change from md_exec_hook, we do
+ * the dynamic thing only when it can be dynmaic, otherwise we
+ * use the static string-pasting method.
+ */
+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
@@ -413,7 +440,9 @@
trust = !issetugid();
- ld_bind_now = getenv(LD_ "BIND_NOW");
+ md_exec_hook(aux_info);
+
+ ld_bind_now = getenv(_LD("BIND_NOW"));
/*
* If the process is tainted, then we un-set the dangerous environment
* variables. The process will be marked as tainted until setuid(2)
@@ -421,24 +450,24 @@
* future processes to honor the potentially un-safe variables.
*/
if (!trust) {
- if (unsetenv(LD_ "PRELOAD") || unsetenv(LD_ "LIBMAP") ||
- unsetenv(LD_ "LIBRARY_PATH") || unsetenv(LD_ "LIBRARY_PATH_FDS") ||
- unsetenv(LD_ "LIBMAP_DISABLE") ||
- unsetenv(LD_ "DEBUG") || unsetenv(LD_ "ELF_HINTS_PATH") ||
- unsetenv(LD_ "LOADFLTR") || unsetenv(LD_ "LIBRARY_PATH_RPATH")) {
+ if (unsetenv(_LD("PRELOAD")) || unsetenv(_LD("LIBMAP")) ||
+ unsetenv(_LD("LIBRARY_PATH")) || unsetenv(_LD("LIBRARY_PATH_FDS")) ||
+ unsetenv(_LD("LIBMAP_DISABLE")) ||
+ unsetenv(_LD("DEBUG")) || unsetenv(_LD("ELF_HINTS_PATH")) ||
+ unsetenv(_LD("LOADFLTR")) || unsetenv(_LD("LIBRARY_PATH_RPATH"))) {
_rtld_error("environment corrupt; aborting");
rtld_die();
}
}
- ld_debug = getenv(LD_ "DEBUG");
- 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_debug = getenv(_LD("DEBUG"));
+ 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"));
if (library_path_rpath != NULL) {
if (library_path_rpath[0] == 'y' ||
library_path_rpath[0] == 'Y' ||
@@ -450,11 +479,11 @@
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 = getenv(_LD("TRACE_LOADED_OBJECTS"));
+ ld_utrace = getenv(_LD("UTRACE"));
if ((ld_elf_hints_path == NULL) || strlen(ld_elf_hints_path) == 0)
- ld_elf_hints_path = _PATH_ELF_HINTS;
+ ld_elf_hints_path = ld_path_elf_hints;
if (ld_debug != NULL && *ld_debug != '\0')
debug = 1;
@@ -588,7 +617,7 @@
exit(0);
}
- if (getenv(LD_ "DUMP_REL_PRE") != NULL) {
+ if (getenv(_LD("DUMP_REL_PRE")) != NULL) {
dump_relocations(obj_main);
exit (0);
}
@@ -616,7 +645,7 @@
if (do_copy_relocations(obj_main) == -1)
rtld_die();
- if (getenv(LD_ "DUMP_REL_POST") != NULL) {
+ if (getenv(_LD("DUMP_REL_POST")) != NULL) {
dump_relocations(obj_main);
exit (0);
}
@@ -1511,7 +1540,7 @@
(pathname = search_library_path(name, refobj->rpath)) != NULL) ||
(pathname = search_library_pathfds(name, ld_library_dirs, fdp)) != NULL ||
(pathname = search_library_path(name, gethints(false))) != NULL ||
- (pathname = search_library_path(name, STANDARD_LIBRARY_PATH)) != NULL)
+ (pathname = search_library_path(name, ld_standard_library_path)) != NULL)
return (pathname);
} else {
nodeflib = objgiven ? refobj->z_nodeflib : false;
@@ -1525,7 +1554,7 @@
(pathname = search_library_pathfds(name, ld_library_dirs, fdp)) != NULL ||
(pathname = search_library_path(name, gethints(nodeflib))) != NULL ||
(objgiven && !nodeflib &&
- (pathname = search_library_path(name, STANDARD_LIBRARY_PATH)) != NULL))
+ (pathname = search_library_path(name, ld_standard_library_path)) != NULL))
return (pathname);
}
@@ -1695,7 +1724,7 @@
hargs.request = RTLD_DI_SERINFOSIZE;
hargs.serinfo = &hmeta;
- path_enumerate(STANDARD_LIBRARY_PATH, fill_search_info, &sargs);
+ path_enumerate(ld_standard_library_path, fill_search_info, &sargs);
path_enumerate(p, fill_search_info, &hargs);
SLPinfo = xmalloc(smeta.dls_size);
@@ -1714,7 +1743,7 @@
hargs.serpath = &hintinfo->dls_serpath[0];
hargs.strspace = (char *)&hintinfo->dls_serpath[hmeta.dls_cnt];
- path_enumerate(STANDARD_LIBRARY_PATH, fill_search_info, &sargs);
+ path_enumerate(ld_standard_library_path, fill_search_info, &sargs);
path_enumerate(p, fill_search_info, &hargs);
/*
@@ -1892,7 +1921,7 @@
digest_dynamic2(&obj_rtld, dyn_rpath, dyn_soname, dyn_runpath);
/* Replace the path with a dynamically allocated copy. */
- obj_rtld.path = xstrdup(PATH_RTLD);
+ obj_rtld.path = xstrdup(ld_path_rtld);
r_debug.r_brk = r_debug_state;
r_debug.r_state = RT_CONSISTENT;
@@ -3506,7 +3535,7 @@
path_enumerate(obj->runpath, fill_search_info, &args);
path_enumerate(gethints(obj->z_nodeflib), fill_search_info, &args);
if (!obj->z_nodeflib)
- path_enumerate(STANDARD_LIBRARY_PATH, fill_search_info, &args);
+ path_enumerate(ld_standard_library_path, fill_search_info, &args);
if (request == RTLD_DI_SERINFOSIZE) {
@@ -3544,7 +3573,7 @@
args.flags = LA_SER_DEFAULT;
if (!obj->z_nodeflib &&
- path_enumerate(STANDARD_LIBRARY_PATH, fill_search_info, &args) != NULL)
+ path_enumerate(ld_standard_library_path, fill_search_info, &args) != NULL)
return (-1);
return (0);
}
@@ -4168,16 +4197,16 @@
char *fmt1, *fmt2, *fmt, *main_local, *list_containers;
int c;
- if ((main_local = getenv(LD_ "TRACE_LOADED_OBJECTS_PROGNAME")) == NULL)
+ if ((main_local = getenv(_LD("TRACE_LOADED_OBJECTS_PROGNAME"))) == NULL)
main_local = "";
- if ((fmt1 = getenv(LD_ "TRACE_LOADED_OBJECTS_FMT1")) == NULL)
+ if ((fmt1 = getenv(_LD("TRACE_LOADED_OBJECTS_FMT1"))) == NULL)
fmt1 = "\t%o => %p (%x)\n";
- if ((fmt2 = getenv(LD_ "TRACE_LOADED_OBJECTS_FMT2")) == NULL)
+ if ((fmt2 = getenv(_LD("TRACE_LOADED_OBJECTS_FMT2"))) == NULL)
fmt2 = "\t%o (%x)\n";
- list_containers = getenv(LD_ "TRACE_LOADED_OBJECTS_ALL");
+ list_containers = getenv(_LD("TRACE_LOADED_OBJECTS_ALL"));
for (; obj; obj = obj->next) {
Needed_Entry *needed;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 11, 10:21 PM (13 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31311647
Default Alt Text
D2718.id5899.diff (14 KB)
Attached To
Mode
D2718: Implement special handling of soft-float binaries.
Attached
Detach File
Event Timeline
Log In to Comment