aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glibc/glibc/0003-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch
blob: 7cba6cc3673988b76a8732386e5112d5f4ccc33a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
From c99892f2018cd7fa0f37b53e6cebec99fa036472 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 18 Mar 2015 01:51:38 +0000
Subject: [PATCH 03/25] nativesdk-glibc: Raise the size of arrays containing dl
 paths

This patch puts the dynamic loader path in the binaries, SYSTEM_DIRS strings
and lengths as well as ld.so.cache path in the dynamic loader to specific
sections in memory. The sections that contain paths have been allocated a 4096
byte section, which is the maximum path length in linux. This will allow the
relocating script to parse the ELF binary, detect the section and easily replace
the strings in a certain path.

Upstream-Status: Inappropriate [SDK specific]

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 elf/dl-cache.c             | 4 ++++
 elf/dl-load.c              | 4 ++--
 elf/interp.c               | 2 +-
 elf/ldconfig.c             | 3 +++
 elf/rtld.c                 | 5 +++--
 sysdeps/generic/dl-cache.h | 4 ----
 6 files changed, 13 insertions(+), 9 deletions(-)

Index: git/elf/dl-cache.c
===================================================================
--- git.orig/elf/dl-cache.c
+++ git/elf/dl-cache.c
@@ -132,6 +132,10 @@ do									      \
 while (0)
 
 
+const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) =
+		SYSCONFDIR "/ld.so.cache";
+
+
 int
 internal_function
 _dl_cache_libcmp (const char *p1, const char *p2)
Index: git/elf/dl-load.c
===================================================================
--- git.orig/elf/dl-load.c
+++ git/elf/dl-load.c
@@ -106,8 +106,8 @@ static size_t max_capstrlen attribute_re
 /* Get the generated information about the trusted directories.  */
 #include "trusted-dirs.h"
 
-static const char system_dirs[] = SYSTEM_DIRS;
-static const size_t system_dirs_len[] =
+static const char system_dirs[4096] __attribute__ ((section (".sysdirs"))) = SYSTEM_DIRS;
+volatile static const size_t system_dirs_len[] __attribute__ ((section (".sysdirslen"))) =
 {
   SYSTEM_DIRS_LEN
 };
Index: git/elf/interp.c
===================================================================
--- git.orig/elf/interp.c
+++ git/elf/interp.c
@@ -18,5 +18,5 @@
 
 #include <runtime-linker.h>
 
-const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp")))
+const char __invoke_dynamic_linker__[4096] __attribute__ ((section (".interp")))
   = RUNTIME_LINKER;
Index: git/elf/ldconfig.c
===================================================================
--- git.orig/elf/ldconfig.c
+++ git/elf/ldconfig.c
@@ -168,6 +168,9 @@ static struct argp argp =
   options, parse_opt, NULL, doc, NULL, more_help, NULL
 };
 
+
+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
+
 /* Check if string corresponds to an important hardware capability or
    a platform.  */
 static int
Index: git/elf/rtld.c
===================================================================
--- git.orig/elf/rtld.c
+++ git/elf/rtld.c
@@ -99,6 +99,7 @@ uintptr_t __pointer_chk_guard_local
 strong_alias (__pointer_chk_guard_local, __pointer_chk_guard)
 #endif
 
+extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
 
 /* List of auditing DSOs.  */
 static struct audit_list
@@ -873,12 +874,12 @@ of this helper program; chances are you
   --list                list all dependencies and how they are resolved\n\
   --verify              verify that given object really is a dynamically linked\n\
 			object we can handle\n\
-  --inhibit-cache       Do not use " LD_SO_CACHE "\n\
+  --inhibit-cache       Do not use %s\n\
   --library-path PATH   use given PATH instead of content of the environment\n\
 			variable LD_LIBRARY_PATH\n\
   --inhibit-rpath LIST  ignore RUNPATH and RPATH information in object names\n\
 			in LIST\n\
-  --audit LIST          use objects named in LIST as auditors\n");
+  --audit LIST          use objects named in LIST as auditors\n", LD_SO_CACHE);
 
       ++_dl_skip_args;
       --_dl_argc;
Index: git/sysdeps/generic/dl-cache.h
===================================================================
--- git.orig/sysdeps/generic/dl-cache.h
+++ git/sysdeps/generic/dl-cache.h
@@ -27,10 +27,6 @@
   ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
 #endif
 
-#ifndef LD_SO_CACHE
-# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
-#endif
-
 #ifndef add_system_dir
 # define add_system_dir(dir) add_dir (dir)
 #endif
Index: git/iconv/gconv_conf.c
===================================================================
--- git.orig/iconv/gconv_conf.c
+++ git/iconv/gconv_conf.c
@@ -36,7 +36,7 @@
 
 
 /* This is the default path where we look for module lists.  */
-static const char default_gconv_path[] = GCONV_PATH;
+static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH;
 
 /* The path elements, as determined by the __gconv_get_path function.
    All path elements end in a slash.  */
Index: git/locale/findlocale.c
===================================================================
--- git.orig/locale/findlocale.c
+++ git/locale/findlocale.c
@@ -56,7 +56,7 @@ struct __locale_data *const _nl_C[] attr
    which are somehow addressed.  */
 struct loaded_l10nfile *_nl_locale_file_list[__LC_LAST];
 
-const char _nl_default_locale_path[] attribute_hidden = COMPLOCALEDIR;
+char _nl_default_locale_path[4096] __attribute__ ((section (".gccrelocprefix"))) attribute_hidden = COMPLOCALEDIR;
 
 /* Checks if the name is actually present, that is, not NULL and not
    empty.  */
@@ -168,7 +168,7 @@ _nl_find_locale (const char *locale_path
 
       /* Nothing in the archive.  Set the default path to search below.  */
       locale_path = _nl_default_locale_path;
-      locale_path_len = sizeof _nl_default_locale_path;
+      locale_path_len = strlen(_nl_default_locale_path) + 1;
     }
   else
     /* We really have to load some data.  First see whether the name is
Index: git/locale/localeinfo.h
===================================================================
--- git.orig/locale/localeinfo.h
+++ git/locale/localeinfo.h
@@ -322,7 +322,7 @@ _nl_lookup_word (locale_t l, int categor
 }
 
 /* Default search path if no LOCPATH environment variable.  */
-extern const char _nl_default_locale_path[] attribute_hidden;
+extern char _nl_default_locale_path[] attribute_hidden;
 
 /* Load the locale data for CATEGORY from the file specified by *NAME.
    If *NAME is "", use environment variables as specified by POSIX, and