diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-03-08 09:40:52 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-03-08 09:40:52 +0000 |
commit | ff1b55eb5e5129913d9fa3bd7f93029a97593142 (patch) | |
tree | 7c5032af1362a9e691b81d2943fb56c6ccbf6694 /ldso | |
parent | 134392384ed11a2aa68a09dc7310cebec3b0b960 (diff) |
Seperate out the symbol resolution debugging, so it doesn't clutter
things up when we don't care about symbol resolution problems. Make
the lib loader always look first in the directory where the shared lib
loader was found.
-Erik
Diffstat (limited to 'ldso')
-rw-r--r-- | ldso/ldso/Makefile | 1 | ||||
-rw-r--r-- | ldso/ldso/arm/elfinterp.c | 4 | ||||
-rw-r--r-- | ldso/ldso/dl-elf.c | 33 | ||||
-rw-r--r-- | ldso/ldso/i386/elfinterp.c | 4 | ||||
-rw-r--r-- | ldso/ldso/ldso.c | 17 | ||||
-rw-r--r-- | ldso/ldso/m68k/elfinterp.c | 5 | ||||
-rw-r--r-- | ldso/ldso/powerpc/elfinterp.c | 4 | ||||
-rw-r--r-- | ldso/ldso/readelflib1.c | 33 | ||||
-rw-r--r-- | ldso/ldso/sparc/elfinterp.c | 5 |
9 files changed, 86 insertions, 20 deletions
diff --git a/ldso/ldso/Makefile b/ldso/ldso/Makefile index 06cdbbe37..55d3f00c6 100644 --- a/ldso/ldso/Makefile +++ b/ldso/ldso/Makefile @@ -29,6 +29,7 @@ LDSO_FULLNAME=ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so # Enable this to enable debugging output from ld.so #XXFLAGS+= -DDL_DEBUG +#XXFLAGS+= -DDL_DEBUG_SYMBOLS XXFLAGS+=-DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \ -DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \ diff --git a/ldso/ldso/arm/elfinterp.c b/ldso/ldso/arm/elfinterp.c index de9d50bc8..aac7ecc11 100644 --- a/ldso/ldso/arm/elfinterp.c +++ b/ldso/ldso/arm/elfinterp.c @@ -82,7 +82,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) (unsigned long) tpnt->loadaddr); got_addr = (char **) instr_addr; -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS _dl_dprintf(2, "Resolving symbol %s\n", strtab + symtab[symtab_index].st_name); #endif @@ -95,7 +95,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) _dl_progname, strtab + symtab[symtab_index].st_name); _dl_exit(1); }; -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS if ((unsigned long) got_addr < 0x40000000) { _dl_dprintf(2, "Calling library function: %s\n", strtab + symtab[symtab_index].st_name); diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c index 35de7a162..ba015042f 100644 --- a/ldso/ldso/dl-elf.c +++ b/ldso/ldso/dl-elf.c @@ -110,7 +110,7 @@ int _dl_unmap_cache(void) static struct elf_resolve * search_for_named_library(char *name, int secure, const char *path_list) { - int i, count = 0; + int i, count = 1; char *path, *path_n; char mylibname[2050]; struct elf_resolve *tpnt1; @@ -154,11 +154,12 @@ search_for_named_library(char *name, int secure, const char *path_list) unsigned long _dl_error_number; unsigned long _dl_internal_error_number; +extern char *_dl_ldsopath; struct elf_resolve *_dl_load_shared_library(int secure, struct elf_resolve *tpnt, char *full_libname) { - char *pnt; + char *pnt, *pnt1; struct elf_resolve *tpnt1; char *libname; @@ -176,6 +177,9 @@ struct elf_resolve *_dl_load_shared_library(int secure, pnt++; } +#ifdef DL_DEBUG + _dl_dprintf(2, "searching for library: '%s'\n", libname); +#endif /* If the filename has any '/', try it straight and leave it at that. For IBCS2 compatibility under linux, we substitute the string /usr/i486-sysv4/lib for /usr/lib in library names. */ @@ -197,6 +201,9 @@ struct elf_resolve *_dl_load_shared_library(int secure, if (pnt) { pnt += (unsigned long) tpnt->loadaddr + tpnt->dynamic_info[DT_STRTAB]; +#ifdef DL_DEBUG + _dl_dprintf(2, "searching RPATH: '%s'\n", pnt); +#endif if ((tpnt1 = search_for_named_library(libname, secure, pnt)) != NULL) { return tpnt1; @@ -207,6 +214,9 @@ struct elf_resolve *_dl_load_shared_library(int secure, /* Check in LD_{ELF_}LIBRARY_PATH, if specified and allowed */ if (_dl_library_path) { +#ifdef DL_DEBUG + _dl_dprintf(2, "searching _dl_library_path: '%s'\n", _dl_library_path); +#endif if ((tpnt1 = search_for_named_library(libname, secure, _dl_library_path)) != NULL) { return tpnt1; @@ -236,8 +246,22 @@ struct elf_resolve *_dl_load_shared_library(int secure, } #endif + /* Look for libraries wherever the shared library loader + * was installed */ +#ifdef DL_DEBUG + _dl_dprintf(2, "searching in ldso dir: %s\n", _dl_ldsopath); +#endif + if ((tpnt1 = search_for_named_library(libname, secure, _dl_ldsopath)) != NULL) + { + return tpnt1; + } + + /* Lastly, search the standard list of paths for the library. This list must exactly match the list in uClibc/ldso/util/ldd.c */ +#ifdef DL_DEBUG + _dl_dprintf(2, "searching full lib path list\n"); +#endif if ((tpnt1 = search_for_named_library(libname, secure, UCLIBC_TARGET_PREFIX "/usr/lib:" UCLIBC_TARGET_PREFIX "/lib:" @@ -250,12 +274,15 @@ struct elf_resolve *_dl_load_shared_library(int secure, return tpnt1; } - goof: +goof: /* Well, we shot our wad on that one. All we can do now is punt */ if (_dl_internal_error_number) _dl_error_number = _dl_internal_error_number; else _dl_error_number = DL_ERROR_NOFILE; +#ifdef DL_DEBUG + _dl_dprintf(2, "Bummer: could not find '%s'!\n", libname); +#endif return NULL; } diff --git a/ldso/ldso/i386/elfinterp.c b/ldso/ldso/i386/elfinterp.c index 8cd1eb21c..be19327a7 100644 --- a/ldso/ldso/i386/elfinterp.c +++ b/ldso/ldso/i386/elfinterp.c @@ -74,7 +74,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) (unsigned long) tpnt->loadaddr); got_addr = (char **) instr_addr; -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS _dl_dprintf(2, "Resolving symbol %s\n", strtab + symtab[symtab_index].st_name); #endif @@ -87,7 +87,7 @@ unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry) _dl_progname, strtab + symtab[symtab_index].st_name); _dl_exit(1); }; -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS if ((unsigned long) got_addr < 0x40000000) { _dl_dprintf(2, "Calling library function: %s\n", strtab + symtab[symtab_index].st_name); diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 6a3f19c72..36580e26a 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -139,10 +139,11 @@ */ #define REALIGN() malloc_buffer = (char *) (((unsigned long) malloc_buffer + 3) & ~(3)) -static char *_dl_malloc_addr, *_dl_mmap_zero; char *_dl_library_path = 0; /* Where we look for libraries */ char *_dl_preload = 0; /* Things to be loaded before the libs. */ +char *_dl_ldsopath = 0; static char *_dl_not_lazy = 0; +static char *_dl_malloc_addr, *_dl_mmap_zero; #ifdef DL_TRACE static char *_dl_trace_loaded_objects = 0; @@ -509,7 +510,7 @@ DL_BOOT(unsigned long args) SEND_STDERR(" undefined.\n"); goof++; } -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS SEND_STDERR("About to fixup symbol: "); SEND_STDERR(strtab + symtab[symtab_index].st_name); SEND_STDERR("\n"); @@ -661,6 +662,18 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a (auxvt[AT_PHDR].a_un.a_val & 0xfffff000)); } } + /* Store the path where the shared lib loader was found for + * later use */ + { + char *pnt, *pnt1; + pnt = _dl_strdup(tpnt->libname); + pnt1 = _dl_strrchr(pnt, '/'); + if (pnt != pnt1) { + *pnt1 = '\0'; + _dl_ldsopath = pnt; + } + } + #ifdef DL_DEBUG _dl_dprintf(2, "Lib Loader:\t(%x) %s\n", tpnt->loadaddr, tpnt->libname); #endif diff --git a/ldso/ldso/m68k/elfinterp.c b/ldso/ldso/m68k/elfinterp.c index 167ce41dd..0fa8da827 100644 --- a/ldso/ldso/m68k/elfinterp.c +++ b/ldso/ldso/m68k/elfinterp.c @@ -83,7 +83,7 @@ unsigned int _dl_linux_resolver (int dummy1, int dummy2, instr_addr = (int) this_reloc->r_offset + (int) tpnt->loadaddr; got_addr = (char **) instr_addr; -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS _dl_dprintf (2, "Resolving symbol %s\n", strtab + symtab[symtab_index].st_name); #endif @@ -97,8 +97,7 @@ unsigned int _dl_linux_resolver (int dummy1, int dummy2, _dl_progname, strtab + symtab[symtab_index].st_name); _dl_exit (1); } -/* #define DL_DEBUG */ -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS if ((unsigned int) got_addr < 0x40000000) _dl_dprintf (2, "Calling library function: %s\n", strtab + symtab[symtab_index].st_name); diff --git a/ldso/ldso/powerpc/elfinterp.c b/ldso/ldso/powerpc/elfinterp.c index 1935960e9..aed640ee2 100644 --- a/ldso/ldso/powerpc/elfinterp.c +++ b/ldso/ldso/powerpc/elfinterp.c @@ -49,7 +49,7 @@ static char *_dl_reltypes[] = working. */ -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS static void debug_sym(Elf32_Sym *symtab,char *strtab,int symtab_index); static void debug_reloc(ELF_RELOC *rpnt); #define DPRINTF(fmt,args...) _dl_dprintf(2,fmt,args) @@ -547,7 +547,7 @@ static void fixup_jmpslot(unsigned long reloc_addr, unsigned long targ_addr) #endif -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS static void debug_sym(Elf32_Sym *symtab,char *strtab,int symtab_index) { if(symtab_index){ diff --git a/ldso/ldso/readelflib1.c b/ldso/ldso/readelflib1.c index 35de7a162..ba015042f 100644 --- a/ldso/ldso/readelflib1.c +++ b/ldso/ldso/readelflib1.c @@ -110,7 +110,7 @@ int _dl_unmap_cache(void) static struct elf_resolve * search_for_named_library(char *name, int secure, const char *path_list) { - int i, count = 0; + int i, count = 1; char *path, *path_n; char mylibname[2050]; struct elf_resolve *tpnt1; @@ -154,11 +154,12 @@ search_for_named_library(char *name, int secure, const char *path_list) unsigned long _dl_error_number; unsigned long _dl_internal_error_number; +extern char *_dl_ldsopath; struct elf_resolve *_dl_load_shared_library(int secure, struct elf_resolve *tpnt, char *full_libname) { - char *pnt; + char *pnt, *pnt1; struct elf_resolve *tpnt1; char *libname; @@ -176,6 +177,9 @@ struct elf_resolve *_dl_load_shared_library(int secure, pnt++; } +#ifdef DL_DEBUG + _dl_dprintf(2, "searching for library: '%s'\n", libname); +#endif /* If the filename has any '/', try it straight and leave it at that. For IBCS2 compatibility under linux, we substitute the string /usr/i486-sysv4/lib for /usr/lib in library names. */ @@ -197,6 +201,9 @@ struct elf_resolve *_dl_load_shared_library(int secure, if (pnt) { pnt += (unsigned long) tpnt->loadaddr + tpnt->dynamic_info[DT_STRTAB]; +#ifdef DL_DEBUG + _dl_dprintf(2, "searching RPATH: '%s'\n", pnt); +#endif if ((tpnt1 = search_for_named_library(libname, secure, pnt)) != NULL) { return tpnt1; @@ -207,6 +214,9 @@ struct elf_resolve *_dl_load_shared_library(int secure, /* Check in LD_{ELF_}LIBRARY_PATH, if specified and allowed */ if (_dl_library_path) { +#ifdef DL_DEBUG + _dl_dprintf(2, "searching _dl_library_path: '%s'\n", _dl_library_path); +#endif if ((tpnt1 = search_for_named_library(libname, secure, _dl_library_path)) != NULL) { return tpnt1; @@ -236,8 +246,22 @@ struct elf_resolve *_dl_load_shared_library(int secure, } #endif + /* Look for libraries wherever the shared library loader + * was installed */ +#ifdef DL_DEBUG + _dl_dprintf(2, "searching in ldso dir: %s\n", _dl_ldsopath); +#endif + if ((tpnt1 = search_for_named_library(libname, secure, _dl_ldsopath)) != NULL) + { + return tpnt1; + } + + /* Lastly, search the standard list of paths for the library. This list must exactly match the list in uClibc/ldso/util/ldd.c */ +#ifdef DL_DEBUG + _dl_dprintf(2, "searching full lib path list\n"); +#endif if ((tpnt1 = search_for_named_library(libname, secure, UCLIBC_TARGET_PREFIX "/usr/lib:" UCLIBC_TARGET_PREFIX "/lib:" @@ -250,12 +274,15 @@ struct elf_resolve *_dl_load_shared_library(int secure, return tpnt1; } - goof: +goof: /* Well, we shot our wad on that one. All we can do now is punt */ if (_dl_internal_error_number) _dl_error_number = _dl_internal_error_number; else _dl_error_number = DL_ERROR_NOFILE; +#ifdef DL_DEBUG + _dl_dprintf(2, "Bummer: could not find '%s'!\n", libname); +#endif return NULL; } diff --git a/ldso/ldso/sparc/elfinterp.c b/ldso/ldso/sparc/elfinterp.c index 46754d6c7..3ccdcb41f 100644 --- a/ldso/ldso/sparc/elfinterp.c +++ b/ldso/ldso/sparc/elfinterp.c @@ -91,7 +91,7 @@ unsigned int _dl_linux_resolver(unsigned int reloc_entry, unsigned int * plt) _dl_dprintf(2, "symtab_index %d\n", symtab_index); -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS _dl_dprintf(2, "Resolving symbol %s\n", strtab + symtab[symtab_index].st_name); #endif @@ -104,8 +104,7 @@ unsigned int _dl_linux_resolver(unsigned int reloc_entry, unsigned int * plt) _dl_progname, strtab + symtab[symtab_index].st_name); _dl_exit(31); }; -/* #define DL_DEBUG */ -#ifdef DL_DEBUG +#ifdef DL_DEBUG_SYMBOLS if((unsigned int) got_addr < 0x40000000) { _dl_dprintf(2, "Calling library function: %s\n", strtab + symtab[symtab_index].st_name); |