public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/fw/glibc-hwcaps] elf: Implement ld.so --version
@ 2020-10-01 16:53 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2020-10-01 16:53 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7333a9c583135f6660716d67c05da78a65df0aea

commit 7333a9c583135f6660716d67c05da78a65df0aea
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Jun 8 16:51:06 2020 +0200

    elf: Implement ld.so --version
    
    This prints out version information for the dynamic loader and
    exits immediately, without further command line processing
    (which seems to match what some GNU tools do).

Diff:
---
 elf/dl-main.h  |  3 +++
 elf/dl-usage.c | 15 +++++++++++++++
 elf/rtld.c     |  2 ++
 3 files changed, 20 insertions(+)

diff --git a/elf/dl-main.h b/elf/dl-main.h
index 71ca5114de..0df849d3cd 100644
--- a/elf/dl-main.h
+++ b/elf/dl-main.h
@@ -101,6 +101,9 @@ call_init_paths (const struct dl_main_state *state)
 void _dl_usage (const char *argv0, const char *wrong_option)
   attribute_hidden __attribute__ ((__noreturn__));
 
+/* Print ld.so version information and exit.  */
+void _dl_version (void) attribute_hidden __attribute__ ((__noreturn__));
+
 /* Print ld.so --help output and exit.  */
 void _dl_help (const char *argv0, struct dl_main_state *state)
   attribute_hidden __attribute__ ((__noreturn__));
diff --git a/elf/dl-usage.c b/elf/dl-usage.c
index 72ff99e70f..7355b094a5 100644
--- a/elf/dl-usage.c
+++ b/elf/dl-usage.c
@@ -20,6 +20,7 @@
 #include <dl-main.h>
 #include <ldsodefs.h>
 #include <unistd.h>
+#include "version.h"
 
 void
 _dl_usage (const char *argv0, const char *wrong_option)
@@ -32,6 +33,19 @@ _dl_usage (const char *argv0, const char *wrong_option)
   _exit (1);
 }
 
+void
+_dl_version (void)
+{
+  _dl_printf ("\
+ld.so " PKGVERSION RELEASE " release version " VERSION ".\n\
+Copyright (C) 2020 Free Software Foundation, Inc.\n\
+This is free software; see the source for copying conditions.\n\
+There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
+PARTICULAR PURPOSE.\n\
+");
+  _exit (0);
+}
+
 void
 _dl_help (const char *argv0, struct dl_main_state *state)
 {
@@ -61,6 +75,7 @@ of this helper program; chances are you did not intend to run this program.\n\
   --preload LIST        preload objects named in LIST\n\
   --argv0 STRING        set argv[0] to STRING before running\n\
   --help                display this help and exit\n\
+  --version             output version information and exit\n\
 ",
               argv0);
   _exit (0);
diff --git a/elf/rtld.c b/elf/rtld.c
index 5cdab3c99c..e0e8e98c2f 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1254,6 +1254,8 @@ dl_main (const ElfW(Phdr) *phdr,
 	    --_dl_argc;
 	    ++_dl_argv;
 	  }
+	else if (strcmp (_dl_argv[1], "--version") == 0)
+	  _dl_version ();
 	else if (_dl_argv[1][0] == '-' && _dl_argv[1][1] == '-')
 	  {
 	   if (_dl_argv[1][1] == '\0')


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-01 16:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01 16:53 [glibc/fw/glibc-hwcaps] elf: Implement ld.so --version Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).