diff options
author | Eric Andersen <andersen@codepoet.org> | 2005-01-12 01:22:59 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2005-01-12 01:22:59 +0000 |
commit | 8f6b29e669ac593f07c7b8f4eb1507aa12c14983 (patch) | |
tree | cc814a8ac48da641a9c6296c24c23751ac4746c2 /utils | |
parent | 7faa798bed2130a7cebc49f4c055b9873e19a768 (diff) | |
download | uClibc-alpine-8f6b29e669ac593f07c7b8f4eb1507aa12c14983.tar.bz2 uClibc-alpine-8f6b29e669ac593f07c7b8f4eb1507aa12c14983.tar.xz |
cleanup, and prevent failures due to including architecture specific
header files into ldconfig when building for the host.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/Makefile | 6 | ||||
-rw-r--r-- | utils/ldconfig.c | 70 | ||||
-rw-r--r-- | utils/readsoname.c | 63 | ||||
-rw-r--r-- | utils/readsoname.h | 4 |
4 files changed, 66 insertions, 77 deletions
diff --git a/utils/Makefile b/utils/Makefile index 86640055d..6b89974c5 100644 --- a/utils/Makefile +++ b/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) diff --git a/utils/ldconfig.c b/utils/ldconfig.c index 370b8cf1f..202a58dd6 100644 --- a/utils/ldconfig.c +++ b/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; diff --git a/utils/readsoname.c b/utils/readsoname.c deleted file mode 100644 index 813710c98..000000000 --- a/utils/readsoname.c +++ /dev/null @@ -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" diff --git a/utils/readsoname.h b/utils/readsoname.h deleted file mode 100644 index 91823ff7a..000000000 --- a/utils/readsoname.h +++ /dev/null @@ -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); |