elfedit: Report unknown x86 feature

Message ID CAMe9rOq7pP4SDgCgp3iGimCoX6m2r1e1sXyTYNTA20sKMVx9RQ@mail.gmail.com
State New
Headers show
Series
  • elfedit: Report unknown x86 feature
Related show

Commit Message

H.J. Lu Oct. 25, 2019, 10:15 p.m.
Report unknown x86 feature:

$ ./elfedit --disable-x86-feature foo a.out
elfedit: Error: Unknown x86 feature: foo
$

* elfedit.c (elf_x86_feature): Report unknown x86 feature.

-- 
H.J.

Patch

From 760ddef46d443b41086292831f78a71ea6b7b1ab Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 25 Oct 2019 15:13:21 -0700
Subject: [PATCH] elfedit: Report unknown x86 feature

Report unknown x86 feature:

$ ./elfedit --disable-x86-feature foo a.out
elfedit: Error: Unknown x86 feature: foo
$

	* elfedit.c (elf_x86_feature): Report unknown x86 feature.
---
 binutils/ChangeLog | 4 ++++
 binutils/elfedit.c | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 6c5143d30e..7a56ce4abd 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,7 @@ 
+2019-10-25  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elfedit.c (elf_x86_feature): Report unknown x86 feature.
+
 2019-10-25  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* elfedit.c (update_gnu_property): Replace BYTE_PUT with byte_put.
diff --git a/binutils/elfedit.c b/binutils/elfedit.c
index 5c0d711e8b..da1984e5b1 100644
--- a/binutils/elfedit.c
+++ b/binutils/elfedit.c
@@ -260,7 +260,10 @@  elf_x86_feature (const char *feature, int enable)
   else if (strcasecmp (feature, "shstk") == 0)
     x86_feature = GNU_PROPERTY_X86_FEATURE_1_SHSTK;
   else
-    return -1;
+    {
+      error (_("Unknown x86 feature: %s\n"), feature);
+      return -1;
+    }
 
   if (enable)
     {
-- 
2.21.0