Skip to contentSkip to conversation

objtool: fix segfault when missing '.shstrtab' section

PATCH New emersion 1 participant 1 message Dec 29, 2017 objtool

lore
Share & tools
lore

emersion

author
#0 lore raw

PATCH 1/1 objtool: fix segfault when missing '.shstrtab' section

This segfault happens when an input file provided to 'objtool orc generate' doesn't have a '.shstrtab' section (for instance, object files produced by clang don't have this section).

---
 tools/objtool/orc_gen.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/objtool/orc_gen.c +2 -1
index e5ca31429..188f18185 100644
@@ -165,7 +165,8 @@ int create_orc_sections(struct objtool_file *file)
 
 	/* create .orc_unwind_ip and .rela.orc_unwind_ip sections */
 	sec = elf_create_section(file->elf, ".orc_unwind_ip", sizeof(int), idx);
-
+	if (!sec)
+		return -1;
 	ip_relasec = elf_create_rela_section(file->elf, sec);
 	if (!ip_relasec)
 		return -1;
Signature · 1 line
2.15.1