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