elfctl: allow features to be specified by value
This will allow elfctl on older releases to set bits that are not yet known there, so that the binary will have the correct settings applied if run on a later FreeBSD version. PR: 252629 (related) Suggested by: kib Reviewed by: gbe (manpage, earlier), kib MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28284
This commit is contained in:
parent
57a543d8b8
commit
86f33b5fcf
@ -26,7 +26,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd January 12, 2021
|
.Dd January 22, 2021
|
||||||
.Dt ELFCTL 1
|
.Dt ELFCTL 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -64,7 +64,8 @@ to turn on the features,
|
|||||||
to turn off the features,
|
to turn off the features,
|
||||||
.Dq Li =
|
.Dq Li =
|
||||||
to only turn on the given features.
|
to only turn on the given features.
|
||||||
A comma separated list of feature names follows the operation.
|
A comma separated list of feature names or numeric values follows the
|
||||||
|
operation.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
If
|
If
|
||||||
@ -86,6 +87,16 @@ command:
|
|||||||
elfctl file
|
elfctl file
|
||||||
elfctl -e +aslr file
|
elfctl -e +aslr file
|
||||||
.Ed
|
.Ed
|
||||||
|
.Pp
|
||||||
|
Features may be specified as numerical values:
|
||||||
|
.Bd -literal -offset -indent
|
||||||
|
elfctl -e =0x0001,0x0004 file
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
Features may also be specified as a single combined value:
|
||||||
|
.Bd -literal -offset -indent
|
||||||
|
elfctl -e =0x5 file
|
||||||
|
.Ed
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
.Nm
|
.Nm
|
||||||
first appeared in
|
first appeared in
|
||||||
|
@ -33,7 +33,9 @@
|
|||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <gelf.h>
|
#include <gelf.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
@ -245,9 +247,26 @@ convert_to_feature_val(char *feature_str, uint32_t *feature_val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == len) {
|
if (i == len) {
|
||||||
warnx("%s is not a valid feature", feature);
|
if (isdigit(feature[0])) {
|
||||||
if (!iflag)
|
char *eptr;
|
||||||
return (false);
|
long val;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
val = strtol(feature, &eptr, 0);
|
||||||
|
if (eptr == feature || *eptr != '\0')
|
||||||
|
errno = EINVAL;
|
||||||
|
else if (val > UINT_MAX)
|
||||||
|
errno = ERANGE;
|
||||||
|
if (errno != 0) {
|
||||||
|
warn("%s invalid", feature);
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
input != val;
|
||||||
|
} else {
|
||||||
|
warnx("%s is not a valid feature", feature);
|
||||||
|
if (!iflag)
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user