# 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)\" \
(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
_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);
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;
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;
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. */
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;
/* 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;
}
#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:"
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;
}
(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
_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);
*/
#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;
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");
(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
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
_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);
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)
#endif
-#ifdef DL_DEBUG
+#ifdef DL_DEBUG_SYMBOLS
static void debug_sym(Elf32_Sym *symtab,char *strtab,int symtab_index)
{
if(symtab_index){
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;
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;
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. */
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;
/* 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;
}
#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:"
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;
}
_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
_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);