summaryrefslogtreecommitdiff
path: root/libc/misc/internals
diff options
context:
space:
mode:
authorFilippo Arcidiacono <filippo.arcidiacono@st.com>2009-07-31 14:56:38 +0200
committerCarmelo Amoroso <carmelo.amoroso@st.com>2010-09-17 13:06:58 +0200
commit637e2b2440f69e22932edd71bd2f0b1210dc32ea (patch)
tree24d396c7f3730ad50426bfffcd113186265d18b2 /libc/misc/internals
parentef65e97083363ffaeeb5fcf3a37d074b74eafb0d (diff)
ldso: Add implementation of ld.so standalone execution
The dynamic linker can be run either indirectly through running some dynamically linked program or library (in which case no command line options to the dynamic linker can be passed and, in the ELF case, the dynamic linker which is stored in the .interp section of the program is executed) or directly by running: /lib/ld-uClibc.so.* [OPTIONS] [PROGRAM [ARGUMENTS]] Stand-alone execution is a prerequisite for adding prelink capabilities to uClibc dynamic linker, as well useful for testing an updated version of the dynamic linker without breaking the whole system. Currently supported option: --library-path PATH use given PATH instead of content of the environment variable LD_LIBRARY_PATH (Mandatory for prelinking) Not supported options: --list list all dependencies and how they are resolved --verify verify that given object really is a dynamically linked object we can handle --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names in LIST This feature can be enabled by setting LDSO_STANDALONE_SUPPORT=y Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/misc/internals')
-rw-r--r--libc/misc/internals/__uClibc_main.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 58f6643b2..36c0c6c63 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -153,6 +153,10 @@ extern void (*__fini_array_end []) (void) attribute_hidden;
# endif
#endif
+#if defined (__LDSO_STANDALONE_SUPPORT__) && defined (SHARED) && defined __sh__
+extern unsigned long _dl_skip_args;
+#endif
+
attribute_hidden const char *__uclibc_progname = "";
#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
const char *program_invocation_short_name = "";
@@ -341,11 +345,23 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc,
__rtld_fini = rtld_fini;
+#if defined __LDSO_STANDALONE_SUPPORT__ && defined SHARED && defined __sh__
+ /*
+ * Skip ld.so and its arguments
+ * Other archs except for SH do this in _dl_start before passing
+ * control to the application.
+ * FIXME: align SH _dl_start to other archs and remove this from here,
+ * so that we can keep the visibility hidden.
+ */
+ argc -= _dl_skip_args;
+ argv += _dl_skip_args;
+#endif
+
/* The environment begins right after argv. */
__environ = &argv[argc + 1];
/* If the first thing after argv is the arguments
- * the the environment is empty. */
+ * then the environment is empty. */
if ((char *) __environ == *argv) {
/* Make __environ point to the NULL at argv[argc] */
__environ = &argv[argc];