ldconfig.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. Upstream-Status: Inappropriate [embedded specific]
  2. enable standalone building of ldconfig
  3. ---
  4. cache.c | 11 +-
  5. chroot_canon.c | 7 +
  6. dl-cache.c | 235 ---------------------------------------------------------
  7. dl-cache.h | 3
  8. ldconfig.c | 27 ++++--
  9. readlib.c | 7 +
  10. xstrdup.c | 11 --
  11. 7 files changed, 45 insertions(+), 256 deletions(-)
  12. Index: ldconfig-native-2.12.1/cache.c
  13. ===================================================================
  14. --- ldconfig-native-2.12.1.orig/cache.c
  15. +++ ldconfig-native-2.12.1/cache.c
  16. @@ -16,6 +16,9 @@
  17. along with this program; if not, write to the Free Software Foundation,
  18. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  19. +#define _LARGEFILE64_SOURCE
  20. +#define _GNU_SOURCE
  21. +
  22. #include <errno.h>
  23. #include <error.h>
  24. #include <dirent.h>
  25. @@ -31,8 +34,10 @@
  26. #include <sys/stat.h>
  27. #include <sys/types.h>
  28. -#include <ldconfig.h>
  29. -#include <dl-cache.h>
  30. +#include "ldconfig.h"
  31. +#include "dl-cache.h"
  32. +# define N_(msgid) msgid
  33. +#define _(msg) msg
  34. struct cache_entry
  35. {
  36. Index: ldconfig-native-2.12.1/chroot_canon.c
  37. ===================================================================
  38. --- ldconfig-native-2.12.1.orig/chroot_canon.c
  39. +++ ldconfig-native-2.12.1/chroot_canon.c
  40. @@ -17,6 +17,9 @@
  41. along with this program; if not, write to the Free Software Foundation,
  42. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  43. +#define _LARGEFILE64_SOURCE
  44. +#define _GNU_SOURCE
  45. +
  46. #include <stdlib.h>
  47. #include <string.h>
  48. #include <unistd.h>
  49. @@ -27,7 +30,9 @@
  50. #include <stddef.h>
  51. #include <stdint.h>
  52. -#include <ldconfig.h>
  53. +#include "ldconfig.h"
  54. +
  55. +#define __set_errno(Val) errno = (Val)
  56. #ifndef PATH_MAX
  57. #define PATH_MAX 1024
  58. Index: ldconfig-native-2.12.1/dl-cache.c
  59. ===================================================================
  60. --- ldconfig-native-2.12.1.orig/dl-cache.c
  61. +++ ldconfig-native-2.12.1/dl-cache.c
  62. @@ -20,12 +20,12 @@
  63. #include <assert.h>
  64. #include <unistd.h>
  65. -#include <ldsodefs.h>
  66. +//#include "ldsodefs.h"
  67. #include <sys/mman.h>
  68. #include <dl-cache.h>
  69. #include <dl-procinfo.h>
  70. -#include <stdio-common/_itoa.h>
  71. +//#include "_itoa.h"
  72. #ifndef _DL_PLATFORMS_COUNT
  73. # define _DL_PLATFORMS_COUNT 0
  74. @@ -39,103 +39,7 @@ static size_t cachesize;
  75. /* 1 if cache_data + PTR points into the cache. */
  76. #define _dl_cache_verify_ptr(ptr) (ptr < cache_data_size)
  77. -#define SEARCH_CACHE(cache) \
  78. -/* We use binary search since the table is sorted in the cache file. \
  79. - The first matching entry in the table is returned. \
  80. - It is important to use the same algorithm as used while generating \
  81. - the cache file. */ \
  82. -do \
  83. - { \
  84. - left = 0; \
  85. - right = cache->nlibs - 1; \
  86. - \
  87. - while (left <= right) \
  88. - { \
  89. - __typeof__ (cache->libs[0].key) key; \
  90. - \
  91. - middle = (left + right) / 2; \
  92. - \
  93. - key = cache->libs[middle].key; \
  94. - \
  95. - /* Make sure string table indices are not bogus before using \
  96. - them. */ \
  97. - if (! _dl_cache_verify_ptr (key)) \
  98. - { \
  99. - cmpres = 1; \
  100. - break; \
  101. - } \
  102. - \
  103. - /* Actually compare the entry with the key. */ \
  104. - cmpres = _dl_cache_libcmp (name, cache_data + key); \
  105. - if (__builtin_expect (cmpres == 0, 0)) \
  106. - { \
  107. - /* Found it. LEFT now marks the last entry for which we \
  108. - know the name is correct. */ \
  109. - left = middle; \
  110. - \
  111. - /* There might be entries with this name before the one we \
  112. - found. So we have to find the beginning. */ \
  113. - while (middle > 0) \
  114. - { \
  115. - __typeof__ (cache->libs[0].key) key; \
  116. - \
  117. - key = cache->libs[middle - 1].key; \
  118. - /* Make sure string table indices are not bogus before \
  119. - using them. */ \
  120. - if (! _dl_cache_verify_ptr (key) \
  121. - /* Actually compare the entry. */ \
  122. - || _dl_cache_libcmp (name, cache_data + key) != 0) \
  123. - break; \
  124. - --middle; \
  125. - } \
  126. - \
  127. - do \
  128. - { \
  129. - int flags; \
  130. - __typeof__ (cache->libs[0]) *lib = &cache->libs[middle]; \
  131. - \
  132. - /* Only perform the name test if necessary. */ \
  133. - if (middle > left \
  134. - /* We haven't seen this string so far. Test whether the \
  135. - index is ok and whether the name matches. Otherwise \
  136. - we are done. */ \
  137. - && (! _dl_cache_verify_ptr (lib->key) \
  138. - || (_dl_cache_libcmp (name, cache_data + lib->key) \
  139. - != 0))) \
  140. - break; \
  141. - \
  142. - flags = lib->flags; \
  143. - if (_dl_cache_check_flags (flags) \
  144. - && _dl_cache_verify_ptr (lib->value)) \
  145. - { \
  146. - if (best == NULL || flags == GLRO(dl_correct_cache_id)) \
  147. - { \
  148. - HWCAP_CHECK; \
  149. - best = cache_data + lib->value; \
  150. - \
  151. - if (flags == GLRO(dl_correct_cache_id)) \
  152. - /* We've found an exact match for the shared \
  153. - object and no general `ELF' release. Stop \
  154. - searching. */ \
  155. - break; \
  156. - } \
  157. - } \
  158. - } \
  159. - while (++middle <= right); \
  160. - break; \
  161. - } \
  162. - \
  163. - if (cmpres < 0) \
  164. - left = middle + 1; \
  165. - else \
  166. - right = middle - 1; \
  167. - } \
  168. - } \
  169. -while (0)
  170. -
  171. -
  172. int
  173. -internal_function
  174. _dl_cache_libcmp (const char *p1, const char *p2)
  175. {
  176. while (*p1 != '\0')
  177. @@ -172,139 +76,3 @@ _dl_cache_libcmp (const char *p1, const
  178. }
  179. return *p1 - *p2;
  180. }
  181. -
  182. -
  183. -/* Look up NAME in ld.so.cache and return the file name stored there,
  184. - or null if none is found. */
  185. -
  186. -const char *
  187. -internal_function
  188. -_dl_load_cache_lookup (const char *name)
  189. -{
  190. - int left, right, middle;
  191. - int cmpres;
  192. - const char *cache_data;
  193. - uint32_t cache_data_size;
  194. - const char *best;
  195. -
  196. - /* Print a message if the loading of libs is traced. */
  197. - if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0))
  198. - _dl_debug_printf (" search cache=%s\n", LD_SO_CACHE);
  199. -
  200. - if (cache == NULL)
  201. - {
  202. - /* Read the contents of the file. */
  203. - void *file = _dl_sysdep_read_whole_file (LD_SO_CACHE, &cachesize,
  204. - PROT_READ);
  205. -
  206. - /* We can handle three different cache file formats here:
  207. - - the old libc5/glibc2.0/2.1 format
  208. - - the old format with the new format in it
  209. - - only the new format
  210. - The following checks if the cache contains any of these formats. */
  211. - if (file != MAP_FAILED && cachesize > sizeof *cache
  212. - && memcmp (file, CACHEMAGIC, sizeof CACHEMAGIC - 1) == 0)
  213. - {
  214. - size_t offset;
  215. - /* Looks ok. */
  216. - cache = file;
  217. -
  218. - /* Check for new version. */
  219. - offset = ALIGN_CACHE (sizeof (struct cache_file)
  220. - + cache->nlibs * sizeof (struct file_entry));
  221. -
  222. - cache_new = (struct cache_file_new *) ((void *) cache + offset);
  223. - if (cachesize < (offset + sizeof (struct cache_file_new))
  224. - || memcmp (cache_new->magic, CACHEMAGIC_VERSION_NEW,
  225. - sizeof CACHEMAGIC_VERSION_NEW - 1) != 0)
  226. - cache_new = (void *) -1;
  227. - }
  228. - else if (file != MAP_FAILED && cachesize > sizeof *cache_new
  229. - && memcmp (file, CACHEMAGIC_VERSION_NEW,
  230. - sizeof CACHEMAGIC_VERSION_NEW - 1) == 0)
  231. - {
  232. - cache_new = file;
  233. - cache = file;
  234. - }
  235. - else
  236. - {
  237. - if (file != MAP_FAILED)
  238. - __munmap (file, cachesize);
  239. - cache = (void *) -1;
  240. - }
  241. -
  242. - assert (cache != NULL);
  243. - }
  244. -
  245. - if (cache == (void *) -1)
  246. - /* Previously looked for the cache file and didn't find it. */
  247. - return NULL;
  248. -
  249. - best = NULL;
  250. -
  251. - if (cache_new != (void *) -1)
  252. - {
  253. - uint64_t platform;
  254. -
  255. - /* This is where the strings start. */
  256. - cache_data = (const char *) cache_new;
  257. -
  258. - /* Now we can compute how large the string table is. */
  259. - cache_data_size = (const char *) cache + cachesize - cache_data;
  260. -
  261. - platform = _dl_string_platform (GLRO(dl_platform));
  262. - if (platform != (uint64_t) -1)
  263. - platform = 1ULL << platform;
  264. -
  265. -#define _DL_HWCAP_TLS_MASK (1LL << 63)
  266. - uint64_t hwcap_exclude = ~((GLRO(dl_hwcap) & GLRO(dl_hwcap_mask))
  267. - | _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK);
  268. -
  269. - /* Only accept hwcap if it's for the right platform. */
  270. -#define HWCAP_CHECK \
  271. - if (lib->hwcap & hwcap_exclude) \
  272. - continue; \
  273. - if (GLRO(dl_osversion) && lib->osversion > GLRO(dl_osversion)) \
  274. - continue; \
  275. - if (_DL_PLATFORMS_COUNT \
  276. - && (lib->hwcap & _DL_HWCAP_PLATFORM) != 0 \
  277. - && (lib->hwcap & _DL_HWCAP_PLATFORM) != platform) \
  278. - continue
  279. - SEARCH_CACHE (cache_new);
  280. - }
  281. - else
  282. - {
  283. - /* This is where the strings start. */
  284. - cache_data = (const char *) &cache->libs[cache->nlibs];
  285. -
  286. - /* Now we can compute how large the string table is. */
  287. - cache_data_size = (const char *) cache + cachesize - cache_data;
  288. -
  289. -#undef HWCAP_CHECK
  290. -#define HWCAP_CHECK do {} while (0)
  291. - SEARCH_CACHE (cache);
  292. - }
  293. -
  294. - /* Print our result if wanted. */
  295. - if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0)
  296. - && best != NULL)
  297. - _dl_debug_printf (" trying file=%s\n", best);
  298. -
  299. - return best;
  300. -}
  301. -
  302. -#ifndef MAP_COPY
  303. -/* If the system does not support MAP_COPY we cannot leave the file open
  304. - all the time since this would create problems when the file is replaced.
  305. - Therefore we provide this function to close the file and open it again
  306. - once needed. */
  307. -void
  308. -_dl_unload_cache (void)
  309. -{
  310. - if (cache != NULL && cache != (struct cache_file *) -1)
  311. - {
  312. - __munmap (cache, cachesize);
  313. - cache = NULL;
  314. - }
  315. -}
  316. -#endif
  317. Index: ldconfig-native-2.12.1/dl-cache.h
  318. ===================================================================
  319. --- ldconfig-native-2.12.1.orig/dl-cache.h
  320. +++ ldconfig-native-2.12.1/dl-cache.h
  321. @@ -101,5 +101,4 @@ struct cache_file_new
  322. (((addr) + __alignof__ (struct cache_file_new) -1) \
  323. & (~(__alignof__ (struct cache_file_new) - 1)))
  324. -extern int _dl_cache_libcmp (const char *p1, const char *p2)
  325. - internal_function;
  326. +extern int _dl_cache_libcmp (const char *p1, const char *p2);
  327. Index: ldconfig-native-2.12.1/ldconfig.c
  328. ===================================================================
  329. --- ldconfig-native-2.12.1.orig/ldconfig.c
  330. +++ ldconfig-native-2.12.1/ldconfig.c
  331. @@ -16,6 +16,9 @@
  332. along with this program; if not, write to the Free Software Foundation,
  333. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  334. +#define _LARGEFILE64_SOURCE
  335. +#define _GNU_SOURCE
  336. +
  337. #define PROCINFO_CLASS static
  338. #include <alloca.h>
  339. #include <argp.h>
  340. @@ -39,10 +42,20 @@
  341. #include <glob.h>
  342. #include <libgen.h>
  343. -#include <ldconfig.h>
  344. -#include <dl-cache.h>
  345. +#include "ldconfig.h"
  346. +#include "dl-cache.h"
  347. +
  348. +#include "dl-procinfo.h"
  349. +
  350. +#include "argp.h"
  351. +
  352. +
  353. +#define SYSCONFDIR "/etc"
  354. +#define LIBDIR "/usr/lib"
  355. +#define SLIBDIR "/lib"
  356. +# define N_(msgid) msgid
  357. +#define _(msg) msg
  358. -#include <dl-procinfo.h>
  359. #ifdef _DL_FIRST_PLATFORM
  360. # define _DL_FIRST_EXTRA (_DL_FIRST_PLATFORM + _DL_PLATFORMS_COUNT)
  361. @@ -55,7 +68,7 @@
  362. #endif
  363. /* Get libc version number. */
  364. -#include <version.h>
  365. +#include "version.h"
  366. #define PACKAGE _libc_intl_domainname
  367. @@ -152,8 +165,8 @@ static const struct argp_option options[
  368. { NULL, 0, NULL, 0, NULL, 0 }
  369. };
  370. -#define PROCINFO_CLASS static
  371. -#include <dl-procinfo.c>
  372. +//#define PROCINFO_CLASS static
  373. +//#include <dl-procinfo.c>
  374. /* Short description of program. */
  375. static const char doc[] = N_("Configure Dynamic Linker Run Time Bindings.");
  376. @@ -291,6 +304,7 @@ parse_opt (int key, char *arg, struct ar
  377. return 0;
  378. }
  379. +#define REPORT_BUGS_TO "mailing list : poky@lists.yoctoproject.org"
  380. /* Print bug-reporting information in the help message. */
  381. static char *
  382. more_help (int key, const char *text, void *input)
  383. @@ -315,7 +329,7 @@ For bug reporting instructions, please s
  384. static void
  385. print_version (FILE *stream, struct argp_state *state)
  386. {
  387. - fprintf (stream, "ldconfig %s%s\n", PKGVERSION, VERSION);
  388. + fprintf (stream, "ldconfig (Hacked Poky Version)\n");
  389. fprintf (stream, gettext ("\
  390. Copyright (C) %s Free Software Foundation, Inc.\n\
  391. This is free software; see the source for copying conditions. There is NO\n\
  392. @@ -1233,6 +1247,7 @@ set_hwcap (void)
  393. hwcap_mask = strtoul (mask, NULL, 0);
  394. }
  395. +const char _libc_intl_domainname[] = "libc";
  396. int
  397. main (int argc, char **argv)
  398. Index: ldconfig-native-2.12.1/readlib.c
  399. ===================================================================
  400. --- ldconfig-native-2.12.1.orig/readlib.c
  401. +++ ldconfig-native-2.12.1/readlib.c
  402. @@ -22,6 +22,9 @@
  403. development version. Besides the simplification, it has also been
  404. modified to read some other file formats. */
  405. +#define _LARGEFILE64_SOURCE
  406. +#define _GNU_SOURCE
  407. +
  408. #include <a.out.h>
  409. #include <elf.h>
  410. #include <error.h>
  411. @@ -35,7 +38,9 @@
  412. #include <sys/stat.h>
  413. #include <gnu/lib-names.h>
  414. -#include <ldconfig.h>
  415. +#include "ldconfig.h"
  416. +
  417. +#define _(msg) msg
  418. #define Elf32_CLASS ELFCLASS32
  419. #define Elf64_CLASS ELFCLASS64
  420. Index: ldconfig-native-2.12.1/xstrdup.c
  421. ===================================================================
  422. --- ldconfig-native-2.12.1.orig/xstrdup.c
  423. +++ ldconfig-native-2.12.1/xstrdup.c
  424. @@ -16,15 +16,10 @@
  425. along with this program; if not, write to the Free Software Foundation,
  426. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  427. -#ifdef HAVE_CONFIG_H
  428. -# include <config.h>
  429. -#endif
  430. +#define _GNU_SOURCE
  431. +
  432. +#include <string.h>
  433. -#if defined STDC_HEADERS || defined HAVE_STRING_H || _LIBC
  434. -# include <string.h>
  435. -#else
  436. -# include <strings.h>
  437. -#endif
  438. void *xmalloc (size_t n) __THROW;
  439. char *xstrdup (char *string) __THROW;