With the following commit:

  2a0098d70640 ("objtool: Fix seg fault with gold linker")

... objtool warnings started showing the modversions '.tmp_' prefix in
the .o file name, like:

  arch/x86/mm/.tmp_mem_encrypt_boot.o: warning: objtool: 
sme_encrypt_execute()+0x48: indirect call found in RETPOLINE build

The prefix is confusing.  Remove it from the printed 'objname' variable.

Fixes: 2a0098d70640 ("objtool: Fix seg fault with gold linker")
Signed-off-by: Josh Poimboeuf <jpoim...@redhat.com>
---
 tools/objtool/check.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 9cd028aa1509..0bf61db0498a 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1978,6 +1978,25 @@ static void cleanup(struct objtool_file *file)
        elf_close(file->elf);
 }
 
+/*
+ * With CONFIG_MODVERSIONS, the object name has '.tmp_' prepended to it.
+ * After the file has been opened, remove the prefix so warnings will look
+ * sensible.
+ */
+static void fix_objname(void)
+{
+       char *s;
+
+       s = strstr(objname, ".tmp_");
+       if (!s)
+               return;
+
+       for (; s[5]; s++)
+               s[0] = s[5];
+
+       s[0] = 0;
+}
+
 int check(const char *_objname, bool _no_fp, bool no_unreachable, bool orc)
 {
        struct objtool_file file;
@@ -1990,6 +2009,8 @@ int check(const char *_objname, bool _no_fp, bool 
no_unreachable, bool orc)
        if (!file.elf)
                return 1;
 
+       fix_objname();
+
        INIT_LIST_HEAD(&file.insn_list);
        hash_init(file.insn_hash);
        file.whitelist = find_section_by_name(file.elf, 
".discard.func_stack_frame_non_standard");
-- 
2.14.3

Reply via email to