Date: Sun, 31 May 2020 21:53:15 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361675 - head/libexec/rtld-elf Message-ID: <202005312153.04VLrF0a015727@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <FD> Execute <FD> instead of searching for <binary>\n" " -p Search in PATH for named binary\n" + " -v Display identification information\n" " -- End of RTLD options\n" " <binary> Name of process to execute\n" " <args> Arguments to the executed process\n", argv0);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005312153.04VLrF0a015727>