From owner-dev-commits-src-branches@freebsd.org Tue Jan 19 02:50:25 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 D2F404DF0D4; Tue, 19 Jan 2021 02:50:25 +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 4DKY6n5bnMz3syy; Tue, 19 Jan 2021 02:50:25 +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 A8C151EF2A; Tue, 19 Jan 2021 02:50:25 +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 10J2oPaR010562; Tue, 19 Jan 2021 02:50:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10J2oPD0010561; Tue, 19 Jan 2021 02:50:25 GMT (envelope-from git) Date: Tue, 19 Jan 2021 02:50:25 GMT Message-Id: <202101190250.10J2oPD0010561@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 369a4023e671 - stable/12 - elftcl: add -i flag to ignore unknown flags MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 369a4023e671c35390574d42b1b409b55946faf8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2021 02:50:25 -0000 The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=369a4023e671c35390574d42b1b409b55946faf8 commit 369a4023e671c35390574d42b1b409b55946faf8 Author: Ed Maste AuthorDate: 2021-01-13 03:24:52 +0000 Commit: Ed Maste CommitDate: 2021-01-19 02:49:55 +0000 elftcl: add -i flag to ignore unknown flags This may allow an identical elfctl invocation to be used on multiple FreeBSD versions, with features not implemented on older releases being silently ignored. PR: 252629 (related) Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28130 (cherry picked from commit f6d95a01103a49a94c876d5a51bb4be25c06d964) --- usr.bin/elfctl/elfctl.1 | 6 +++++- usr.bin/elfctl/elfctl.c | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/usr.bin/elfctl/elfctl.1 b/usr.bin/elfctl/elfctl.1 index 176c2c42b22a..f93b558fdf0d 100644 --- a/usr.bin/elfctl/elfctl.1 +++ b/usr.bin/elfctl/elfctl.1 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 1, 2020 +.Dd January 12, 2021 .Dt ELFCTL 1 .Os .Sh NAME @@ -35,6 +35,7 @@ .Sh SYNOPSIS .Nm .Op Fl h | Fl -help +.Op Fl i .Op Fl l .Op Fl e Ar featurelist .Ar @@ -47,6 +48,9 @@ The options are as follows: .Bl -tag -width indent .It Fl h | Fl -help Print a usage message and exit. +.It Fl i +Ignore unknown feature flags in +.Ar featurelist . .It Fl l List known ELF feature flags. .It Fl e Ar featurelist diff --git a/usr.bin/elfctl/elfctl.c b/usr.bin/elfctl/elfctl.c index d18d828e151c..725752375d16 100644 --- a/usr.bin/elfctl/elfctl.c +++ b/usr.bin/elfctl/elfctl.c @@ -83,7 +83,9 @@ static struct option long_opts[] = { #else #define SUPPORTED_ENDIAN ELFDATA2MSB #endif - + +static bool iflag; + int main(int argc, char **argv) { @@ -102,8 +104,11 @@ main(int argc, char **argv) if (elf_version(EV_CURRENT) == EV_NONE) errx(EXIT_FAILURE, "elf_version error"); - while ((ch = getopt_long(argc, argv, "hle:", long_opts, NULL)) != -1) { + while ((ch = getopt_long(argc, argv, "hile:", long_opts, NULL)) != -1) { switch (ch) { + case 'i': + iflag = true; + break; case 'l': print_features(); lflag = true; @@ -199,6 +204,7 @@ Usage: %s [options] file...\n\ Set or display the control features for an ELF object.\n\n\ Supported options are:\n\ -l List known control features.\n\ + -i Ignore unknown features.\n\ -e [+-=]feature,list Edit features from a comma separated list.\n\ -h | --help Print a usage message and exit.\n" @@ -231,7 +237,8 @@ convert_to_feature_val(char *feature_str, uint32_t *feature_val) } if (i == len) { warnx("%s is not a valid feature", feature); - return (false); + if (!iflag) + return (false); } }