summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Tjernlund <joakim.tjernlund@transmode.se>2004-10-06 07:34:17 +0000
committerJoakim Tjernlund <joakim.tjernlund@transmode.se>2004-10-06 07:34:17 +0000
commit9f9ab4922338d58f5adf8353286039eae09e1c2f (patch)
treea9149db236c6d220b3fd10c72855ea1a720292e1
parente93138024a06eab6edeaa542c4660d246ef2cfce (diff)
Puts common defines into dl-defs.h (in ldso/include) from dl-elf.h and
dl-cache.h and make use of it. Also disables the lib-path-redundancy check for the case the cache is not used. Makes use of _PRELOAD_FILE_SUPPORT. From Peter Mazinger.
-rw-r--r--extra/Configs/Config.in7
-rw-r--r--ldso/include/dl-defs.h44
-rw-r--r--ldso/include/dl-elf.h35
-rw-r--r--ldso/ldso/dl-elf.c2
-rw-r--r--utils/Makefile2
-rw-r--r--utils/dl-cache.h34
-rw-r--r--utils/ldconfig.c17
-rw-r--r--utils/ldd.c4
8 files changed, 62 insertions, 83 deletions
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index 1537867cc..56f794912 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -241,8 +241,8 @@ config LDSO_PRELOAD_FILE_SUPPORT
default n
help
Enable this to make use of /etc/ld.so.preload. This file contains a
- whitespace separated list of shared libraries to be loaded before
- the program.
+ whitespace separated list of shared libraries to be loaded before
+ the program.
config LDSO_BASE_FILENAME
string "Shared library loader naming prefix"
@@ -258,6 +258,9 @@ config LDSO_BASE_FILENAME
Most people will leave this set to the default of "ld.so".
+ WARNING: Changing the default prefix could cause problems with
+ binutils' ld !
+
config UCLIBC_CTOR_DTOR
bool "Support global constructors and destructors"
default y
diff --git a/ldso/include/dl-defs.h b/ldso/include/dl-defs.h
new file mode 100644
index 000000000..1894a56dd
--- /dev/null
+++ b/ldso/include/dl-defs.h
@@ -0,0 +1,44 @@
+#ifndef _LD_DEFS_H
+#define _LD_DEFS_H
+
+#define LIB_ANY -1
+#define LIB_DLL 0
+#define LIB_ELF 1
+#define LIB_ELF64 0x80
+#define LIB_ELF_LIBC5 2
+#define LIB_ELF_LIBC6 3
+#define LIB_ELF_LIBC0 4
+
+/* should we include features.h? */
+#if defined(__LDSO_PRELOAD_FILE_SUPPORT__) || defined(__LDSO_CACHE_SUPPORT__)
+#define LDSO_BASE_PATH UCLIBC_RUNTIME_PREFIX "etc/" __LDSO_BASE_FILENAME__
+
+#ifdef __LDSO_PRELOAD_FILE_SUPPORT__
+#define LDSO_PRELOAD LDSO_BASE_PATH ".preload"
+#endif
+
+#ifdef __LDSO_CACHE_SUPPORT__
+#define LDSO_CONF LDSO_BASE_PATH ".conf"
+#define LDSO_CACHE LDSO_BASE_PATH ".cache"
+
+#define LDSO_CACHE_MAGIC "ld.so-"
+#define LDSO_CACHE_MAGIC_LEN (sizeof LDSO_CACHE_MAGIC -1)
+#define LDSO_CACHE_VER "1.7.0"
+#define LDSO_CACHE_VER_LEN (sizeof LDSO_CACHE_VER -1)
+
+typedef struct {
+ char magic [LDSO_CACHE_MAGIC_LEN];
+ char version [LDSO_CACHE_VER_LEN];
+ int nlibs;
+} header_t;
+
+typedef struct {
+ int flags;
+ int sooffset;
+ int liboffset;
+} libentry_t;
+#endif /* __LDSO_CACHE_SUPPORT__ */
+
+#endif
+
+#endif /* _LD_DEFS_H */
diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h
index 5a6e56c80..66843096c 100644
--- a/ldso/include/dl-elf.h
+++ b/ldso/include/dl-elf.h
@@ -5,47 +5,14 @@
#include <elf.h>
#include <link.h>
-#define LDSO_BASE_PATH UCLIBC_RUNTIME_PREFIX "etc/" __LDSO_BASE_FILENAME__
-#define LDSO_CONF LDSO_BASE_PATH ".conf"
-#define LDSO_CACHE LDSO_BASE_PATH ".cache"
-#define LDSO_PRELOAD LDSO_BASE_PATH ".preload"
-
-
-#define LIB_ANY -1
-#define LIB_DLL 0
-#define LIB_ELF 1
-#define LIB_ELF64 0x80
-#define LIB_ELF_LIBC5 2
-#define LIB_ELF_LIBC6 3
-#define LIB_ELF_LIBC0 4
-
/* Forward declarations for stuff defined in ld_hash.h */
struct dyn_elf;
struct elf_resolve;
-
-/* Definitions and prototypes for cache stuff */
+#include <dl-defs.h>
#ifdef __LDSO_CACHE_SUPPORT__
extern int _dl_map_cache(void);
extern int _dl_unmap_cache(void);
-
-#define LDSO_CACHE_MAGIC "ld.so-"
-#define LDSO_CACHE_MAGIC_LEN (sizeof LDSO_CACHE_MAGIC -1)
-#define LDSO_CACHE_VER "1.7.0"
-#define LDSO_CACHE_VER_LEN (sizeof LDSO_CACHE_VER -1)
-
-typedef struct {
- char magic [LDSO_CACHE_MAGIC_LEN];
- char version [LDSO_CACHE_VER_LEN];
- int nlibs;
-} header_t;
-
-typedef struct {
- int flags;
- int sooffset;
- int liboffset;
-} libentry_t;
-
#else
static inline void _dl_map_cache(void) { }
static inline void _dl_unmap_cache(void) { }
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 7e1252df7..2dda6e5da 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -358,7 +358,7 @@ struct elf_resolve *_dl_load_shared_library(int secure, struct dyn_elf **rpnt,
if ((tpnt1 = search_for_named_library(libname, secure,
UCLIBC_RUNTIME_PREFIX "lib:"
UCLIBC_RUNTIME_PREFIX "usr/lib"
-#if !defined (__LDSO_CACHE_SUPPORT__)
+#ifndef __LDSO_CACHE_SUPPORT__
":" UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib"
#endif
, rpnt)
diff --git a/utils/Makefile b/utils/Makefile
index 55591c244..9b5517000 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -55,7 +55,7 @@ ldconfig: ldconfig.c readsoname.c
ldd: ldd.c
$(CC) $(CFLAGS) $(XXFLAGS) -Wl,-s \
-DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
- -DUCLIBC_LDSO=$(UCLIBC_LDSO) \
+ -DUCLIBC_LDSO=$(UCLIBC_LDSO) -I. -I../ldso/include \
$^ -o $@ $(LDADD_LIBFLOAT) -L../lib
$(STRIPTOOL) -x -R .note -R .comment $@
diff --git a/utils/dl-cache.h b/utils/dl-cache.h
index ba7cd3f28..e69de29bb 100644
--- a/utils/dl-cache.h
+++ b/utils/dl-cache.h
@@ -1,34 +0,0 @@
-#define LDSO_BASE_PATH UCLIBC_RUNTIME_PREFIX "etc/" __LDSO_BASE_FILENAME__
-#define LDSO_CONF LDSO_BASE_PATH ".conf"
-#define LDSO_CACHE LDSO_BASE_PATH ".cache"
-#define LDSO_PRELOAD LDSO_BASE_PATH ".preload"
-
-#define LIB_ANY -1
-#define LIB_DLL 0
-#define LIB_ELF 1
-#define LIB_ELF64 0x80
-#define LIB_ELF_LIBC5 2
-#define LIB_ELF_LIBC6 3
-#define LIB_ELF_LIBC0 4
-
-/* Definitions and prototypes for cache stuff */
-#ifdef __LDSO_CACHE_SUPPORT__
-
-#define LDSO_CACHE_MAGIC "ld.so-"
-#define LDSO_CACHE_MAGIC_LEN (sizeof LDSO_CACHE_MAGIC -1)
-#define LDSO_CACHE_VER "1.7.0"
-#define LDSO_CACHE_VER_LEN (sizeof LDSO_CACHE_VER -1)
-
-typedef struct {
- char magic [LDSO_CACHE_MAGIC_LEN];
- char version [LDSO_CACHE_VER_LEN];
- int nlibs;
-} header_t;
-
-typedef struct {
- int flags;
- int sooffset;
- int liboffset;
-} libentry_t;
-
-#endif
diff --git a/utils/ldconfig.c b/utils/ldconfig.c
index e466a42fb..52dc55b1d 100644
--- a/utils/ldconfig.c
+++ b/utils/ldconfig.c
@@ -876,7 +876,7 @@ int main(int argc, char **argv)
{
scan_dir(UCLIBC_RUNTIME_PREFIX "lib");
scan_dir(UCLIBC_RUNTIME_PREFIX "usr/lib");
-#if !defined (__LDSO_CACHE_SUPPORT__)
+#ifndef __LDSO_CACHE_SUPPORT__
scan_dir(UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib");
#endif
@@ -884,21 +884,20 @@ int main(int argc, char **argv)
if ((extpath = get_extpath()))
{
for (cp = strtok(extpath, DIR_SEP); cp; cp = strtok(NULL, DIR_SEP)) {
- /* strip traling slashes */
+ /* we do the redundancy check only if cache usage is enabled */
+#ifdef __LDSO_CACHE_SUPPORT__
+ /* strip trailing slashes */
int len = strlen(cp);
if (len)
while (cp[--len] == '/' && len)
cp[len] = 0;
- if (strcmp(UCLIBC_RUNTIME_PREFIX "lib", cp) == 0
- || strcmp(UCLIBC_RUNTIME_PREFIX "usr/lib", cp) == 0
-#if !defined (__LDSO_CACHE_SUPPORT__)
- || strcmp(UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib", cp) == 0
-#endif
- ) {
+ if (strcmp(UCLIBC_RUNTIME_PREFIX "lib", cp) == 0 ||
+ strcmp(UCLIBC_RUNTIME_PREFIX "usr/lib", cp) == 0) {
if (verbose >= 0)
- warnx("Path `%s' given more than once\n", cp);
+ warnx("Remove `%s' from `%s'\n", cp, LDSO_CONF);
continue;
}
+#endif
scan_dir(cp);
}
free(extpath);
diff --git a/utils/ldd.c b/utils/ldd.c
index cc50109fc..a4877e31a 100644
--- a/utils/ldd.c
+++ b/utils/ldd.c
@@ -45,7 +45,7 @@
#else
#include "elf.h"
#endif
-#include "dl-cache.h"
+#include "dl-defs.h"
#ifdef DMALLOC
#include <dmalloc.h>
@@ -439,7 +439,7 @@ void locate_library_file(Elf32_Ehdr* ehdr, Elf32_Dyn* dynamic, int is_suid, stru
This list must exactly match the list in uClibc/ldso/ldso/dl-elf.c */
path = UCLIBC_RUNTIME_PREFIX "lib:"
UCLIBC_RUNTIME_PREFIX "usr/lib"
-#if !defined (__LDSO_CACHE_SUPPORT__)
+#ifndef __LDSO_CACHE_SUPPORT__
":" UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib"
#endif
;