From owner-svn-src-head@freebsd.org Sun May 31 21:53:16 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 36A5A2F315C; Sun, 31 May 2020 21:53:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49ZsW00jnGz41pR; Sun, 31 May 2020 21:53:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 13BB620EC4; Sun, 31 May 2020 21:53:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04VLrF6k015729; Sun, 31 May 2020 21:53:15 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04VLrF0a015727; Sun, 31 May 2020 21:53:15 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202005312153.04VLrF0a015727@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 31 May 2020 21:53:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361675 - head/libexec/rtld-elf X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/libexec/rtld-elf X-SVN-Commit-Revision: 361675 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 May 2020 21:53:16 -0000 Author: kib Date: Sun May 31 21:53:15 2020 New Revision: 361675 URL: https://svnweb.freebsd.org/changeset/base/361675 Log: rtld: Add -v switch to print some useful information about the rtld binary. Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/libexec/rtld-elf/rtld.1 head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.1 ============================================================================== --- head/libexec/rtld-elf/rtld.1 Sun May 31 21:43:59 2020 (r361674) +++ head/libexec/rtld-elf/rtld.1 Sun May 31 21:53:15 2020 (r361675) @@ -333,6 +333,8 @@ character, uses the search path provided by the environment variable .Dv PATH to find the binary to execute. +.It Fl v +Display information about this run-time linker binary, then exit. .It Fl - Ends the .Nm Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Sun May 31 21:43:59 2020 (r361674) +++ head/libexec/rtld-elf/rtld.c Sun May 31 21:53:15 2020 (r361675) @@ -5613,7 +5613,9 @@ static int parse_args(char* argv[], int argc, bool *use_pathp, int *fdp) { const char *arg; - int fd, i, j, arglen; + char machine[64]; + size_t sz; + int arglen, fd, i, j, mib[2]; char opt; dbg("Parsing command-line arguments"); @@ -5672,6 +5674,24 @@ parse_args(char* argv[], int argc, bool *use_pathp, in break; } else if (opt == 'p') { *use_pathp = true; + } else if (opt == 'v') { + machine[0] = '\0'; + mib[0] = CTL_HW; + mib[1] = HW_MACHINE; + sz = sizeof(machine); + sysctl(mib, nitems(mib), machine, &sz, NULL, 0); + rtld_printf( + "FreeBSD ld-elf.so.1 %s\n" + "FreeBSD_version %d\n" + "Default lib path %s\n" + "Env prefix %s\n" + "Hint file %s\n" + "libmap file %s\n", + machine, + __FreeBSD_version, ld_standard_library_path, + ld_env_prefix, ld_elf_hints_default, + ld_path_libmap_conf); + _exit(0); } else { _rtld_error("Invalid argument: '%s'", arg); print_usage(argv[0]); @@ -5720,6 +5740,7 @@ print_usage(const char *argv0) " -h Display this help message\n" " -f Execute instead of searching for \n" " -p Search in PATH for named binary\n" + " -v Display identification information\n" " -- End of RTLD options\n" " Name of process to execute\n" " Arguments to the executed process\n", argv0);