blob: 03f99916fa6cf5e02b7862ba7288998b4b156eac [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From 695e1cbff6ee6db3435c33e55311c67adf44476d Mon Sep 17 00:00:00 2001
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 18 Mar 2015 01:51:38 +0000
Brad Bishop316dfdd2018-06-25 12:45:53 -04004Subject: [PATCH 03/27] nativesdk-glibc: Raise the size of arrays containing dl
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005 paths
6
7This patch puts the dynamic loader path in the binaries, SYSTEM_DIRS strings
8and lengths as well as ld.so.cache path in the dynamic loader to specific
9sections in memory. The sections that contain paths have been allocated a 4096
10byte section, which is the maximum path length in linux. This will allow the
11relocating script to parse the ELF binary, detect the section and easily replace
12the strings in a certain path.
13
14Upstream-Status: Inappropriate [SDK specific]
15
16Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
17Signed-off-by: Khem Raj <raj.khem@gmail.com>
18---
19 elf/dl-cache.c | 4 ++++
20 elf/dl-load.c | 4 ++--
21 elf/interp.c | 2 +-
22 elf/ldconfig.c | 3 +++
23 elf/rtld.c | 5 +++--
Brad Bishop6e60e8b2018-02-01 10:27:11 -050024 iconv/gconv_conf.c | 2 +-
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 sysdeps/generic/dl-cache.h | 4 ----
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026 7 files changed, 14 insertions(+), 10 deletions(-)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027
Brad Bishop6e60e8b2018-02-01 10:27:11 -050028diff --git a/elf/dl-cache.c b/elf/dl-cache.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040029index 6ee5153ff9..37a5f701fa 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030--- a/elf/dl-cache.c
31+++ b/elf/dl-cache.c
Brad Bishopd7bf8c12018-02-25 22:55:05 -050032@@ -133,6 +133,10 @@ do \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033 while (0)
34
35
36+const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) =
37+ SYSCONFDIR "/ld.so.cache";
38+
39+
40 int
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041 _dl_cache_libcmp (const char *p1, const char *p2)
Brad Bishop316dfdd2018-06-25 12:45:53 -040042 {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043diff --git a/elf/dl-load.c b/elf/dl-load.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040044index 62e3eee478..6ddba73650 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045--- a/elf/dl-load.c
46+++ b/elf/dl-load.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040047@@ -109,8 +109,8 @@ static size_t max_capstrlen attribute_relro;
48 gen-trusted-dirs.awk. */
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049 #include "trusted-dirs.h"
50
51-static const char system_dirs[] = SYSTEM_DIRS;
52-static const size_t system_dirs_len[] =
53+static const char system_dirs[4096] __attribute__ ((section (".sysdirs"))) = SYSTEM_DIRS;
54+volatile static const size_t system_dirs_len[] __attribute__ ((section (".sysdirslen"))) =
55 {
56 SYSTEM_DIRS_LEN
57 };
Brad Bishop6e60e8b2018-02-01 10:27:11 -050058diff --git a/elf/interp.c b/elf/interp.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040059index 9cd50c7291..fc2f39d73c 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050060--- a/elf/interp.c
61+++ b/elf/interp.c
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062@@ -18,5 +18,5 @@
63
64 #include <runtime-linker.h>
65
66-const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp")))
67+const char __invoke_dynamic_linker__[4096] __attribute__ ((section (".interp")))
68 = RUNTIME_LINKER;
Brad Bishop6e60e8b2018-02-01 10:27:11 -050069diff --git a/elf/ldconfig.c b/elf/ldconfig.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040070index fbdd814edf..9f4d8d69b1 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050071--- a/elf/ldconfig.c
72+++ b/elf/ldconfig.c
Patrick Williamsc0f7c042017-02-23 20:41:17 -060073@@ -168,6 +168,9 @@ static struct argp argp =
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 options, parse_opt, NULL, doc, NULL, more_help, NULL
75 };
76
77+
78+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
79+
80 /* Check if string corresponds to an important hardware capability or
81 a platform. */
82 static int
Brad Bishop6e60e8b2018-02-01 10:27:11 -050083diff --git a/elf/rtld.c b/elf/rtld.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040084index 453f56eb15..08e0c4c94b 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050085--- a/elf/rtld.c
86+++ b/elf/rtld.c
Brad Bishopd7bf8c12018-02-25 22:55:05 -050087@@ -128,6 +128,7 @@ dso_name_valid_for_suid (const char *p)
88 }
89 return *p != '\0';
90 }
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
92
Brad Bishopd7bf8c12018-02-25 22:55:05 -050093 /* LD_AUDIT variable contents. Must be processed before the
94 audit_list below. */
Brad Bishop316dfdd2018-06-25 12:45:53 -040095@@ -1000,12 +1001,12 @@ of this helper program; chances are you did not intend to run this program.\n\
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096 --list list all dependencies and how they are resolved\n\
97 --verify verify that given object really is a dynamically linked\n\
98 object we can handle\n\
99- --inhibit-cache Do not use " LD_SO_CACHE "\n\
100+ --inhibit-cache Do not use %s\n\
101 --library-path PATH use given PATH instead of content of the environment\n\
102 variable LD_LIBRARY_PATH\n\
103 --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\
104 in LIST\n\
105- --audit LIST use objects named in LIST as auditors\n");
106+ --audit LIST use objects named in LIST as auditors\n", LD_SO_CACHE);
107
108 ++_dl_skip_args;
109 --_dl_argc;
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500110diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
Brad Bishop316dfdd2018-06-25 12:45:53 -0400111index d6cf9d2a3e..9fcf970144 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500112--- a/iconv/gconv_conf.c
113+++ b/iconv/gconv_conf.c
114@@ -36,7 +36,7 @@
115
116
117 /* This is the default path where we look for module lists. */
118-static const char default_gconv_path[] = GCONV_PATH;
119+static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH;
120
121 /* The path elements, as determined by the __gconv_get_path function.
122 All path elements end in a slash. */
123diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
Brad Bishop316dfdd2018-06-25 12:45:53 -0400124index cf43f1cf3b..7f07adde53 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500125--- a/sysdeps/generic/dl-cache.h
126+++ b/sysdeps/generic/dl-cache.h
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500127@@ -27,10 +27,6 @@
128 ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
129 #endif
130
131-#ifndef LD_SO_CACHE
132-# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
133-#endif
134-
135 #ifndef add_system_dir
136 # define add_system_dir(dir) add_dir (dir)
137 #endif
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500138--
Brad Bishop316dfdd2018-06-25 12:45:53 -04001392.16.1
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500140