blob: 48f5a787166dd42ee87ad6609e7b29cab706b2e3 [file] [log] [blame]
Brad Bishop08902b02019-08-20 09:16:51 -04001From 3aceb84e2bc0f796204fe059beede91179b1bc6e 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 Bishop08902b02019-08-20 09:16:51 -04004Subject: [PATCH 03/28] nativesdk-glibc: Raise the size of arrays containing dl
Brad Bishop19323692019-04-05 15:28:33 -04005 paths
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006
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 Bishop19323692019-04-05 15:28:33 -040029index d8d1e2344e..d2247bfc4f 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 Bishop08902b02019-08-20 09:16:51 -040044index c7a0fa58cb..4b87505d45 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045--- a/elf/dl-load.c
46+++ b/elf/dl-load.c
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080047@@ -110,8 +110,8 @@ static size_t max_capstrlen attribute_relro;
Brad Bishop316dfdd2018-06-25 12:45:53 -040048 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 Bishop19323692019-04-05 15:28:33 -040059index 243829f5f7..0e74241703 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 Bishop08902b02019-08-20 09:16:51 -040070index 3bc9e61891..6a23096435 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 Bishop08902b02019-08-20 09:16:51 -040084index c9490ff694..3962373ebb 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050085--- a/elf/rtld.c
86+++ b/elf/rtld.c
Brad Bishop08902b02019-08-20 09:16:51 -040087@@ -173,6 +173,7 @@ dso_name_valid_for_suid (const char *p)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050088 }
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 Bishop08902b02019-08-20 09:16:51 -040095@@ -1220,13 +1221,13 @@ 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\
Brad Bishop08902b02019-08-20 09:16:51 -0400105 --audit LIST use objects named in LIST as auditors\n\
106- --preload LIST preload objects named in LIST\n");
107+ --preload LIST preload objects named in LIST\n", LD_SO_CACHE);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108
109 ++_dl_skip_args;
110 --_dl_argc;
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500111diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
Brad Bishop19323692019-04-05 15:28:33 -0400112index ae8937cba0..f321ee419e 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500113--- a/iconv/gconv_conf.c
114+++ b/iconv/gconv_conf.c
115@@ -36,7 +36,7 @@
116
117
118 /* This is the default path where we look for module lists. */
119-static const char default_gconv_path[] = GCONV_PATH;
120+static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH;
121
Brad Bishop19323692019-04-05 15:28:33 -0400122 /* Type to represent search path. */
123 struct path_elem
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500124diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
Brad Bishop19323692019-04-05 15:28:33 -0400125index bc8b40331d..b0fdd2144b 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500126--- a/sysdeps/generic/dl-cache.h
127+++ b/sysdeps/generic/dl-cache.h
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128@@ -27,10 +27,6 @@
129 ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
130 #endif
131
132-#ifndef LD_SO_CACHE
133-# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
134-#endif
135-
136 #ifndef add_system_dir
137 # define add_system_dir(dir) add_dir (dir)
138 #endif
Brad Bishop19323692019-04-05 15:28:33 -0400139--
Brad Bishop08902b02019-08-20 09:16:51 -04001402.22.0
Brad Bishop19323692019-04-05 15:28:33 -0400141