|
|
e354a5 |
commit 9590a71adcf134c77f2d0f5711b0d6ab1b4193e6
|
|
|
e354a5 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
e354a5 |
Date: Thu Oct 8 10:57:10 2020 +0200
|
|
|
e354a5 |
|
|
|
e354a5 |
elf: Move ld.so error/help output to _dl_usage
|
|
|
e354a5 |
|
|
|
e354a5 |
Also add a comment to elf/Makefile, explaining why we cannot use
|
|
|
e354a5 |
config.status for autoconf template processing.
|
|
|
e354a5 |
|
|
|
e354a5 |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
e354a5 |
|
|
|
e354a5 |
diff --git a/elf/Makefile b/elf/Makefile
|
|
|
e354a5 |
index e2078f6bc325b7e0..e5666e5bf7817c3c 100644
|
|
|
e354a5 |
--- a/elf/Makefile
|
|
|
e354a5 |
+++ b/elf/Makefile
|
|
|
e354a5 |
@@ -59,7 +59,7 @@ elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin \
|
|
|
e354a5 |
# ld.so uses those routines, plus some special stuff for being the program
|
|
|
e354a5 |
# interpreter and operating independent of libc.
|
|
|
e354a5 |
rtld-routines = rtld $(all-dl-routines) dl-sysdep dl-environ dl-minimal \
|
|
|
e354a5 |
- dl-error-minimal dl-conflict dl-hwcaps
|
|
|
e354a5 |
+ dl-error-minimal dl-conflict dl-hwcaps dl-usage
|
|
|
e354a5 |
all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
|
|
|
e354a5 |
|
|
|
e354a5 |
CFLAGS-dl-runtime.c += -fexceptions -fasynchronous-unwind-tables
|
|
|
e354a5 |
@@ -598,6 +598,12 @@ ldso_install: $(inst_rtlddir)/$(rtld-installed-name)
|
|
|
e354a5 |
endif
|
|
|
e354a5 |
|
|
|
e354a5 |
|
|
|
e354a5 |
+# Workarounds for ${exec_prefix} expansion in configure variables.
|
|
|
e354a5 |
+# config.status cannot be used directly for processing ldd.bash.in or
|
|
|
e354a5 |
+# expanding variables such as sysconfdir because the expansion
|
|
|
e354a5 |
+# contains the literal string ${exec_prefix}, which is not valid in C
|
|
|
e354a5 |
+# headers or installed shell scripts.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
ldd-rewrite = -e 's%@RTLD@%$(rtlddir)/$(rtld-installed-name)%g' \
|
|
|
e354a5 |
-e 's%@VERSION@%$(version)%g' \
|
|
|
e354a5 |
-e 's|@PKGVERSION@|$(PKGVERSION)|g' \
|
|
|
e354a5 |
@@ -635,6 +641,7 @@ libof-ldconfig = ldconfig
|
|
|
e354a5 |
CFLAGS-dl-cache.c += $(SYSCONF-FLAGS)
|
|
|
e354a5 |
CFLAGS-cache.c += $(SYSCONF-FLAGS)
|
|
|
e354a5 |
CFLAGS-rtld.c += $(SYSCONF-FLAGS)
|
|
|
e354a5 |
+CFLAGS-dl-usage.c += $(SYSCONF-FLAGS)
|
|
|
e354a5 |
|
|
|
e354a5 |
cpp-srcs-left := $(all-rtld-routines:=.os)
|
|
|
e354a5 |
lib := rtld
|
|
|
e354a5 |
diff --git a/elf/dl-main.h b/elf/dl-main.h
|
|
|
e354a5 |
index bcc9bcf2e8fee6e7..b01f433f9c8d9e1a 100644
|
|
|
e354a5 |
--- a/elf/dl-main.h
|
|
|
e354a5 |
+++ b/elf/dl-main.h
|
|
|
e354a5 |
@@ -19,7 +19,9 @@
|
|
|
e354a5 |
#ifndef _DL_MAIN
|
|
|
e354a5 |
#define _DL_MAIN
|
|
|
e354a5 |
|
|
|
e354a5 |
+#include <ldsodefs.h>
|
|
|
e354a5 |
#include <limits.h>
|
|
|
e354a5 |
+#include <stdlib.h>
|
|
|
e354a5 |
|
|
|
e354a5 |
/* Length limits for names and paths, to protect the dynamic linker,
|
|
|
e354a5 |
particularly when __libc_enable_secure is active. */
|
|
|
e354a5 |
@@ -95,4 +97,7 @@ call_init_paths (const struct dl_main_state *state)
|
|
|
e354a5 |
_dl_init_paths (state->library_path);
|
|
|
e354a5 |
}
|
|
|
e354a5 |
|
|
|
e354a5 |
+/* Print ld.so usage information and exit. */
|
|
|
e354a5 |
+_Noreturn void _dl_usage (void) attribute_hidden;
|
|
|
e354a5 |
+
|
|
|
e354a5 |
#endif /* _DL_MAIN */
|
|
|
e354a5 |
diff --git a/elf/dl-usage.c b/elf/dl-usage.c
|
|
|
e354a5 |
new file mode 100644
|
|
|
e354a5 |
index 0000000000000000..f3d89d22b71d7d12
|
|
|
e354a5 |
--- /dev/null
|
|
|
e354a5 |
+++ b/elf/dl-usage.c
|
|
|
e354a5 |
@@ -0,0 +1,51 @@
|
|
|
e354a5 |
+/* Print usage information and help for ld.so.
|
|
|
e354a5 |
+ Copyright (C) 1995-2020 Free Software Foundation, Inc.
|
|
|
e354a5 |
+ This file is part of the GNU C Library.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
e354a5 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
e354a5 |
+ License as published by the Free Software Foundation; either
|
|
|
e354a5 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
e354a5 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e354a5 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
e354a5 |
+ Lesser General Public License for more details.
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
e354a5 |
+ License along with the GNU C Library; if not, see
|
|
|
e354a5 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+#include <dl-cache.h>
|
|
|
e354a5 |
+#include <dl-main.h>
|
|
|
e354a5 |
+#include <ldsodefs.h>
|
|
|
e354a5 |
+
|
|
|
e354a5 |
+void
|
|
|
e354a5 |
+_dl_usage (void)
|
|
|
e354a5 |
+{
|
|
|
e354a5 |
+ _dl_fatal_printf ("\
|
|
|
e354a5 |
+Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]\n\
|
|
|
e354a5 |
+You have invoked `ld.so', the helper program for shared library executables.\n\
|
|
|
e354a5 |
+This program usually lives in the file `/lib/ld.so', and special directives\n\
|
|
|
e354a5 |
+in executable files using ELF shared libraries tell the system's program\n\
|
|
|
e354a5 |
+loader to load the helper program from this file. This helper program loads\n\
|
|
|
e354a5 |
+the shared libraries needed by the program executable, prepares the program\n\
|
|
|
e354a5 |
+to run, and runs it. You may invoke this helper program directly from the\n\
|
|
|
e354a5 |
+command line to load and run an ELF executable file; this is like executing\n\
|
|
|
e354a5 |
+that file itself, but always uses this helper program from the file you\n\
|
|
|
e354a5 |
+specified, instead of the helper program file specified in the executable\n\
|
|
|
e354a5 |
+file you run. This is mostly of use for maintainers to test new versions\n\
|
|
|
e354a5 |
+of this helper program; chances are you did not intend to run this program.\n\
|
|
|
e354a5 |
+\n\
|
|
|
e354a5 |
+ --list list all dependencies and how they are resolved\n\
|
|
|
e354a5 |
+ --verify verify that given object really is a dynamically linked\n\
|
|
|
e354a5 |
+ object we can handle\n\
|
|
|
e354a5 |
+ --inhibit-cache Do not use " LD_SO_CACHE "\n\
|
|
|
e354a5 |
+ --library-path PATH use given PATH instead of content of the environment\n\
|
|
|
e354a5 |
+ variable LD_LIBRARY_PATH\n\
|
|
|
e354a5 |
+ --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\
|
|
|
e354a5 |
+ in LIST\n\
|
|
|
e354a5 |
+ --audit LIST use objects named in LIST as auditors\n\
|
|
|
e354a5 |
+ --preload LIST preload objects named in LIST\n\
|
|
|
e354a5 |
+ --argv0 STRING set argv[0] to STRING before running\n");
|
|
|
e354a5 |
+}
|
|
|
e354a5 |
diff --git a/elf/rtld.c b/elf/rtld.c
|
|
|
e354a5 |
index fbfa441bf3b050ff..a12a56b550bbc837 100644
|
|
|
e354a5 |
--- a/elf/rtld.c
|
|
|
e354a5 |
+++ b/elf/rtld.c
|
|
|
e354a5 |
@@ -1240,31 +1240,7 @@ dl_main (const ElfW(Phdr) *phdr,
|
|
|
e354a5 |
/* If we have no further argument the program was called incorrectly.
|
|
|
e354a5 |
Grant the user some education. */
|
|
|
e354a5 |
if (_dl_argc < 2)
|
|
|
e354a5 |
- _dl_fatal_printf ("\
|
|
|
e354a5 |
-Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]\n\
|
|
|
e354a5 |
-You have invoked `ld.so', the helper program for shared library executables.\n\
|
|
|
e354a5 |
-This program usually lives in the file `/lib/ld.so', and special directives\n\
|
|
|
e354a5 |
-in executable files using ELF shared libraries tell the system's program\n\
|
|
|
e354a5 |
-loader to load the helper program from this file. This helper program loads\n\
|
|
|
e354a5 |
-the shared libraries needed by the program executable, prepares the program\n\
|
|
|
e354a5 |
-to run, and runs it. You may invoke this helper program directly from the\n\
|
|
|
e354a5 |
-command line to load and run an ELF executable file; this is like executing\n\
|
|
|
e354a5 |
-that file itself, but always uses this helper program from the file you\n\
|
|
|
e354a5 |
-specified, instead of the helper program file specified in the executable\n\
|
|
|
e354a5 |
-file you run. This is mostly of use for maintainers to test new versions\n\
|
|
|
e354a5 |
-of this helper program; chances are you did not intend to run this program.\n\
|
|
|
e354a5 |
-\n\
|
|
|
e354a5 |
- --list list all dependencies and how they are resolved\n\
|
|
|
e354a5 |
- --verify verify that given object really is a dynamically linked\n\
|
|
|
e354a5 |
- object we can handle\n\
|
|
|
e354a5 |
- --inhibit-cache Do not use " LD_SO_CACHE "\n\
|
|
|
e354a5 |
- --library-path PATH use given PATH instead of content of the environment\n\
|
|
|
e354a5 |
- variable LD_LIBRARY_PATH\n\
|
|
|
e354a5 |
- --inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\
|
|
|
e354a5 |
- in LIST\n\
|
|
|
e354a5 |
- --audit LIST use objects named in LIST as auditors\n\
|
|
|
e354a5 |
- --preload LIST preload objects named in LIST\n\
|
|
|
e354a5 |
- --argv0 STRING set argv[0] to STRING before running\n");
|
|
|
e354a5 |
+ _dl_usage ();
|
|
|
e354a5 |
|
|
|
e354a5 |
++_dl_skip_args;
|
|
|
e354a5 |
--_dl_argc;
|