Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 1 | From 19cd858f5f04a6ac584fbd89a2fbc51791263b85 Mon Sep 17 00:00:00 2001 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 18 Mar 2015 01:51:38 +0000 |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 4 | Subject: [PATCH 05/29] nativesdk-glibc: Raise the size of arrays containing dl |
| 5 | paths |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 6 | |
| 7 | This patch puts the dynamic loader path in the binaries, SYSTEM_DIRS strings |
| 8 | and lengths as well as ld.so.cache path in the dynamic loader to specific |
| 9 | sections in memory. The sections that contain paths have been allocated a 4096 |
| 10 | byte section, which is the maximum path length in linux. This will allow the |
| 11 | relocating script to parse the ELF binary, detect the section and easily replace |
| 12 | the strings in a certain path. |
| 13 | |
| 14 | Upstream-Status: Inappropriate [SDK specific] |
| 15 | |
| 16 | Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> |
| 17 | Signed-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 | |
| 28 | diff --git a/elf/dl-cache.c b/elf/dl-cache.c |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 29 | index 93d185e788..e115b18756 100644 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 30 | --- 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 | { |
| 43 | diff --git a/elf/dl-load.c b/elf/dl-load.c |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 44 | index e1b3486549..5226d0c4fa 100644 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 45 | --- a/elf/dl-load.c |
| 46 | +++ b/elf/dl-load.c |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 47 | @@ -111,8 +111,8 @@ static size_t max_capstrlen attribute_relro; |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 48 | 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 | }; |
| 58 | diff --git a/elf/interp.c b/elf/interp.c |
| 59 | index 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; |
| 69 | diff --git a/elf/ldconfig.c b/elf/ldconfig.c |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 70 | index 0c090dca15..6bb6e0fe72 100644 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 71 | --- a/elf/ldconfig.c |
| 72 | +++ b/elf/ldconfig.c |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 73 | @@ -171,6 +171,9 @@ static struct argp argp = |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 74 | 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 |
| 83 | diff --git a/elf/rtld.c b/elf/rtld.c |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 84 | index 5b882163fa..db407b5d8b 100644 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 85 | --- a/elf/rtld.c |
| 86 | +++ b/elf/rtld.c |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 87 | @@ -217,6 +217,7 @@ dso_name_valid_for_suid (const char *p) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 88 | } |
| 89 | return *p != '\0'; |
| 90 | } |
| 91 | +extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); |
| 92 | |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 93 | 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 96 | --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; |
| 111 | diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c |
| 112 | index 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 |
| 124 | diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h |
| 125 | index 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 Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame^] | 139 | -- |
| 140 | 2.27.0 |
| 141 | |