diff options
author | Florian Weimer <fweimer@redhat.com> | 2020-10-08 10:57:10 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2020-10-08 15:00:39 +0200 |
commit | e0f1a58f3d1f4f55591b524e9dcff23cc98a509e (patch) | |
tree | cd744b7405d8793811595fc9d7020ef354e1e2d6 /elf/dl-usage.c | |
parent | 27316f4a23efdc90bdfe4569a6c4b7e27941606e (diff) | |
download | glibc-e0f1a58f3d1f4f55591b524e9dcff23cc98a509e.tar.gz glibc-e0f1a58f3d1f4f55591b524e9dcff23cc98a509e.tar.xz glibc-e0f1a58f3d1f4f55591b524e9dcff23cc98a509e.zip |
elf: Implement ld.so --help
--help processing is deferred to the point where the executable has been loaded, so that it is possible to eventually include information from the main executable in the help output. As suggested in the GNU command-line interface guidelines, the help message is printed to standard output, and the exit status is successful. Handle usage errors closer to the GNU command-line interface guidelines. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf/dl-usage.c')
-rw-r--r-- | elf/dl-usage.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/elf/dl-usage.c b/elf/dl-usage.c index f3d89d22b7..c1820dca2f 100644 --- a/elf/dl-usage.c +++ b/elf/dl-usage.c @@ -19,12 +19,24 @@ #include <dl-cache.h> #include <dl-main.h> #include <ldsodefs.h> +#include <unistd.h> void -_dl_usage (void) +_dl_usage (const char *argv0, const char *wrong_option) { - _dl_fatal_printf ("\ -Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]\n\ + if (wrong_option != NULL) + _dl_error_printf ("%s: unrecognized option '%s'\n", argv0, wrong_option); + else + _dl_error_printf ("%s: missing program name\n", argv0); + _dl_error_printf ("Try '%s --help' for more information.\n", argv0); + _exit (EXIT_FAILURE); +} + +void +_dl_help (const char *argv0, struct dl_main_state *state) +{ + _dl_printf ("\ +Usage: %s [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]\n\ You have invoked `ld.so', the helper program for shared library executables.\n\ This program usually lives in the file `/lib/ld.so', and special directives\n\ in executable files using ELF shared libraries tell the system's program\n\ @@ -47,5 +59,9 @@ of this helper program; chances are you did not intend to run this program.\n\ in LIST\n\ --audit LIST use objects named in LIST as auditors\n\ --preload LIST preload objects named in LIST\n\ - --argv0 STRING set argv[0] to STRING before running\n"); + --argv0 STRING set argv[0] to STRING before running\n\ + --help display this help and exit\n\ +", + argv0); + _exit (EXIT_SUCCESS); } |