From owner-dev-commits-src-main@freebsd.org Mon Aug 30 14:57:13 2021 Return-Path: Delivered-To: dev-commits-src-main@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 01ADF677F11; Mon, 30 Aug 2021 14:57:13 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GythS6bFnz4v4h; Mon, 30 Aug 2021 14:57:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C6B461FE8D; Mon, 30 Aug 2021 14:57:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17UEvCOW008781; Mon, 30 Aug 2021 14:57:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17UEvCRv008780; Mon, 30 Aug 2021 14:57:12 GMT (envelope-from git) Date: Mon, 30 Aug 2021 14:57:12 GMT Message-Id: <202108301457.17UEvCRv008780@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 4d0dc60f1401 - main - xinstall: fix invocation of llvm-strip MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4d0dc60f14019eab08f6d9dc656c9f9f1ebdde02 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2021 14:57:13 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=4d0dc60f14019eab08f6d9dc656c9f9f1ebdde02 commit 4d0dc60f14019eab08f6d9dc656c9f9f1ebdde02 Author: Mitchell Horne AuthorDate: 2021-06-02 15:00:56 +0000 Commit: Mitchell Horne CommitDate: 2021-08-30 14:56:10 +0000 xinstall: fix invocation of llvm-strip When executing strip(1), '--' is passed as an argument to explicitly terminate the getopt(3) loop. The option parsing in llvm-strip doesn't support this however, so setting XSTRIPBIN=llvm-strip results in an unsupported argument error. llvm-strip(1) is otherwise commandline-compatible with FreeBSD's strip(1), so just use the documented argument format that is common to both. Special care needs to be taken for filenames beginning with a '-'. Reviewed by: arichardson, eugen (earlier version, both) Discussed with: jilles Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30614 --- usr.bin/xinstall/xinstall.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 114614abd16f..05b1444506db 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -1306,7 +1306,7 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name, * strip -- * Use strip(1) to strip the target file. * Just invoke strip(1) on to_name if from_name is NULL, else try - * to run "strip -o to_name -- from_name" and return 0 on failure. + * to run "strip -o to_name from_name" and return 0 on failure. * Return 1 on success and assign result of digest_file(to_name) * to *dresp. */ @@ -1314,10 +1314,12 @@ static int strip(const char *to_name, int to_fd, const char *from_name, char **dresp) { const char *stripbin; - const char *args[6]; + const char *args[5]; + char *prefixed_from_name; pid_t pid; int error, serrno, status; + prefixed_from_name = NULL; stripbin = getenv("STRIPBIN"); if (stripbin == NULL) stripbin = "strip"; @@ -1328,9 +1330,16 @@ strip(const char *to_name, int to_fd, const char *from_name, char **dresp) } else { args[1] = "-o"; args[2] = to_name; - args[3] = "--"; - args[4] = from_name; - args[5] = NULL; + + /* Prepend './' if from_name begins with '-' */ + if (from_name[0] == '-') { + if (asprintf(&prefixed_from_name, "./%s", from_name) == -1) + return (0); + args[3] = prefixed_from_name; + } else { + args[3] = from_name; + } + args[4] = NULL; } error = posix_spawnp(&pid, stripbin, NULL, NULL, __DECONST(char **, args), environ); @@ -1339,6 +1348,7 @@ strip(const char *to_name, int to_fd, const char *from_name, char **dresp) errc(error == EAGAIN || error == EPROCLIM || error == ENOMEM ? EX_TEMPFAIL : EX_OSERR, error, "spawn %s", stripbin); } + free(prefixed_from_name); if (waitpid(pid, &status, 0) == -1) { error = errno; (void)unlink(to_name);