0005-nativesdk-glibc-Raise-the-size-of-arrays-containing-.patch 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. From 2d41508ed1059df2df9994d35d870be2005f575f 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] nativesdk-glibc: Raise the size of arrays containing dl paths
  5. This patch puts the dynamic loader path in the binaries, SYSTEM_DIRS strings
  6. and lengths as well as ld.so.cache path in the dynamic loader to specific
  7. sections in memory. The sections that contain paths have been allocated a 4096
  8. byte section, which is the maximum path length in linux. This will allow the
  9. relocating script to parse the ELF binary, detect the section and easily replace
  10. the strings in a certain path.
  11. Upstream-Status: Inappropriate [SDK specific]
  12. Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
  13. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  14. ---
  15. elf/dl-cache.c | 4 ++++
  16. elf/dl-load.c | 4 ++--
  17. elf/dl-usage.c | 6 ++++--
  18. elf/interp.c | 2 +-
  19. elf/ldconfig.c | 3 +++
  20. elf/rtld.c | 1 +
  21. iconv/gconv_conf.c | 2 +-
  22. sysdeps/generic/dl-cache.h | 4 ----
  23. 8 files changed, 16 insertions(+), 10 deletions(-)
  24. diff --git a/elf/dl-cache.c b/elf/dl-cache.c
  25. index 8bbf110d02..c02a95d9b5 100644
  26. --- a/elf/dl-cache.c
  27. +++ b/elf/dl-cache.c
  28. @@ -352,6 +352,10 @@ search_cache (const char *string_table, uint32_t string_table_size,
  29. return best;
  30. }
  31. +const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache"))) =
  32. + SYSCONFDIR "/ld.so.cache";
  33. +
  34. +
  35. int
  36. _dl_cache_libcmp (const char *p1, const char *p2)
  37. {
  38. diff --git a/elf/dl-load.c b/elf/dl-load.c
  39. index ce3cbfa3c4..e116db24a1 100644
  40. --- a/elf/dl-load.c
  41. +++ b/elf/dl-load.c
  42. @@ -117,8 +117,8 @@ enum { ncapstr = 1, max_capstrlen = 0 };
  43. gen-trusted-dirs.awk. */
  44. #include "trusted-dirs.h"
  45. -static const char system_dirs[] = SYSTEM_DIRS;
  46. -static const size_t system_dirs_len[] =
  47. +static const char system_dirs[4096] __attribute__ ((section (".sysdirs"))) = SYSTEM_DIRS;
  48. +volatile static const size_t system_dirs_len[] __attribute__ ((section (".sysdirslen"))) =
  49. {
  50. SYSTEM_DIRS_LEN
  51. };
  52. diff --git a/elf/dl-usage.c b/elf/dl-usage.c
  53. index 98d8c98948..77ca98cbf9 100644
  54. --- a/elf/dl-usage.c
  55. +++ b/elf/dl-usage.c
  56. @@ -25,6 +25,8 @@
  57. #include <dl-procinfo.h>
  58. #include <dl-hwcaps.h>
  59. +extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
  60. +
  61. void
  62. _dl_usage (const char *argv0, const char *wrong_option)
  63. {
  64. @@ -244,7 +246,7 @@ setting environment variables (which would be inherited by subprocesses).\n\
  65. --list list all dependencies and how they are resolved\n\
  66. --verify verify that given object really is a dynamically linked\n\
  67. object we can handle\n\
  68. - --inhibit-cache Do not use " LD_SO_CACHE "\n\
  69. + --inhibit-cache Do not use %s\n\
  70. --library-path PATH use given PATH instead of content of the environment\n\
  71. variable LD_LIBRARY_PATH\n\
  72. --glibc-hwcaps-prepend LIST\n\
  73. @@ -267,7 +269,7 @@ setting environment variables (which would be inherited by subprocesses).\n\
  74. \n\
  75. This program interpreter self-identifies as: " RTLD "\n\
  76. ",
  77. - argv0);
  78. + argv0, LD_SO_CACHE);
  79. print_search_path_for_help (state);
  80. print_hwcaps_subdirectories (state);
  81. print_legacy_hwcap_directories ();
  82. diff --git a/elf/interp.c b/elf/interp.c
  83. index d82af036d1..9d282b2769 100644
  84. --- a/elf/interp.c
  85. +++ b/elf/interp.c
  86. @@ -18,5 +18,5 @@
  87. #include <runtime-linker.h>
  88. -const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp")))
  89. +const char __invoke_dynamic_linker__[4096] __attribute__ ((section (".interp")))
  90. = RUNTIME_LINKER;
  91. diff --git a/elf/ldconfig.c b/elf/ldconfig.c
  92. index 9394ac6438..7f66b1a460 100644
  93. --- a/elf/ldconfig.c
  94. +++ b/elf/ldconfig.c
  95. @@ -176,6 +176,9 @@ static struct argp argp =
  96. options, parse_opt, NULL, doc, NULL, more_help, NULL
  97. };
  98. +
  99. +extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
  100. +
  101. /* Check if string corresponds to an important hardware capability or
  102. a platform. */
  103. static int
  104. diff --git a/elf/rtld.c b/elf/rtld.c
  105. index cbbaf4a331..d2d27a0127 100644
  106. --- a/elf/rtld.c
  107. +++ b/elf/rtld.c
  108. @@ -189,6 +189,7 @@ dso_name_valid_for_suid (const char *p)
  109. }
  110. return *p != '\0';
  111. }
  112. +extern const char LD_SO_CACHE[4096] __attribute__ ((section (".ldsocache")));
  113. static void
  114. audit_list_init (struct audit_list *list)
  115. diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
  116. index f069e28323..6288f715ba 100644
  117. --- a/iconv/gconv_conf.c
  118. +++ b/iconv/gconv_conf.c
  119. @@ -35,7 +35,7 @@
  120. #include <gconv_parseconfdir.h>
  121. /* This is the default path where we look for module lists. */
  122. -static const char default_gconv_path[] = GCONV_PATH;
  123. +static char default_gconv_path[4096] __attribute__ ((section (".gccrelocprefix"))) = GCONV_PATH;
  124. /* Type to represent search path. */
  125. struct path_elem
  126. diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
  127. index 93d4bea930..5249176441 100644
  128. --- a/sysdeps/generic/dl-cache.h
  129. +++ b/sysdeps/generic/dl-cache.h
  130. @@ -34,10 +34,6 @@
  131. ((flags) == 1 || (flags) == _DL_CACHE_DEFAULT_ID)
  132. #endif
  133. -#ifndef LD_SO_CACHE
  134. -# define LD_SO_CACHE SYSCONFDIR "/ld.so.cache"
  135. -#endif
  136. -
  137. #ifndef add_system_dir
  138. # define add_system_dir(dir) add_dir (dir)
  139. #endif