|
|
446cf2 |
commit 56f8d442942ee51824b4683be83f776a811a3f2a
|
|
|
446cf2 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
446cf2 |
Date: Wed Oct 7 16:40:23 2020 +0200
|
|
|
446cf2 |
|
|
|
446cf2 |
elf: Do not search HWCAP subdirectories in statically linked binaries
|
|
|
446cf2 |
|
|
|
446cf2 |
This functionality does not seem to be useful since static dlopen
|
|
|
446cf2 |
is mostly used for iconv/character set conversion and NSS support.
|
|
|
446cf2 |
gconv modules are loaded with full paths anyway, so that the
|
|
|
446cf2 |
HWCAP subdirectory logic does not apply.
|
|
|
446cf2 |
|
|
|
446cf2 |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
446cf2 |
|
|
|
446cf2 |
diff --git a/elf/Makefile b/elf/Makefile
|
|
|
446cf2 |
index 837a070c267527e1..ef655630d50b07aa 100644
|
|
|
446cf2 |
--- a/elf/Makefile
|
|
|
446cf2 |
+++ b/elf/Makefile
|
|
|
446cf2 |
@@ -29,7 +29,7 @@ routines = $(all-dl-routines) dl-support dl-iteratephdr \
|
|
|
446cf2 |
|
|
|
446cf2 |
# The core dynamic linking functions are in libc for the static and
|
|
|
446cf2 |
# profiled libraries.
|
|
|
446cf2 |
-dl-routines = $(addprefix dl-,load lookup object reloc deps hwcaps \
|
|
|
446cf2 |
+dl-routines = $(addprefix dl-,load lookup object reloc deps \
|
|
|
446cf2 |
runtime init fini debug misc \
|
|
|
446cf2 |
version profile tls origin scope \
|
|
|
446cf2 |
execstack open close trampoline \
|
|
|
446cf2 |
@@ -59,7 +59,7 @@ elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin \
|
|
|
446cf2 |
# ld.so uses those routines, plus some special stuff for being the program
|
|
|
446cf2 |
# interpreter and operating independent of libc.
|
|
|
446cf2 |
rtld-routines = rtld $(all-dl-routines) dl-sysdep dl-environ dl-minimal \
|
|
|
446cf2 |
- dl-error-minimal dl-conflict
|
|
|
446cf2 |
+ dl-error-minimal dl-conflict dl-hwcaps
|
|
|
446cf2 |
all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
|
|
|
446cf2 |
|
|
|
446cf2 |
CFLAGS-dl-runtime.c += -fexceptions -fasynchronous-unwind-tables
|
|
|
446cf2 |
diff --git a/elf/dl-load.c b/elf/dl-load.c
|
|
|
446cf2 |
index 64da5323d0e368c1..2b4dd9a0f3e27b70 100644
|
|
|
446cf2 |
--- a/elf/dl-load.c
|
|
|
446cf2 |
+++ b/elf/dl-load.c
|
|
|
446cf2 |
@@ -101,9 +101,13 @@ int __stack_prot attribute_hidden attribute_relro
|
|
|
446cf2 |
static struct r_search_path_struct env_path_list attribute_relro;
|
|
|
446cf2 |
|
|
|
446cf2 |
/* List of the hardware capabilities we might end up using. */
|
|
|
446cf2 |
+#ifdef SHARED
|
|
|
446cf2 |
static const struct r_strlenpair *capstr attribute_relro;
|
|
|
446cf2 |
static size_t ncapstr attribute_relro;
|
|
|
446cf2 |
static size_t max_capstrlen attribute_relro;
|
|
|
446cf2 |
+#else
|
|
|
446cf2 |
+enum { ncapstr = 1, max_capstrlen = 0 };
|
|
|
446cf2 |
+#endif
|
|
|
446cf2 |
|
|
|
446cf2 |
|
|
|
446cf2 |
/* Get the generated information about the trusted directories. Use
|
|
|
446cf2 |
@@ -691,9 +695,11 @@ _dl_init_paths (const char *llp)
|
|
|
446cf2 |
/* Fill in the information about the application's RPATH and the
|
|
|
446cf2 |
directories addressed by the LD_LIBRARY_PATH environment variable. */
|
|
|
446cf2 |
|
|
|
446cf2 |
+#ifdef SHARED
|
|
|
446cf2 |
/* Get the capabilities. */
|
|
|
446cf2 |
capstr = _dl_important_hwcaps (GLRO(dl_platform), GLRO(dl_platformlen),
|
|
|
446cf2 |
&ncapstr, &max_capstrlen);
|
|
|
446cf2 |
+#endif
|
|
|
446cf2 |
|
|
|
446cf2 |
/* First set up the rest of the default search directory entries. */
|
|
|
446cf2 |
aelem = rtld_search_dirs.dirs = (struct r_search_path_elem **)
|
|
|
446cf2 |
@@ -1459,11 +1465,15 @@ print_search_path (struct r_search_path_elem **list,
|
|
|
446cf2 |
for (cnt = 0; cnt < ncapstr; ++cnt)
|
|
|
446cf2 |
if ((*list)->status[cnt] != nonexisting)
|
|
|
446cf2 |
{
|
|
|
446cf2 |
+#ifdef SHARED
|
|
|
446cf2 |
char *cp = __mempcpy (endp, capstr[cnt].str, capstr[cnt].len);
|
|
|
446cf2 |
if (cp == buf || (cp == buf + 1 && buf[0] == '/'))
|
|
|
446cf2 |
cp[0] = '\0';
|
|
|
446cf2 |
else
|
|
|
446cf2 |
cp[-1] = '\0';
|
|
|
446cf2 |
+#else
|
|
|
446cf2 |
+ *endp = '\0';
|
|
|
446cf2 |
+#endif
|
|
|
446cf2 |
|
|
|
446cf2 |
_dl_debug_printf_c (first ? "%s" : ":%s", buf);
|
|
|
446cf2 |
first = 0;
|
|
|
446cf2 |
@@ -1836,11 +1846,15 @@ open_path (const char *name, size_t namelen, int mode,
|
|
|
446cf2 |
if (this_dir->status[cnt] == nonexisting)
|
|
|
446cf2 |
continue;
|
|
|
446cf2 |
|
|
|
446cf2 |
+#ifdef SHARED
|
|
|
446cf2 |
buflen =
|
|
|
446cf2 |
((char *) __mempcpy (__mempcpy (edp, capstr[cnt].str,
|
|
|
446cf2 |
capstr[cnt].len),
|
|
|
446cf2 |
name, namelen)
|
|
|
446cf2 |
- buf);
|
|
|
446cf2 |
+#else
|
|
|
446cf2 |
+ buflen = (char *) __mempcpy (edp, name, namelen) - buf;
|
|
|
446cf2 |
+#endif
|
|
|
446cf2 |
|
|
|
446cf2 |
/* Print name we try if this is wanted. */
|
|
|
446cf2 |
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
|