Преглед на файлове

cleanup, and prevent failures due to including architecture specific
header files into ldconfig when building for the host.

Eric Andersen преди 19 години
родител
ревизия
8f6b29e669
променени са 4 файла, в които са добавени 66 реда и са изтрити 77 реда
  1. 3 3
      utils/Makefile
  2. 63 7
      utils/ldconfig.c
  3. 0 63
      utils/readsoname.c
  4. 0 4
      utils/readsoname.h

+ 3 - 3
utils/Makefile

@@ -44,7 +44,7 @@ readelf: readelf.c
 	$(CC) $(CFLAGS) -Wl,-s $^ -o $@
 	$(STRIPTOOL) -x -R .note -R .comment $@
 
-ldconfig:	ldconfig.c readsoname.c
+ldconfig:	ldconfig.c
 	$(CC) $(CFLAGS) -Wl,-s -static \
 		-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
 		-DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
@@ -76,7 +76,7 @@ ldd.host:	ldd.c
 		-DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
 		$^ -o $@
 
-ldconfig.host:	ldconfig.c readsoname.c
+ldconfig.host:	ldconfig.c
 	$(HOSTCC) $(HOSTCFLAGS) -Wl,-s \
 		-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
 		-DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
@@ -89,7 +89,7 @@ clean:
 	$(RM) $(TARGETS) *.o *~ core *.target elf.h iconv *.host
 
 
-readelf.c readsoname.c ldconfig.c ldd.c:	headers
+readelf.c ldconfig.c ldd.c:	headers
 
 install: all
 ifeq ($(strip $(HAVE_SHARED)),y)

+ 63 - 7
utils/ldconfig.c

@@ -37,8 +37,7 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
-#include "dl-elf.h"
-#include "readsoname.h"
+#include "dl-defs.h"
 
 #define BUFFER_SIZE 4096
 
@@ -99,6 +98,26 @@ char *conffile = LDSO_CONF;	/* default conf file */
 char *cachefile = LDSO_CACHE;	/* default cache file */
 #endif
 
+struct needed_tab
+{
+  char *soname;
+  int type;
+};
+
+struct needed_tab needed_tab[] = {
+  { "libc.so.0",    LIB_ELF_LIBC0 },
+  { "libm.so.0",    LIB_ELF_LIBC0 },
+  { "libdl.so.0",   LIB_ELF_LIBC0 },
+  { "libc.so.5",    LIB_ELF_LIBC5 },
+  { "libm.so.5",    LIB_ELF_LIBC5 },
+  { "libdl.so.1",   LIB_ELF_LIBC5 },
+  { "libc.so.6",    LIB_ELF_LIBC6 },
+  { "libm.so.6",    LIB_ELF_LIBC6 },
+  { "libdl.so.2",   LIB_ELF_LIBC6 },
+  { NULL,           LIB_ELF }
+};
+
+
 /* These two are used internally -- you shouldn't need to use them */
 static void verror_msg(const char *s, va_list p)
 {
@@ -107,7 +126,7 @@ static void verror_msg(const char *s, va_list p)
 	vfprintf(stderr, s, p);
 }
 
-extern void warnx(const char *s, ...)
+static void warnx(const char *s, ...)
 {
 	va_list p;
 
@@ -117,7 +136,7 @@ extern void warnx(const char *s, ...)
 	fprintf(stderr, "\n");
 }
 
-extern void err(int errnum, const char *s, ...)
+static void err(int errnum, const char *s, ...)
 {
 	va_list p;
 
@@ -140,7 +159,7 @@ static void vperror_msg(const char *s, va_list p)
 	fprintf(stderr, "%s%s\n", s, strerror(err));
 }
 
-extern void warn(const char *s, ...)
+static void warn(const char *s, ...)
 {
 	va_list p;
 
@@ -149,7 +168,7 @@ extern void warn(const char *s, ...)
 	va_end(p);
 }
 
-void *xmalloc(size_t size)
+static void *xmalloc(size_t size)
 {
     void *ptr;
     if ((ptr = malloc(size)) == NULL)
@@ -157,7 +176,7 @@ void *xmalloc(size_t size)
     return ptr;
 }
 
-char *xstrdup(const char *str)
+static char *xstrdup(const char *str)
 {
     char *ptr;
     if ((ptr = strdup(str)) == NULL)
@@ -165,6 +184,39 @@ char *xstrdup(const char *str)
     return ptr;
 }
 
+
+#undef __ELF_NATIVE_CLASS
+#undef readsonameXX
+#define readsonameXX readsoname32
+#define __ELF_NATIVE_CLASS 32
+#include "readsoname2.c"
+
+#undef __ELF_NATIVE_CLASS
+#undef readsonameXX
+#define readsonameXX readsoname64
+#define __ELF_NATIVE_CLASS 64
+#include "readsoname2.c"
+
+char *readsoname(char *name, FILE *infile, int expected_type, 
+		 int *type, int elfclass)
+{
+  char *res;
+
+  if (elfclass == ELFCLASS32)
+    res = readsoname32(name, infile, expected_type, type);
+  else
+  {
+    res = readsoname64(name, infile, expected_type, type);
+#if 0
+    *type |= LIB_ELF64;
+#endif
+  }
+
+  return res;
+}
+
+
+
 /* If shared library, return a malloced copy of the soname and set the
    type, else return NULL.
 
@@ -753,8 +805,10 @@ void usage(void)
 	    "\t-X:\t\tdon't update the library links\n"
 	    "\t-l:\t\tlibrary mode, manually link libraries\n"
 	    "\t-p:\t\tprint the current library cache\n"
+#ifdef __LDSO_CACHE_SUPPORT__
 	    "\t-f conf :\tuse conf instead of %s\n"
 	    "\t-C cache:\tuse cache instead of %s\n"
+#endif
 	    "\t-r root :\tfirst, do a chroot to the indicated directory\n"
 	    "\tdir ... :\tdirectories to process\n"
 #ifdef __LDSO_CACHE_SUPPORT__
@@ -776,7 +830,9 @@ int main(int argc, char **argv)
     int libtype, islink;
     char *chroot_dir = NULL;
     int printcache = 0;
+#ifdef __LDSO_CACHE_SUPPORT__
     char *extpath;
+#endif
 
     prog = argv[0];
     opterr = 0;

+ 0 - 63
utils/readsoname.c

@@ -1,63 +0,0 @@
-/* adapted from Eric Youngdale's readelf program */
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <link.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include "dl-elf.h"
-#include "readsoname.h"
-
-void warn(char *fmt, ...);
-char *xstrdup(char *);
-
-struct needed_tab
-{
-  char *soname;
-  int type;
-};
-
-struct needed_tab needed_tab[] = {
-  { "libc.so.0",    LIB_ELF_LIBC0 },
-  { "libm.so.0",    LIB_ELF_LIBC0 },
-  { "libdl.so.0",   LIB_ELF_LIBC0 },
-  { "libc.so.5",    LIB_ELF_LIBC5 },
-  { "libm.so.5",    LIB_ELF_LIBC5 },
-  { "libdl.so.1",   LIB_ELF_LIBC5 },
-  { "libc.so.6",    LIB_ELF_LIBC6 },
-  { "libm.so.6",    LIB_ELF_LIBC6 },
-  { "libdl.so.2",   LIB_ELF_LIBC6 },
-  { NULL,           LIB_ELF }
-};
-
-char *readsoname(char *name, FILE *infile, int expected_type, 
-		 int *type, int elfclass)
-{
-  char *res;
-
-  if (elfclass == ELFCLASS32)
-    res = readsoname32(name, infile, expected_type, type);
-  else
-  {
-    res = readsoname64(name, infile, expected_type, type);
-#if 0
-    *type |= LIB_ELF64;
-#endif
-  }
-
-  return res;
-}
-
-#undef __ELF_NATIVE_CLASS
-#undef readsonameXX
-#define readsonameXX readsoname32
-#define __ELF_NATIVE_CLASS 32
-#include "readsoname2.c"
-
-#undef __ELF_NATIVE_CLASS
-#undef readsonameXX
-#define readsonameXX readsoname64
-#define __ELF_NATIVE_CLASS 64
-#include "readsoname2.c"

+ 0 - 4
utils/readsoname.h

@@ -1,4 +0,0 @@
-char *readsoname(char *name, FILE *file, int expected_type,
-		 int *type, int elfclass);
-char *readsoname32(char *name, FILE *file, int expected_type, int *type);
-char *readsoname64(char *name, FILE *file, int expected_type, int *type);