From patchwork Thu Oct 1 16:32:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 40601 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 393BA398B875; Thu, 1 Oct 2020 16:32:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 393BA398B875 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1601569955; bh=wGq2H1jImErD36GM/mxZOD0sI7NgMXgDqEQgEIMIzl0=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=LGPlNisXBGK1ai9l+QZ2GiVmUw45nnvYJjHU12F4/oWJLunce9KsE+07ZBAY7nVAf swkTz/eDw67rRaOphBYHO9kwHY3vpsTmaC7yKQjt6oLjRfG3/fnYftQZPLYgXUkuWa aPkbhR+m4vMLKK+vM2jahbCn9TaKlMD87o86FTX0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id C266E398B836 for ; Thu, 1 Oct 2020 16:32:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C266E398B836 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-6D6f8NGBNGKlvnPu0sInlA-1; Thu, 01 Oct 2020 12:32:30 -0400 X-MC-Unique: 6D6f8NGBNGKlvnPu0sInlA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 129F31015CB4 for ; Thu, 1 Oct 2020 16:32:30 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 80B9260BFA for ; Thu, 1 Oct 2020 16:32:29 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 08/28] elf: Implement ld.so --version In-Reply-To: References: Message-Id: <7333a9c583135f6660716d67c05da78a65df0aea.1601569371.git.fweimer@redhat.com> Date: Thu, 01 Oct 2020 18:32:27 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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). Reviewed-by: Adhemerval Zanella --- 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 #include #include +#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')