blob: 086e0c6f1431c3da512cc504174c7abd67997428 [file] [log] [blame]
From e874dacbfdb06520240887e9077c58006ee33f87 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 18 Mar 2015 01:51:38 +0000
Subject: [PATCH] nativesdk-glibc: Raise the size of arrays containing dl paths
This patch puts the dynamic loader path in the binaries, SYSTEM_DIRS strings
and lengths as well as ld.so.cache path in the dynamic loader to specific
sections in memory. The sections that contain paths have been allocated a 4096
byte section, which is the maximum path length in linux. This will allow the
relocating script to parse the ELF binary, detect the section and easily replace
the strings in a certain path.
Upstream-Status: Inappropriate [SDK specific]
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
elf/dl-cache.c | 4 ++++
elf/dl-load.c | 4 ++--
elf/dl-usage.c | 6 ++++--
elf/interp.c | 2 +-
elf/ldconfig.c | 2 ++
elf/rtld.c | 1 +
iconv/gconv_conf.c | 2 +-
sysdeps/generic/dl-cache.h | 4 ----
8 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/elf/dl-cache.c b/elf/dl-cache.c
index 804bf23222..d99501c389 100644
--- a/elf/dl-cache.c
+++ b/elf/dl-cache.c
@@ -352,6 +352,10 @@ search_cache (const char *string_table, uint32_t string_table_size,
return best;
}
+const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) =
+ SYSCONFDIR "/ld.so.cache";
+
+
int
_dl_cache_libcmp (const char *p1, const char *p2)
{
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 3a23dc618c..563e703096 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -117,8 +117,8 @@ enum { ncapstr = 1, max_capstrlen = 0 };
gen-trusted-dirs.awk. */
#include "trusted-dirs.h"
-static const char system_dirs[] = SYSTEM_DIRS;
-static const size_t system_dirs_len[] =
+static const char system_dirs[4096] __attribute__ ((section (".sysdirs"))) = SYSTEM_DIRS;
+volatile static const size_t system_dirs_len[] __attribute__ ((section (".sysdirslen"))) =
{
SYSTEM_DIRS_LEN
};
diff --git a/elf/dl-usage.c b/elf/dl-usage.c
index 98f0b0d027..ab4f76e1fe 100644
--- a/elf/dl-usage.c
+++ b/elf/dl-usage.c
@@ -25,6 +25,8 @@
#include <dl-procinfo.h>
#include <dl-hwcaps.h>
+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
+
void
_dl_usage (const char *argv0, const char *wrong_option)
{
@@ -184,7 +186,7 @@ setting environment variables (which would be inherited by subprocesses).\n\
--list list all dependencies and how they are resolved\n\
--verify verify that given object really is a dynamically linked\n\
object we can handle\n\
- --inhibit-cache Do not use " LD_SO_CACHE "\n\
+ --inhibit-cache Do not use %s\n\
--library-path PATH use given PATH instead of content of the environment\n\
variable LD_LIBRARY_PATH\n\
--glibc-hwcaps-prepend LIST\n\
@@ -203,7 +205,7 @@ setting environment variables (which would be inherited by subprocesses).\n\
\n\
This program interpreter self-identifies as: " RTLD "\n\
",
- argv0);
+ argv0, LD_SO_CACHE);
print_search_path_for_help (state);
print_hwcaps_subdirectories (state);
_exit (EXIT_SUCCESS);
diff --git a/elf/interp.c b/elf/interp.c
index ae21ae0cb3..b168e6da66 100644
--- a/elf/interp.c
+++ b/elf/interp.c
@@ -18,5 +18,5 @@
#include <runtime-linker.h>
-const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp")))
+const char __invoke_dynamic_linker__[4096] __attribute__ ((section (".interp")))
= RUNTIME_LINKER;
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index d26eef1fb4..e5af6e5c01 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -150,6 +150,8 @@ static struct argp argp =
options, parse_opt, NULL, doc, NULL, more_help, NULL
};
+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
+
/* Handle program arguments. */
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
diff --git a/elf/rtld.c b/elf/rtld.c
index a91e2a4471..56d816d4d9 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -190,6 +190,7 @@ dso_name_valid_for_suid (const char *p)
}
return *p != '\0';
}
+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
static void
audit_list_init (struct audit_list *list)
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index ee9e97e1bd..01a99382d0 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -35,7 +35,7 @@
#include <gconv_parseconfdir.h>
/* This is the default path where we look for module lists. */
-static const char default_gconv_path[] = GCONV_PATH;
+static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH;
/* Type to represent search path. */
struct path_elem
diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
index bd39ff7fb7..38f9e2ad57 100644
--- a/sysdeps/generic/dl-cache.h
+++ b/sysdeps/generic/dl-cache.h
@@ -34,10 +34,6 @@
((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
#endif
-#ifndef LD_SO_CACHE
-# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
-#endif
-
#ifndef add_system_dir
# define add_system_dir(dir) add_dir (dir)
#endif