blob: e082540303b57bf579d5c515ad4d9ee531d5bdd3 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 055dd46b793168fb08e44913153010b088011ba2 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 Bishop1a4b7ee2018-12-16 17:11:34 -08004Subject: [PATCH] nativesdk-glibc: Raise the size of arrays containing dl paths
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005
6This patch puts the dynamic loader path in the binaries, SYSTEM_DIRS strings
7and lengths as well as ld.so.cache path in the dynamic loader to specific
8sections in memory. The sections that contain paths have been allocated a 4096
9byte section, which is the maximum path length in linux. This will allow the
10relocating script to parse the ELF binary, detect the section and easily replace
11the strings in a certain path.
12
13Upstream-Status: Inappropriate [SDK specific]
14
15Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18 elf/dl-cache.c | 4 ++++
19 elf/dl-load.c | 4 ++--
20 elf/interp.c | 2 +-
21 elf/ldconfig.c | 3 +++
22 elf/rtld.c | 5 +++--
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023 iconv/gconv_conf.c | 2 +-
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 sysdeps/generic/dl-cache.h | 4 ----
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025 7 files changed, 14 insertions(+), 10 deletions(-)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026
Brad Bishop6e60e8b2018-02-01 10:27:11 -050027diff --git a/elf/dl-cache.c b/elf/dl-cache.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040028index 6ee5153ff9..37a5f701fa 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050029--- a/elf/dl-cache.c
30+++ b/elf/dl-cache.c
Brad Bishopd7bf8c12018-02-25 22:55:05 -050031@@ -133,6 +133,10 @@ do \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032 while (0)
33
34
35+const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) =
36+ SYSCONFDIR "/ld.so.cache";
37+
38+
39 int
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040 _dl_cache_libcmp (const char *p1, const char *p2)
Brad Bishop316dfdd2018-06-25 12:45:53 -040041 {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050042diff --git a/elf/dl-load.c b/elf/dl-load.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080043index 74e2e5e962..8f19186e1c 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050044--- a/elf/dl-load.c
45+++ b/elf/dl-load.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046@@ -110,8 +110,8 @@ static size_t max_capstrlen attribute_relro;
Brad Bishop316dfdd2018-06-25 12:45:53 -040047 gen-trusted-dirs.awk. */
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 #include "trusted-dirs.h"
49
50-static const char system_dirs[] = SYSTEM_DIRS;
51-static const size_t system_dirs_len[] =
52+static const char system_dirs[4096] __attribute__ ((section (".sysdirs"))) = SYSTEM_DIRS;
53+volatile static const size_t system_dirs_len[] __attribute__ ((section (".sysdirslen"))) =
54 {
55 SYSTEM_DIRS_LEN
56 };
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057diff --git a/elf/interp.c b/elf/interp.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040058index 9cd50c7291..fc2f39d73c 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050059--- a/elf/interp.c
60+++ b/elf/interp.c
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061@@ -18,5 +18,5 @@
62
63 #include <runtime-linker.h>
64
65-const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp")))
66+const char __invoke_dynamic_linker__[4096] __attribute__ ((section (".interp")))
67 = RUNTIME_LINKER;
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068diff --git a/elf/ldconfig.c b/elf/ldconfig.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040069index fbdd814edf..9f4d8d69b1 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050070--- a/elf/ldconfig.c
71+++ b/elf/ldconfig.c
Patrick Williamsc0f7c042017-02-23 20:41:17 -060072@@ -168,6 +168,9 @@ static struct argp argp =
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 options, parse_opt, NULL, doc, NULL, more_help, NULL
74 };
75
76+
77+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
78+
79 /* Check if string corresponds to an important hardware capability or
80 a platform. */
81 static int
Brad Bishop6e60e8b2018-02-01 10:27:11 -050082diff --git a/elf/rtld.c b/elf/rtld.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080083index 1b0c74739f..a70a62d31e 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050084--- a/elf/rtld.c
85+++ b/elf/rtld.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080086@@ -130,6 +130,7 @@ dso_name_valid_for_suid (const char *p)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050087 }
88 return *p != '\0';
89 }
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
91
Brad Bishopd7bf8c12018-02-25 22:55:05 -050092 /* LD_AUDIT variable contents. Must be processed before the
93 audit_list below. */
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080094@@ -1001,12 +1002,12 @@ of this helper program; chances are you did not intend to run this program.\n\
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095 --list list all dependencies and how they are resolved\n\
96 --verify verify that given object really is a dynamically linked\n\
97 object we can handle\n\
98- --inhibit-cache Do not use " LD_SO_CACHE "\n\
99+ --inhibit-cache Do not use %s\n\
100 --library-path PATH use given PATH instead of content of the environment\n\
101 variable LD_LIBRARY_PATH\n\
102 --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\
103 in LIST\n\
104- --audit LIST use objects named in LIST as auditors\n");
105+ --audit LIST use objects named in LIST as auditors\n", LD_SO_CACHE);
106
107 ++_dl_skip_args;
108 --_dl_argc;
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500109diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800110index f173cde71b..5c3205026f 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500111--- a/iconv/gconv_conf.c
112+++ b/iconv/gconv_conf.c
113@@ -36,7 +36,7 @@
114
115
116 /* This is the default path where we look for module lists. */
117-static const char default_gconv_path[] = GCONV_PATH;
118+static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH;
119
120 /* The path elements, as determined by the __gconv_get_path function.
121 All path elements end in a slash. */
122diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
Brad Bishop316dfdd2018-06-25 12:45:53 -0400123index cf43f1cf3b..7f07adde53 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500124--- a/sysdeps/generic/dl-cache.h
125+++ b/sysdeps/generic/dl-cache.h
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126@@ -27,10 +27,6 @@
127 ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
128 #endif
129
130-#ifndef LD_SO_CACHE
131-# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
132-#endif
133-
134 #ifndef add_system_dir
135 # define add_system_dir(dir) add_dir (dir)
136 #endif