blob: 60f9f17b89fe08b068256c8746a8293f1cf65934 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001From e76048898ae9aa49dc70d6f9b1bbc22082e61fe3 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
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05004Subject: [PATCH 03/24] 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 +++--
24 sysdeps/generic/dl-cache.h | 4 ----
25 6 files changed, 13 insertions(+), 9 deletions(-)
26
27diff --git a/elf/dl-cache.c b/elf/dl-cache.c
28index dec49bc..862f1d8 100644
29--- a/elf/dl-cache.c
30+++ b/elf/dl-cache.c
31@@ -132,6 +132,10 @@ do \
32 while (0)
33
34
35+const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) =
36+ SYSCONFDIR "/ld.so.cache";
37+
38+
39 int
40 internal_function
41 _dl_cache_libcmp (const char *p1, const char *p2)
42diff --git a/elf/dl-load.c b/elf/dl-load.c
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050043index c4a42e9..acf6c03 100644
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044--- a/elf/dl-load.c
45+++ b/elf/dl-load.c
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050046@@ -106,8 +106,8 @@ static size_t max_capstrlen attribute_relro;
Patrick Williamsc124f4f2015-09-15 14:41:29 -050047 /* Get the generated information about the trusted directories. */
48 #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 };
57diff --git a/elf/interp.c b/elf/interp.c
58index 422ea95e..6d61a36 100644
59--- a/elf/interp.c
60+++ b/elf/interp.c
61@@ -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;
68diff --git a/elf/ldconfig.c b/elf/ldconfig.c
69index f54ec22..0e78a83 100644
70--- a/elf/ldconfig.c
71+++ b/elf/ldconfig.c
72@@ -167,6 +167,9 @@ static struct argp argp =
73 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
82diff --git a/elf/rtld.c b/elf/rtld.c
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050083index 52160df..80f0582 100644
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084--- a/elf/rtld.c
85+++ b/elf/rtld.c
86@@ -99,6 +99,7 @@ uintptr_t __pointer_chk_guard_local
87 strong_alias (__pointer_chk_guard_local, __pointer_chk_guard)
88 #endif
89
90+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
91
92 /* List of auditing DSOs. */
93 static struct audit_list
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050094@@ -873,12 +874,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;
109diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500110index 70d4aeb..5c726d0 100644
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111--- a/sysdeps/generic/dl-cache.h
112+++ b/sysdeps/generic/dl-cache.h
113@@ -27,10 +27,6 @@
114 ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
115 #endif
116
117-#ifndef LD_SO_CACHE
118-# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
119-#endif
120-
121 #ifndef add_system_dir
122 # define add_system_dir(dir) add_dir (dir)
123 #endif
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500124Index: git/iconv/gconv_conf.c
125===================================================================
126--- git.orig/iconv/gconv_conf.c
127+++ git/iconv/gconv_conf.c
128@@ -36,7 +36,7 @@
129
130
131 /* This is the default path where we look for module lists. */
132-static const char default_gconv_path[] = GCONV_PATH;
133+static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH;
134
135 /* The path elements, as determined by the __gconv_get_path function.
136 All path elements end in a slash. */