Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From fd595a5ec885bcb4c14417daa21c2e61c5b72e42 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 18 Mar 2015 01:51:38 +0000 |
| 4 | Subject: [PATCH 03/27] nativesdk-glibc: Raise the size of arrays containing dl |
| 5 | paths |
| 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 | sysdeps/generic/dl-cache.h | 4 ---- |
| 25 | 6 files changed, 13 insertions(+), 9 deletions(-) |
| 26 | |
| 27 | diff --git a/elf/dl-cache.c b/elf/dl-cache.c |
| 28 | index 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) |
| 42 | diff --git a/elf/dl-load.c b/elf/dl-load.c |
| 43 | index f1eb5ed..f664f50 100644 |
| 44 | --- a/elf/dl-load.c |
| 45 | +++ b/elf/dl-load.c |
| 46 | @@ -104,8 +104,8 @@ static size_t max_capstrlen attribute_relro; |
| 47 | /* 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 | }; |
| 57 | diff --git a/elf/interp.c b/elf/interp.c |
| 58 | index 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; |
| 68 | diff --git a/elf/ldconfig.c b/elf/ldconfig.c |
| 69 | index 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 |
| 82 | diff --git a/elf/rtld.c b/elf/rtld.c |
| 83 | index 69873c2..6d3add7 100644 |
| 84 | --- 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 |
| 94 | @@ -877,12 +878,12 @@ of this helper program; chances are you did not intend to run this program.\n\ |
| 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; |
| 109 | diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h |
| 110 | index 4b49869..1800d03 100644 |
| 111 | --- 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 |
| 124 | -- |
| 125 | 2.1.4 |
| 126 | |