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