Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so Implement LD_PRELOAD support.
details: https://anonhg.NetBSD.org/src/rev/c34997101b0a
branches: trunk
changeset: 473378:c34997101b0a
user: kleink <kleink%NetBSD.org@localhost>
date: Mon May 31 14:48:16 1999 +0000
description:
Implement LD_PRELOAD support.
diffstat:
libexec/ld.elf_so/load.c | 27 ++++++++++++++++++++++++++-
libexec/ld.elf_so/rtld.c | 10 +++++++++-
libexec/ld.elf_so/rtld.h | 3 ++-
3 files changed, 37 insertions(+), 3 deletions(-)
diffs (79 lines):
diff -r 324b4098307a -r c34997101b0a libexec/ld.elf_so/load.c
--- a/libexec/ld.elf_so/load.c Mon May 31 14:39:13 1999 +0000
+++ b/libexec/ld.elf_so/load.c Mon May 31 14:48:16 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: load.c,v 1.3 1999/03/01 16:40:07 christos Exp $ */
+/* $NetBSD: load.c,v 1.4 1999/05/31 14:48:16 kleink Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -142,3 +142,28 @@
return status;
}
+
+#ifdef RTLD_LOADER
+int
+_rtld_preload(preload_path, dodebug)
+ const char *preload_path;
+ bool dodebug;
+{
+ const char *path;
+ char *cp, *buf;
+ int status = 0;
+
+ if (preload_path != NULL) {
+ cp = buf = xstrdup(preload_path);
+ while ((path = strsep(&cp, " ")) != NULL && status == 0) {
+ if (_rtld_load_object(xstrdup(path), dodebug) == NULL)
+ status = -1;
+ else if (dodebug)
+ dbg((" preloaded \"%s\"", path));
+ }
+ free(buf);
+ }
+
+ return (status);
+}
+#endif
diff -r 324b4098307a -r c34997101b0a libexec/ld.elf_so/rtld.c
--- a/libexec/ld.elf_so/rtld.c Mon May 31 14:39:13 1999 +0000
+++ b/libexec/ld.elf_so/rtld.c Mon May 31 14:48:16 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld.c,v 1.18 1999/04/18 19:40:06 ws Exp $ */
+/* $NetBSD: rtld.c,v 1.19 1999/05/31 14:48:16 kleink Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -393,6 +393,14 @@
_rtld_objtail = &_rtld_objmain->next;
++_rtld_objmain->refcount;
+ /*
+ * Pre-load user-specified objects after the main program but before
+ * any shared object dependencies.
+ */
+ dbg(("preloading objects"));
+ if (_rtld_trust && _rtld_preload(getenv("LD_PRELOAD"), true) == -1)
+ _rtld_die();
+
dbg(("loading needed objects"));
if (_rtld_load_needed_objects(_rtld_objmain) == -1)
_rtld_die();
diff -r 324b4098307a -r c34997101b0a libexec/ld.elf_so/rtld.h
--- a/libexec/ld.elf_so/rtld.h Mon May 31 14:39:13 1999 +0000
+++ b/libexec/ld.elf_so/rtld.h Mon May 31 14:48:16 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld.h,v 1.10 1999/04/18 19:40:06 ws Exp $ */
+/* $NetBSD: rtld.h,v 1.11 1999/05/31 14:48:16 kleink Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -203,6 +203,7 @@
/* load.c */
Obj_Entry *_rtld_load_object __P((char *, bool));
int _rtld_load_needed_objects __P((Obj_Entry *));
+int _rtld_preload __P((const char *, bool));
/* path.c */
void _rtld_add_paths __P((Search_Path **, const char *, bool));
Home |
Main Index |
Thread Index |
Old Index