summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
Diffstat (limited to 'ldso')
-rw-r--r--ldso/config.h10
-rw-r--r--ldso/ldso/Makefile4
-rw-r--r--ldso/ldso/dl-elf.c4
-rw-r--r--ldso/ldso/readelflib1.c4
-rw-r--r--ldso/libdl/dlib.c50
-rw-r--r--ldso/libdl/libdl.c50
-rw-r--r--ldso/util/Makefile10
-rw-r--r--ldso/util/ldconfig.c4
-rw-r--r--ldso/util/ldd.c8
9 files changed, 107 insertions, 37 deletions
diff --git a/ldso/config.h b/ldso/config.h
index 256bab271..499101885 100644
--- a/ldso/config.h
+++ b/ldso/config.h
@@ -5,11 +5,11 @@
# define LDSO_PRELOAD "../util/ld.so.preload"
# define LDDSTUB "../util/lddstub"
#else
-# define LDSO_IMAGE UCLIBC_PREFIX "/lib/ld.so"
-# define LDSO_CONF UCLIBC_PREFIX "/etc/ld.so.conf"
-# define LDSO_CACHE UCLIBC_PREFIX "/etc/ld.so.cache"
-# define LDSO_PRELOAD UCLIBC_PREFIX "/etc/ld.so.preload"
-# define LDDSTUB UCLIBC_PREFIX "/usr/lib/lddstub"
+# define LDSO_IMAGE UCLIBC_TARGET_PREFIX "lib/ld.so"
+# define LDSO_CONF UCLIBC_TARGET_PREFIX "etc/ld.so.conf"
+# define LDSO_CACHE UCLIBC_TARGET_PREFIX "etc/ld.so.cache"
+# define LDSO_PRELOAD UCLIBC_TARGET_PREFIX "etc/ld.so.preload"
+# define LDDSTUB UCLIBC_TARGET_PREFIX "usr/lib/lddstub"
#endif
#define LDD_ARGV0 "__LDD_ARGV0"
diff --git a/ldso/ldso/Makefile b/ldso/ldso/Makefile
index 95ed01caf..617784ec9 100644
--- a/ldso/ldso/Makefile
+++ b/ldso/ldso/Makefile
@@ -24,12 +24,12 @@
TOPDIR=../../
include $(TOPDIR)Rules.mak
-TARGET_CFLAGS += #-DUSE_CACHE #-DDL_DEBUG #-funroll-loops
+TARGET_CFLAGS += #-DDL_DEBUG #-funroll-loops
LDSO_FULLNAME=ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).so
-TARGET_CFLAGS+=-fPIC -D__PIC__ -DUCLIBC_PREFIX=\"$(PREFIX)\" \
+TARGET_CFLAGS+=-fPIC -D__PIC__ -DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
-DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \
-DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR); pwd)\"
CSRC= boot1.c hash.c readelflib1.c $(TARGET_ARCH)/elfinterp.c
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 049452bfa..ebc9bc8dc 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -249,7 +249,7 @@ struct elf_resolve *_dl_load_shared_library(int secure,
#endif
/* Check in <prefix>/usr/lib */
- pnt1 = UCLIBC_PREFIX "/usr/lib/";
+ pnt1 = UCLIBC_TARGET_PREFIX "/usr/lib/";
pnt = mylibname;
while (*pnt1)
*pnt++ = *pnt1++;
@@ -262,7 +262,7 @@ struct elf_resolve *_dl_load_shared_library(int secure,
return tpnt1;
/* Check in <prefix>/lib */
- pnt1 = UCLIBC_PREFIX "/lib/";
+ pnt1 = UCLIBC_TARGET_PREFIX "/lib/";
pnt = mylibname;
while (*pnt1)
*pnt++ = *pnt1++;
diff --git a/ldso/ldso/readelflib1.c b/ldso/ldso/readelflib1.c
index 049452bfa..ebc9bc8dc 100644
--- a/ldso/ldso/readelflib1.c
+++ b/ldso/ldso/readelflib1.c
@@ -249,7 +249,7 @@ struct elf_resolve *_dl_load_shared_library(int secure,
#endif
/* Check in <prefix>/usr/lib */
- pnt1 = UCLIBC_PREFIX "/usr/lib/";
+ pnt1 = UCLIBC_TARGET_PREFIX "/usr/lib/";
pnt = mylibname;
while (*pnt1)
*pnt++ = *pnt1++;
@@ -262,7 +262,7 @@ struct elf_resolve *_dl_load_shared_library(int secure,
return tpnt1;
/* Check in <prefix>/lib */
- pnt1 = UCLIBC_PREFIX "/lib/";
+ pnt1 = UCLIBC_TARGET_PREFIX "/lib/";
pnt = mylibname;
while (*pnt1)
*pnt++ = *pnt1++;
diff --git a/ldso/libdl/dlib.c b/ldso/libdl/dlib.c
index 2b6000472..7664f3fd4 100644
--- a/ldso/libdl/dlib.c
+++ b/ldso/libdl/dlib.c
@@ -454,41 +454,69 @@ const char *_dlerror()
}
/* Generate the correct symbols that we need. */
+#if 0
weak_alias(_dlopen, dlopen);
weak_alias(_dlerror, dlerror);
weak_alias(_dlclose, dlclose);
weak_alias(_dlsym, dlsym);
weak_alias(_dladdr, dladdr);
+#endif
+asm(".weak dlopen;dlopen=_dlopen");
+asm(".weak dlerror;dlerror=_dlerror");
+asm(".weak dlclose;dlclose=_dlclose");
+asm(".weak dlsym;dlsym=_dlsym");
+asm(".weak dladdr;dladdr=_dladdr");
+
/* This is a real hack. We need access to the dynamic linker, but we
also need to make it possible to link against this library without any
unresolved externals. We provide these weak symbols to make the link
possible, but at run time the normal symbols are accessed. */
-static void foobar()
+static void __attribute__ ((unused)) foobar()
{
_dl_fprintf(2, "libdl library not correctly linked\n");
_dl_exit(1);
}
-static int __attribute__ ((unused)) foobar1 = (int) foobar; /* Use as pointer */
+asm(".weak _dl_fprintf; _dl_fprintf = foobar");
+asm(".weak _dl_find_hash; _dl_find_hash = foobar");
+asm(".weak _dl_load_shared_library; _dl_load_shared_library = foobar");
+asm(".weak _dl_parse_relocation_information; _dl_parse_relocation_information = foobar");
+asm(".weak _dl_parse_lazy_relocation_information; _dl_parse_lazy_relocation_information = foobar");
+#ifdef USE_CACHE
+asm(".weak _dl_map_cache; _dl_map_cache = foobar");
+asm(".weak _dl_unmap_cache; _dl_unmap_cache = foobar");
+#endif
+#if 0
+weak_alias(_dl_fprintf, foobar);
weak_alias(_dl_find_hash, foobar);
-weak_alias(_dl_symbol_tables, foobar1);
-weak_alias(_dl_handles, foobar1);
-weak_alias(_dl_loaded_modules, foobar1);
-weak_alias(_dl_debug_addr, foobar1);
-weak_alias(_dl_error_number, foobar1);
weak_alias(_dl_load_shared_library, foobar);
+weak_alias(_dl_parse_relocation_information, foobar);
+weak_alias(_dl_parse_lazy_relocation_information, foobar);
#ifdef USE_CACHE
weak_alias(_dl_map_cache, foobar);
weak_alias(_dl_unmap_cache, foobar);
#endif
-weak_alias(_dl_malloc_function, foobar1);
-weak_alias(_dl_parse_relocation_information, foobar);
-weak_alias(_dl_parse_lazy_relocation_information, foobar);
-weak_alias(_dl_fprintf, foobar);
+#endif
+
+static int __attribute__ ((unused)) foobar1 = (int) foobar; /* Use as pointer */
+asm(".weak _dl_symbol_tables; _dl_symbol_tables = foobar1");
+asm(".weak _dl_handles; _dl_handles = foobar1");
+asm(".weak _dl_loaded_modules; _dl_loaded_modules = foobar1");
+asm(".weak _dl_debug_addr; _dl_debug_addr = foobar1");
+asm(".weak _dl_error_number; _dl_error_number = foobar1");
+asm(".weak _dl_malloc_function; _dl_malloc_function = foobar1");
+#if 0
+weak_alias(_dl_symbol_tables, foobar1);
+weak_alias(_dl_handles, foobar1);
+weak_alias(_dl_loaded_modules, foobar1);
+weak_alias(_dl_debug_addr, foobar1);
+weak_alias(_dl_error_number, foobar1);
+weak_alias(_dl_malloc_function, foobar1);
+#endif
/*
* Dump information to stderrr about the current loaded modules
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 2b6000472..7664f3fd4 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -454,41 +454,69 @@ const char *_dlerror()
}
/* Generate the correct symbols that we need. */
+#if 0
weak_alias(_dlopen, dlopen);
weak_alias(_dlerror, dlerror);
weak_alias(_dlclose, dlclose);
weak_alias(_dlsym, dlsym);
weak_alias(_dladdr, dladdr);
+#endif
+asm(".weak dlopen;dlopen=_dlopen");
+asm(".weak dlerror;dlerror=_dlerror");
+asm(".weak dlclose;dlclose=_dlclose");
+asm(".weak dlsym;dlsym=_dlsym");
+asm(".weak dladdr;dladdr=_dladdr");
+
/* This is a real hack. We need access to the dynamic linker, but we
also need to make it possible to link against this library without any
unresolved externals. We provide these weak symbols to make the link
possible, but at run time the normal symbols are accessed. */
-static void foobar()
+static void __attribute__ ((unused)) foobar()
{
_dl_fprintf(2, "libdl library not correctly linked\n");
_dl_exit(1);
}
-static int __attribute__ ((unused)) foobar1 = (int) foobar; /* Use as pointer */
+asm(".weak _dl_fprintf; _dl_fprintf = foobar");
+asm(".weak _dl_find_hash; _dl_find_hash = foobar");
+asm(".weak _dl_load_shared_library; _dl_load_shared_library = foobar");
+asm(".weak _dl_parse_relocation_information; _dl_parse_relocation_information = foobar");
+asm(".weak _dl_parse_lazy_relocation_information; _dl_parse_lazy_relocation_information = foobar");
+#ifdef USE_CACHE
+asm(".weak _dl_map_cache; _dl_map_cache = foobar");
+asm(".weak _dl_unmap_cache; _dl_unmap_cache = foobar");
+#endif
+#if 0
+weak_alias(_dl_fprintf, foobar);
weak_alias(_dl_find_hash, foobar);
-weak_alias(_dl_symbol_tables, foobar1);
-weak_alias(_dl_handles, foobar1);
-weak_alias(_dl_loaded_modules, foobar1);
-weak_alias(_dl_debug_addr, foobar1);
-weak_alias(_dl_error_number, foobar1);
weak_alias(_dl_load_shared_library, foobar);
+weak_alias(_dl_parse_relocation_information, foobar);
+weak_alias(_dl_parse_lazy_relocation_information, foobar);
#ifdef USE_CACHE
weak_alias(_dl_map_cache, foobar);
weak_alias(_dl_unmap_cache, foobar);
#endif
-weak_alias(_dl_malloc_function, foobar1);
-weak_alias(_dl_parse_relocation_information, foobar);
-weak_alias(_dl_parse_lazy_relocation_information, foobar);
-weak_alias(_dl_fprintf, foobar);
+#endif
+
+static int __attribute__ ((unused)) foobar1 = (int) foobar; /* Use as pointer */
+asm(".weak _dl_symbol_tables; _dl_symbol_tables = foobar1");
+asm(".weak _dl_handles; _dl_handles = foobar1");
+asm(".weak _dl_loaded_modules; _dl_loaded_modules = foobar1");
+asm(".weak _dl_debug_addr; _dl_debug_addr = foobar1");
+asm(".weak _dl_error_number; _dl_error_number = foobar1");
+asm(".weak _dl_malloc_function; _dl_malloc_function = foobar1");
+#if 0
+weak_alias(_dl_symbol_tables, foobar1);
+weak_alias(_dl_handles, foobar1);
+weak_alias(_dl_loaded_modules, foobar1);
+weak_alias(_dl_debug_addr, foobar1);
+weak_alias(_dl_error_number, foobar1);
+weak_alias(_dl_malloc_function, foobar1);
+#endif
/*
* Dump information to stderrr about the current loaded modules
diff --git a/ldso/util/Makefile b/ldso/util/Makefile
index a5eb9ad6c..baa3fa897 100644
--- a/ldso/util/Makefile
+++ b/ldso/util/Makefile
@@ -8,7 +8,7 @@ readsoname.o: readsoname.c readsoname2.c
$(STRIPTOOL) -x -R .note -R .comment $*.o
ldconfig.o: ldconfig.c
- $(TARGET_CC) $(TARGET_CFLAGS) -DUCLIBC_PREFIX=\"$(PREFIX)\" \
+ $(TARGET_CC) $(TARGET_CFLAGS) -DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
-c $< -o $@
$(STRIPTOOL) -x -R .note -R .comment $*.o
@@ -16,14 +16,20 @@ readelf: readelf.c
$(TARGET_CC) $(TARGET_CFLAGS) -static readelf.c -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
+ifeq ($(strip $(LIBRARY_CACHE)),)
+ldconfig:
+ echo "LIBRARY_CACHE disabled -- not building ldconfig"
+else
ldconfig: ldconfig.o readsoname.o
$(TARGET_CC) $(TARGET_CFLAGS) -static $^ -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
+endif
ldd: ldd.c
- $(TARGET_CC) $(TARGET_CFLAGS) -DUCLIBC_PREFIX=\"$(PREFIX)\" \
+ $(TARGET_CC) $(TARGET_CFLAGS) -DUCLIBC_TARGET_PREFIX=\"$(TARGET_PREFIX)\" \
-DUCLIBC_DEVEL_PREFIX=\"$(DEVEL_PREFIX)\" \
-DUCLIBC_BUILD_DIR=\"$(shell cd $(TOPDIR); pwd)\" \
+ -DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\" \
-static ldd.c -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
diff --git a/ldso/util/ldconfig.c b/ldso/util/ldconfig.c
index 054b82a93..63765a78c 100644
--- a/ldso/util/ldconfig.c
+++ b/ldso/util/ldconfig.c
@@ -683,8 +683,8 @@ int main(int argc, char **argv)
free(extpath);
}
- scan_dir(UCLIBC_PREFIX "/usr/lib");
- scan_dir(UCLIBC_PREFIX "/lib");
+ scan_dir(UCLIBC_TARGET_PREFIX "/usr/lib");
+ scan_dir(UCLIBC_TARGET_PREFIX "/lib");
}
if (!nocache)
diff --git a/ldso/util/ldd.c b/ldso/util/ldd.c
index fd0ff54b3..e8627fb0a 100644
--- a/ldso/util/ldd.c
+++ b/ldso/util/ldd.c
@@ -222,6 +222,10 @@ static int add_library(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, char *strtab, int i
if (!s || !strlen(s))
return 1;
+ /* We add libc.so.0 elsewhere */
+ if (strcmp(s, UCLIBC_LDSO)==0)
+ return 1;
+
for (cur = lib_list; cur; cur=cur->next) {
if(strcmp(cur->name, s)==0) {
/* Lib is already in the list */
@@ -396,9 +400,13 @@ int main( int argc, char** argv)
/* Print the list */
+ got_em_all=0;
for (cur = lib_list; cur; cur=cur->next) {
+ got_em_all=1;
printf("\t%s => %s\n", cur->name, cur->path);
}
+ if (got_em_all==0)
+ printf("\tnot a dynamic executable\n");
return 0;
}