objtool/klp: Fix bug table handling for __WARN_printf()

Running objtool klp-diff on a changed function which uses WARN() can
fail with:

vmlinux.o: error: objtool: md_run+0x866: failed to convert reloc sym '__bug_table' to its proper format

The problem is that since commit 5b472b6e5bd9 ("x86_64/bug: Implement
__WARN_printf()"), each __WARN_printf() call site now directly
references its bug table entry. klp-diff errors out when it can't
convert such section-based references to object symbols (because bug
table entries don't have symbols).

Luckily, klp-diff already has code to create symbols for bug table
entries. Move that code earlier, before function diffing.

Fixes: dd590d4d57eb ("objtool/klp: Introduce klp diff subcommand for diffing object files")
Fixes: 5b472b6e5bd9 ("x86_64/bug: Implement __WARN_printf()")
Reported-by: Song Liu <song@kernel.org>
Tested-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/a8e0a714b9da962858842b9aecd63b4900927c88.1769406850.git.jpoimboe@kernel.org
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

+11 -3
+11 -3
tools/objtool/klp-diff.c
··· 1425 { 1426 struct section *patched_sec; 1427 1428 - if (create_fake_symbols(e->patched)) 1429 - return -1; 1430 - 1431 for_each_sec(e->patched, patched_sec) { 1432 if (is_special_section(patched_sec)) { 1433 if (clone_special_section(e, patched_sec)) ··· 1699 1700 e.out = elf_create_file(&e.orig->ehdr, argv[2]); 1701 if (!e.out) 1702 return -1; 1703 1704 if (clone_included_functions(&e))
··· 1425 { 1426 struct section *patched_sec; 1427 1428 for_each_sec(e->patched, patched_sec) { 1429 if (is_special_section(patched_sec)) { 1430 if (clone_special_section(e, patched_sec)) ··· 1702 1703 e.out = elf_create_file(&e.orig->ehdr, argv[2]); 1704 if (!e.out) 1705 + return -1; 1706 + 1707 + /* 1708 + * Special section fake symbols are needed so that individual special 1709 + * section entries can be extracted by clone_special_sections(). 1710 + * 1711 + * Note the fake symbols are also needed by clone_included_functions() 1712 + * because __WARN_printf() call sites add references to bug table 1713 + * entries in the calling functions. 1714 + */ 1715 + if (create_fake_symbols(e.patched)) 1716 return -1; 1717 1718 if (clone_included_functions(&e))