[tip: objtool/core] objtool: Ignore empty alternatives

From: tip-bot2 for Julien Thierry
Date: Thu Apr 23 2020 - 03:50:07 EST


The following commit has been merged into the objtool/core branch of tip:

Commit-ID: 7170cf47d16f1ba29eca07fd818870b7af0a93a5
Gitweb: https://git.kernel.org/tip/7170cf47d16f1ba29eca07fd818870b7af0a93a5
Author: Julien Thierry <jthierry@xxxxxxxxxx>
AuthorDate: Fri, 27 Mar 2020 15:28:41
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Wed, 22 Apr 2020 10:53:49 +02:00

objtool: Ignore empty alternatives

The .alternatives section can contain entries with no original
instructions. Objtool will currently crash when handling such an entry.

Just skip that entry, but still give a warning to discourage useless
entries.

Signed-off-by: Julien Thierry <jthierry@xxxxxxxxxx>
Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Reviewed-by: Miroslav Benes <mbenes@xxxxxxx>
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
tools/objtool/check.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 5b67d61..efb9640 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -905,6 +905,12 @@ static int add_special_section_alts(struct objtool_file *file)
}

if (special_alt->group) {
+ if (!special_alt->orig_len) {
+ WARN_FUNC("empty alternative entry",
+ orig_insn->sec, orig_insn->offset);
+ continue;
+ }
+
ret = handle_group_alt(file, special_alt, orig_insn,
&new_insn);
if (ret)