Commit 969b5726 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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
parents 5db2a252 78c268f3
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -555,13 +555,11 @@ copy_orig_objects() {
		local file_dir="$(dirname "$file")"
		local orig_file="$ORIG_DIR/$rel_file"
		local orig_dir="$(dirname "$orig_file")"
		local cmd_file="$file_dir/.$(basename "$file").cmd"

		[[ ! -f "$file" ]] && die "missing $(basename "$file") for $_file"

		mkdir -p "$orig_dir"
		cp -f "$file" "$orig_dir"
		[[ -e "$cmd_file" ]] && cp -f "$cmd_file" "$orig_dir"
	done
	xtrace_restore

@@ -740,15 +738,17 @@ build_patch_module() {
		local orig_dir="$(dirname "$orig_file")"
		local kmod_file="$KMOD_DIR/$rel_file"
		local kmod_dir="$(dirname "$kmod_file")"
		local cmd_file="$orig_dir/.$(basename "$file").cmd"
		local cmd_file="$kmod_dir/.$(basename "$file").cmd"

		mkdir -p "$kmod_dir"
		cp -f "$file" "$kmod_dir"
		[[ -e "$cmd_file" ]] && cp -f "$cmd_file" "$kmod_dir"

		# Tell kbuild this is a prebuilt object
		cp -f "$file" "${kmod_file}_shipped"

		# Make modpost happy
		touch "$cmd_file"

		echo -n " $rel_file" >> "$makefile"
	done

+8 −6
Original line number Diff line number Diff line
@@ -108,6 +108,8 @@ static int sprint_name(char *str, const char *name, unsigned long offset)

#define DINFO_FPRINTF(dinfo, ...)	\
	((*(dinfo)->fprintf_func)((dinfo)->stream, __VA_ARGS__))
#define bfd_vma_fmt			\
	__builtin_choose_expr(sizeof(bfd_vma) == sizeof(unsigned long), "%#lx <%s>", "%#llx <%s>")

static int disas_result_fprintf(struct disas_context *dctx,
				const char *fmt, va_list ap)
@@ -170,10 +172,10 @@ static void disas_print_addr_sym(struct section *sec, struct symbol *sym,

	if (sym) {
		sprint_name(symstr, sym->name, addr - sym->offset);
		DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, symstr);
		DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, symstr);
	} else {
		str = offstr(sec, addr);
		DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, str);
		DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, str);
		free(str);
	}
}
@@ -252,7 +254,7 @@ static void disas_print_addr_reloc(bfd_vma addr, struct disassemble_info *dinfo)
		 * example: "lea 0x0(%rip),%rdi". The kernel can reference
		 * the next IP with _THIS_IP_ macro.
		 */
		DINFO_FPRINTF(dinfo, "0x%lx <_THIS_IP_>", addr);
		DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, "_THIS_IP_");
		return;
	}

@@ -264,11 +266,11 @@ static void disas_print_addr_reloc(bfd_vma addr, struct disassemble_info *dinfo)
	 */
	if (reloc->sym->type == STT_SECTION) {
		str = offstr(reloc->sym->sec, reloc->sym->offset + offset);
		DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, str);
		DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, str);
		free(str);
	} else {
		sprint_name(symstr, reloc->sym->name, offset);
		DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, symstr);
		DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, symstr);
	}
}

@@ -311,7 +313,7 @@ static void disas_print_address(bfd_vma addr, struct disassemble_info *dinfo)
	 */
	sym = insn_call_dest(insn);
	if (sym && (sym->offset == addr || (sym->offset == 0 && is_reloc))) {
		DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, sym->name);
		DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, sym->name);
		return;
	}

+6 −7
Original line number Diff line number Diff line
@@ -18,15 +18,14 @@
#include <errno.h>
#include <libgen.h>
#include <ctype.h>
#include <linux/align.h>
#include <linux/kernel.h>
#include <linux/interval_tree_generic.h>
#include <linux/log2.h>
#include <objtool/builtin.h>
#include <objtool/elf.h>
#include <objtool/warn.h>

#define ALIGN_UP(x, align_to) (((x) + ((align_to)-1)) & ~((align_to)-1))
#define ALIGN_UP_POW2(x) (1U << ((8 * sizeof(x)) - __builtin_clz((x) - 1U)))
#define MAX(a, b) ((a) > (b) ? (a) : (b))

static inline u32 str_hash(const char *str)
{
	return jhash(str, strlen(str), 0);
@@ -1336,7 +1335,7 @@ unsigned int elf_add_string(struct elf *elf, struct section *strtab, const char
		return -1;
	}

	offset = ALIGN_UP(strtab->sh.sh_size, strtab->sh.sh_addralign);
	offset = ALIGN(strtab->sh.sh_size, strtab->sh.sh_addralign);

	if (!elf_add_data(elf, strtab, str, strlen(str) + 1))
		return -1;
@@ -1378,7 +1377,7 @@ void *elf_add_data(struct elf *elf, struct section *sec, const void *data, size_
	sec->data->d_size = size;
	sec->data->d_align = 1;

	offset = ALIGN_UP(sec->sh.sh_size, sec->sh.sh_addralign);
	offset = ALIGN(sec->sh.sh_size, sec->sh.sh_addralign);
	sec->sh.sh_size = offset + size;

	mark_sec_changed(elf, sec, true);
@@ -1502,7 +1501,7 @@ static int elf_alloc_reloc(struct elf *elf, struct section *rsec)
	rsec->data->d_size = nr_relocs_new * elf_rela_size(elf);
	rsec->sh.sh_size   = rsec->data->d_size;

	nr_alloc = MAX(64, ALIGN_UP_POW2(nr_relocs_new));
	nr_alloc = max(64UL, roundup_pow_of_two(nr_relocs_new));
	if (nr_alloc <= rsec->nr_alloc_relocs)
		return 0;

+11 −3
Original line number Diff line number Diff line
@@ -1425,9 +1425,6 @@ static int clone_special_sections(struct elfs *e)
{
	struct section *patched_sec;

	if (create_fake_symbols(e->patched))
		return -1;

	for_each_sec(e->patched, patched_sec) {
		if (is_special_section(patched_sec)) {
			if (clone_special_section(e, patched_sec))
@@ -1704,6 +1701,17 @@ int cmd_klp_diff(int argc, const char **argv)
	if (!e.out)
		return -1;

	/*
	 * Special section fake symbols are needed so that individual special
	 * section entries can be extracted by clone_special_sections().
	 *
	 * Note the fake symbols are also needed by clone_included_functions()
	 * because __WARN_printf() call sites add references to bug table
	 * entries in the calling functions.
	 */
	if (create_fake_symbols(e.patched))
		return -1;

	if (clone_included_functions(&e))
		return -1;