[PATCH 04/10] objtool: check: Ignore empty alternative groups

From: Julien Thierry
Date: Wed Mar 25 2020 - 04:42:49 EST


Atlernative section can contain entries for alternatives with no
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>
---
tools/objtool/check.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 0ccf6882d8ce..75ebaa0a6216 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -917,6 +917,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)
--
2.21.1