git: f6d95a01103a - main - elftcl: add -i flag to ignore unknown flags
Ed Maste
emaste at FreeBSD.org
Wed Jan 13 05:12:20 UTC 2021
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=f6d95a01103a49a94c876d5a51bb4be25c06d964
commit f6d95a01103a49a94c876d5a51bb4be25c06d964
Author: Ed Maste <emaste at FreeBSD.org>
AuthorDate: 2021-01-13 03:24:52 +0000
Commit: Ed Maste <emaste at FreeBSD.org>
CommitDate: 2021-01-13 05:10:13 +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
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28130
---
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 e9b93e697ef7..9d75c002d82c 100644
--- a/usr.bin/elfctl/elfctl.c
+++ b/usr.bin/elfctl/elfctl.c
@@ -81,7 +81,9 @@ static struct option long_opts[] = {
#else
#define SUPPORTED_ENDIAN ELFDATA2MSB
#endif
-
+
+static bool iflag;
+
int
main(int argc, char **argv)
{
@@ -100,8 +102,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;
@@ -197,6 +202,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"
@@ -229,7 +235,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);
}
}
More information about the dev-commits-src-main
mailing list