blob: 2073576aac42c73dfb7a0f4dedc34bf5589a9f24 [file] [log] [blame]
Andrew Geissler635e0e42020-08-21 15:58:33 -05001From 19cd858f5f04a6ac584fbd89a2fbc51791263b85 Mon Sep 17 00:00:00 2001
Andrew Geissler82c905d2020-04-13 13:39:40 -05002From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 18 Mar 2015 01:51:38 +0000
Andrew Geissler635e0e42020-08-21 15:58:33 -05004Subject: [PATCH 05/29] nativesdk-glibc: Raise the size of arrays containing dl
5 paths
Andrew Geissler82c905d2020-04-13 13:39:40 -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 +++--
24 iconv/gconv_conf.c | 2 +-
25 sysdeps/generic/dl-cache.h | 4 ----
26 7 files changed, 14 insertions(+), 10 deletions(-)
27
28diff --git a/elf/dl-cache.c b/elf/dl-cache.c
Andrew Geissler635e0e42020-08-21 15:58:33 -050029index 93d185e788..e115b18756 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050030--- a/elf/dl-cache.c
31+++ b/elf/dl-cache.c
32@@ -133,6 +133,10 @@ do \
33 while (0)
34
35
36+const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) =
37+ SYSCONFDIR "/ld.so.cache";
38+
39+
40 int
41 _dl_cache_libcmp (const char *p1, const char *p2)
42 {
43diff --git a/elf/dl-load.c b/elf/dl-load.c
Andrew Geissler635e0e42020-08-21 15:58:33 -050044index e1b3486549..5226d0c4fa 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050045--- a/elf/dl-load.c
46+++ b/elf/dl-load.c
Andrew Geissler635e0e42020-08-21 15:58:33 -050047@@ -111,8 +111,8 @@ static size_t max_capstrlen attribute_relro;
Andrew Geissler82c905d2020-04-13 13:39:40 -050048 gen-trusted-dirs.awk. */
49 #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 };
58diff --git a/elf/interp.c b/elf/interp.c
59index 331cc1df48..885b2d9476 100644
60--- a/elf/interp.c
61+++ b/elf/interp.c
62@@ -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;
69diff --git a/elf/ldconfig.c b/elf/ldconfig.c
Andrew Geissler635e0e42020-08-21 15:58:33 -050070index 0c090dca15..6bb6e0fe72 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050071--- a/elf/ldconfig.c
72+++ b/elf/ldconfig.c
Andrew Geissler635e0e42020-08-21 15:58:33 -050073@@ -171,6 +171,9 @@ static struct argp argp =
Andrew Geissler82c905d2020-04-13 13:39:40 -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
83diff --git a/elf/rtld.c b/elf/rtld.c
Andrew Geissler635e0e42020-08-21 15:58:33 -050084index 5b882163fa..db407b5d8b 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050085--- a/elf/rtld.c
86+++ b/elf/rtld.c
Andrew Geissler635e0e42020-08-21 15:58:33 -050087@@ -217,6 +217,7 @@ dso_name_valid_for_suid (const char *p)
Andrew Geissler82c905d2020-04-13 13:39:40 -050088 }
89 return *p != '\0';
90 }
91+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
92
Andrew Geissler635e0e42020-08-21 15:58:33 -050093 static void
94 audit_list_init (struct audit_list *list)
95@@ -1286,13 +1287,13 @@ of this helper program; chances are you did not intend to run this program.\n\
Andrew Geissler82c905d2020-04-13 13:39:40 -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- --preload LIST preload objects named in LIST\n");
107+ --preload LIST preload objects named in LIST\n", LD_SO_CACHE);
108
109 ++_dl_skip_args;
110 --_dl_argc;
111diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
112index 735bd1f2d5..25100ba666 100644
113--- 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
122 /* Type to represent search path. */
123 struct path_elem
124diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
125index 6b310e9e15..3877311df4 100644
126--- a/sysdeps/generic/dl-cache.h
127+++ b/sysdeps/generic/dl-cache.h
128@@ -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
Andrew Geissler635e0e42020-08-21 15:58:33 -0500139--
1402.27.0
141