|
|
b1dca6 |
commit 542923d949e8b2480e48bd85fea13cf5d00d30b7
|
|
|
b1dca6 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
b1dca6 |
Date: Thu Oct 8 15:33:00 2020 +0200
|
|
|
b1dca6 |
|
|
|
b1dca6 |
elf: Implement ld.so --version
|
|
|
b1dca6 |
|
|
|
b1dca6 |
This prints out version information for the dynamic loader and
|
|
|
b1dca6 |
exits immediately, without further command line processing
|
|
|
b1dca6 |
(which seems to match what some GNU tools do).
|
|
|
b1dca6 |
|
|
|
b1dca6 |
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
b1dca6 |
|
|
|
b1dca6 |
diff --git a/elf/dl-main.h b/elf/dl-main.h
|
|
|
b1dca6 |
index ac7249a580214860..b51256d3b48230b0 100644
|
|
|
b1dca6 |
--- a/elf/dl-main.h
|
|
|
b1dca6 |
+++ b/elf/dl-main.h
|
|
|
b1dca6 |
@@ -105,6 +105,9 @@ call_init_paths (const struct dl_main_state *state)
|
|
|
b1dca6 |
_Noreturn void _dl_usage (const char *argv0, const char *wrong_option)
|
|
|
b1dca6 |
attribute_hidden;
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+/* Print ld.so version information and exit. */
|
|
|
b1dca6 |
+_Noreturn void _dl_version (void) attribute_hidden;
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
/* Print ld.so --help output and exit. */
|
|
|
b1dca6 |
_Noreturn void _dl_help (const char *argv0, struct dl_main_state *state)
|
|
|
b1dca6 |
attribute_hidden;
|
|
|
b1dca6 |
diff --git a/elf/dl-usage.c b/elf/dl-usage.c
|
|
|
b1dca6 |
index c1820dca2fa117ee..f3c5ac76d37f9c03 100644
|
|
|
b1dca6 |
--- a/elf/dl-usage.c
|
|
|
b1dca6 |
+++ b/elf/dl-usage.c
|
|
|
b1dca6 |
@@ -20,6 +20,7 @@
|
|
|
b1dca6 |
#include <dl-main.h>
|
|
|
b1dca6 |
#include <ldsodefs.h>
|
|
|
b1dca6 |
#include <unistd.h>
|
|
|
b1dca6 |
+#include "version.h"
|
|
|
b1dca6 |
|
|
|
b1dca6 |
void
|
|
|
b1dca6 |
_dl_usage (const char *argv0, const char *wrong_option)
|
|
|
b1dca6 |
@@ -32,6 +33,19 @@ _dl_usage (const char *argv0, const char *wrong_option)
|
|
|
b1dca6 |
_exit (EXIT_FAILURE);
|
|
|
b1dca6 |
}
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+void
|
|
|
b1dca6 |
+_dl_version (void)
|
|
|
b1dca6 |
+{
|
|
|
b1dca6 |
+ _dl_printf ("\
|
|
|
b1dca6 |
+ld.so " PKGVERSION RELEASE " release version " VERSION ".\n\
|
|
|
b1dca6 |
+Copyright (C) 2020 Free Software Foundation, Inc.\n\
|
|
|
b1dca6 |
+This is free software; see the source for copying conditions.\n\
|
|
|
b1dca6 |
+There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
|
|
|
b1dca6 |
+PARTICULAR PURPOSE.\n\
|
|
|
b1dca6 |
+");
|
|
|
b1dca6 |
+ _exit (EXIT_SUCCESS);
|
|
|
b1dca6 |
+}
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
void
|
|
|
b1dca6 |
_dl_help (const char *argv0, struct dl_main_state *state)
|
|
|
b1dca6 |
{
|
|
|
b1dca6 |
@@ -61,6 +75,7 @@ of this helper program; chances are you did not intend to run this program.\n\
|
|
|
b1dca6 |
--preload LIST preload objects named in LIST\n\
|
|
|
b1dca6 |
--argv0 STRING set argv[0] to STRING before running\n\
|
|
|
b1dca6 |
--help display this help and exit\n\
|
|
|
b1dca6 |
+ --version output version information and exit\n\
|
|
|
b1dca6 |
",
|
|
|
b1dca6 |
argv0);
|
|
|
b1dca6 |
_exit (EXIT_SUCCESS);
|
|
|
b1dca6 |
diff --git a/elf/rtld.c b/elf/rtld.c
|
|
|
b1dca6 |
index b92641cb1c2d99a6..da1eef108508b95f 100644
|
|
|
b1dca6 |
--- a/elf/rtld.c
|
|
|
b1dca6 |
+++ b/elf/rtld.c
|
|
|
b1dca6 |
@@ -1248,6 +1248,8 @@ dl_main (const ElfW(Phdr) *phdr,
|
|
|
b1dca6 |
--_dl_argc;
|
|
|
b1dca6 |
++_dl_argv;
|
|
|
b1dca6 |
}
|
|
|
b1dca6 |
+ else if (strcmp (_dl_argv[1], "--version") == 0)
|
|
|
b1dca6 |
+ _dl_version ();
|
|
|
b1dca6 |
else if (_dl_argv[1][0] == '-' && _dl_argv[1][1] == '-')
|
|
|
b1dca6 |
{
|
|
|
b1dca6 |
if (_dl_argv[1][1] == '\0')
|