Merge tag 'objtool-urgent-2026-02-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull objtool fixes from Ingo Molnar:

- Fix a build error on ia32-x86_64 cross builds

- Replace locally open coded ALIGN_UP(), ALIGN_UP_POW2()
and MAX(), which, beyond being duplicates, the
ALIGN_UP_POW2() is also buggy

- Fix objtool klp-diff regression caused by a recent
change to the bug table format

- Fix klp-build vs CONFIG_MODULE_SRCVERSION_ALL build
failure

* tag 'objtool-urgent-2026-02-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
livepatch/klp-build: Fix klp-build vs CONFIG_MODULE_SRCVERSION_ALL
objtool/klp: Fix bug table handling for __WARN_printf()
objtool: Replace custom macros in elf.c with shared ones
objtool: Print bfd_vma as unsigned long long on ia32-x86_64 cross build

+29 -20
+4 -4
scripts/livepatch/klp-build
··· 555 555 local file_dir="$(dirname "$file")" 556 556 local orig_file="$ORIG_DIR/$rel_file" 557 557 local orig_dir="$(dirname "$orig_file")" 558 - local cmd_file="$file_dir/.$(basename "$file").cmd" 559 558 560 559 [[ ! -f "$file" ]] && die "missing $(basename "$file") for $_file" 561 560 562 561 mkdir -p "$orig_dir" 563 562 cp -f "$file" "$orig_dir" 564 - [[ -e "$cmd_file" ]] && cp -f "$cmd_file" "$orig_dir" 565 563 done 566 564 xtrace_restore 567 565 ··· 738 740 local orig_dir="$(dirname "$orig_file")" 739 741 local kmod_file="$KMOD_DIR/$rel_file" 740 742 local kmod_dir="$(dirname "$kmod_file")" 741 - local cmd_file="$orig_dir/.$(basename "$file").cmd" 743 + local cmd_file="$kmod_dir/.$(basename "$file").cmd" 742 744 743 745 mkdir -p "$kmod_dir" 744 746 cp -f "$file" "$kmod_dir" 745 - [[ -e "$cmd_file" ]] && cp -f "$cmd_file" "$kmod_dir" 746 747 747 748 # Tell kbuild this is a prebuilt object 748 749 cp -f "$file" "${kmod_file}_shipped" 750 + 751 + # Make modpost happy 752 + touch "$cmd_file" 749 753 750 754 echo -n " $rel_file" >> "$makefile" 751 755 done
+8 -6
tools/objtool/disas.c
··· 108 108 109 109 #define DINFO_FPRINTF(dinfo, ...) \ 110 110 ((*(dinfo)->fprintf_func)((dinfo)->stream, __VA_ARGS__)) 111 + #define bfd_vma_fmt \ 112 + __builtin_choose_expr(sizeof(bfd_vma) == sizeof(unsigned long), "%#lx <%s>", "%#llx <%s>") 111 113 112 114 static int disas_result_fprintf(struct disas_context *dctx, 113 115 const char *fmt, va_list ap) ··· 172 170 173 171 if (sym) { 174 172 sprint_name(symstr, sym->name, addr - sym->offset); 175 - DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, symstr); 173 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, symstr); 176 174 } else { 177 175 str = offstr(sec, addr); 178 - DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, str); 176 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, str); 179 177 free(str); 180 178 } 181 179 } ··· 254 252 * example: "lea 0x0(%rip),%rdi". The kernel can reference 255 253 * the next IP with _THIS_IP_ macro. 256 254 */ 257 - DINFO_FPRINTF(dinfo, "0x%lx <_THIS_IP_>", addr); 255 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, "_THIS_IP_"); 258 256 return; 259 257 } 260 258 ··· 266 264 */ 267 265 if (reloc->sym->type == STT_SECTION) { 268 266 str = offstr(reloc->sym->sec, reloc->sym->offset + offset); 269 - DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, str); 267 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, str); 270 268 free(str); 271 269 } else { 272 270 sprint_name(symstr, reloc->sym->name, offset); 273 - DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, symstr); 271 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, symstr); 274 272 } 275 273 } 276 274 ··· 313 311 */ 314 312 sym = insn_call_dest(insn); 315 313 if (sym && (sym->offset == addr || (sym->offset == 0 && is_reloc))) { 316 - DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, sym->name); 314 + DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, sym->name); 317 315 return; 318 316 } 319 317
+6 -7
tools/objtool/elf.c
··· 18 18 #include <errno.h> 19 19 #include <libgen.h> 20 20 #include <ctype.h> 21 + #include <linux/align.h> 22 + #include <linux/kernel.h> 21 23 #include <linux/interval_tree_generic.h> 24 + #include <linux/log2.h> 22 25 #include <objtool/builtin.h> 23 26 #include <objtool/elf.h> 24 27 #include <objtool/warn.h> 25 - 26 - #define ALIGN_UP(x, align_to) (((x) + ((align_to)-1)) & ~((align_to)-1)) 27 - #define ALIGN_UP_POW2(x) (1U << ((8 * sizeof(x)) - __builtin_clz((x) - 1U))) 28 - #define MAX(a, b) ((a) > (b) ? (a) : (b)) 29 28 30 29 static inline u32 str_hash(const char *str) 31 30 { ··· 1335 1336 return -1; 1336 1337 } 1337 1338 1338 - offset = ALIGN_UP(strtab->sh.sh_size, strtab->sh.sh_addralign); 1339 + offset = ALIGN(strtab->sh.sh_size, strtab->sh.sh_addralign); 1339 1340 1340 1341 if (!elf_add_data(elf, strtab, str, strlen(str) + 1)) 1341 1342 return -1; ··· 1377 1378 sec->data->d_size = size; 1378 1379 sec->data->d_align = 1; 1379 1380 1380 - offset = ALIGN_UP(sec->sh.sh_size, sec->sh.sh_addralign); 1381 + offset = ALIGN(sec->sh.sh_size, sec->sh.sh_addralign); 1381 1382 sec->sh.sh_size = offset + size; 1382 1383 1383 1384 mark_sec_changed(elf, sec, true); ··· 1501 1502 rsec->data->d_size = nr_relocs_new * elf_rela_size(elf); 1502 1503 rsec->sh.sh_size = rsec->data->d_size; 1503 1504 1504 - nr_alloc = MAX(64, ALIGN_UP_POW2(nr_relocs_new)); 1505 + nr_alloc = max(64UL, roundup_pow_of_two(nr_relocs_new)); 1505 1506 if (nr_alloc <= rsec->nr_alloc_relocs) 1506 1507 return 0; 1507 1508
+11 -3
tools/objtool/klp-diff.c
··· 1425 1425 { 1426 1426 struct section *patched_sec; 1427 1427 1428 - if (create_fake_symbols(e->patched)) 1429 - return -1; 1430 - 1431 1428 for_each_sec(e->patched, patched_sec) { 1432 1429 if (is_special_section(patched_sec)) { 1433 1430 if (clone_special_section(e, patched_sec)) ··· 1699 1702 1700 1703 e.out = elf_create_file(&e.orig->ehdr, argv[2]); 1701 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)) 1702 1716 return -1; 1703 1717 1704 1718 if (clone_included_functions(&e))