Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 055dd46b793168fb08e44913153010b088011ba2 Mon Sep 17 00:00:00 2001 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 18 Mar 2015 01:51:38 +0000 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 4 | Subject: [PATCH] nativesdk-glibc: Raise the size of arrays containing dl paths |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | |
| 6 | This patch puts the dynamic loader path in the binaries, SYSTEM_DIRS strings |
| 7 | and lengths as well as ld.so.cache path in the dynamic loader to specific |
| 8 | sections in memory. The sections that contain paths have been allocated a 4096 |
| 9 | byte section, which is the maximum path length in linux. This will allow the |
| 10 | relocating script to parse the ELF binary, detect the section and easily replace |
| 11 | the strings in a certain path. |
| 12 | |
| 13 | Upstream-Status: Inappropriate [SDK specific] |
| 14 | |
| 15 | Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> |
| 16 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 17 | --- |
| 18 | elf/dl-cache.c | 4 ++++ |
| 19 | elf/dl-load.c | 4 ++-- |
| 20 | elf/interp.c | 2 +- |
| 21 | elf/ldconfig.c | 3 +++ |
| 22 | elf/rtld.c | 5 +++-- |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 23 | iconv/gconv_conf.c | 2 +- |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | sysdeps/generic/dl-cache.h | 4 ---- |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 25 | 7 files changed, 14 insertions(+), 10 deletions(-) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 26 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 27 | diff --git a/elf/dl-cache.c b/elf/dl-cache.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 28 | index 6ee5153ff9..37a5f701fa 100644 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 29 | --- a/elf/dl-cache.c |
| 30 | +++ b/elf/dl-cache.c |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 31 | @@ -133,6 +133,10 @@ do \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | while (0) |
| 33 | |
| 34 | |
| 35 | +const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) = |
| 36 | + SYSCONFDIR "/ld.so.cache"; |
| 37 | + |
| 38 | + |
| 39 | int |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | _dl_cache_libcmp (const char *p1, const char *p2) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 41 | { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 42 | diff --git a/elf/dl-load.c b/elf/dl-load.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 43 | index 74e2e5e962..8f19186e1c 100644 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 44 | --- a/elf/dl-load.c |
| 45 | +++ b/elf/dl-load.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 46 | @@ -110,8 +110,8 @@ static size_t max_capstrlen attribute_relro; |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 47 | gen-trusted-dirs.awk. */ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | }; |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 57 | diff --git a/elf/interp.c b/elf/interp.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 58 | index 9cd50c7291..fc2f39d73c 100644 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 59 | --- a/elf/interp.c |
| 60 | +++ b/elf/interp.c |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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; |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 68 | diff --git a/elf/ldconfig.c b/elf/ldconfig.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 69 | index fbdd814edf..9f4d8d69b1 100644 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 70 | --- a/elf/ldconfig.c |
| 71 | +++ b/elf/ldconfig.c |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 72 | @@ -168,6 +168,9 @@ static struct argp argp = |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 82 | diff --git a/elf/rtld.c b/elf/rtld.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 83 | index 1b0c74739f..a70a62d31e 100644 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 84 | --- a/elf/rtld.c |
| 85 | +++ b/elf/rtld.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 86 | @@ -130,6 +130,7 @@ dso_name_valid_for_suid (const char *p) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 87 | } |
| 88 | return *p != '\0'; |
| 89 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | +extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))); |
| 91 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 92 | /* LD_AUDIT variable contents. Must be processed before the |
| 93 | audit_list below. */ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 94 | @@ -1001,12 +1002,12 @@ of this helper program; chances are you did not intend to run this program.\n\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | --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; |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 109 | diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 110 | index f173cde71b..5c3205026f 100644 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 111 | --- a/iconv/gconv_conf.c |
| 112 | +++ b/iconv/gconv_conf.c |
| 113 | @@ -36,7 +36,7 @@ |
| 114 | |
| 115 | |
| 116 | /* This is the default path where we look for module lists. */ |
| 117 | -static const char default_gconv_path[] = GCONV_PATH; |
| 118 | +static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH; |
| 119 | |
| 120 | /* The path elements, as determined by the __gconv_get_path function. |
| 121 | All path elements end in a slash. */ |
| 122 | diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 123 | index cf43f1cf3b..7f07adde53 100644 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 124 | --- a/sysdeps/generic/dl-cache.h |
| 125 | +++ b/sysdeps/generic/dl-cache.h |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 126 | @@ -27,10 +27,6 @@ |
| 127 | ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID) |
| 128 | #endif |
| 129 | |
| 130 | -#ifndef LD_SO_CACHE |
| 131 | -# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache" |
| 132 | -#endif |
| 133 | - |
| 134 | #ifndef add_system_dir |
| 135 | # define add_system_dir(dir) add_dir (dir) |
| 136 | #endif |