Skip to content

Commit 969b572

Browse files
committed
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
2 parents 5db2a25 + 78c268f commit 969b572

4 files changed

Lines changed: 29 additions & 20 deletions

File tree

scripts/livepatch/klp-build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,11 @@ copy_orig_objects() {
555555
local file_dir="$(dirname "$file")"
556556
local orig_file="$ORIG_DIR/$rel_file"
557557
local orig_dir="$(dirname "$orig_file")"
558-
local cmd_file="$file_dir/.$(basename "$file").cmd"
559558

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

562561
mkdir -p "$orig_dir"
563562
cp -f "$file" "$orig_dir"
564-
[[ -e "$cmd_file" ]] && cp -f "$cmd_file" "$orig_dir"
565563
done
566564
xtrace_restore
567565

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

745743
mkdir -p "$kmod_dir"
746744
cp -f "$file" "$kmod_dir"
747-
[[ -e "$cmd_file" ]] && cp -f "$cmd_file" "$kmod_dir"
748745

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

749+
# Make modpost happy
750+
touch "$cmd_file"
751+
752752
echo -n " $rel_file" >> "$makefile"
753753
done
754754

tools/objtool/disas.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ static int sprint_name(char *str, const char *name, unsigned long offset)
108108

109109
#define DINFO_FPRINTF(dinfo, ...) \
110110
((*(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>")
111113

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

171173
if (sym) {
172174
sprint_name(symstr, sym->name, addr - sym->offset);
173-
DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, symstr);
175+
DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, symstr);
174176
} else {
175177
str = offstr(sec, addr);
176-
DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, str);
178+
DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, str);
177179
free(str);
178180
}
179181
}
@@ -252,7 +254,7 @@ static void disas_print_addr_reloc(bfd_vma addr, struct disassemble_info *dinfo)
252254
* example: "lea 0x0(%rip),%rdi". The kernel can reference
253255
* the next IP with _THIS_IP_ macro.
254256
*/
255-
DINFO_FPRINTF(dinfo, "0x%lx <_THIS_IP_>", addr);
257+
DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, "_THIS_IP_");
256258
return;
257259
}
258260

@@ -264,11 +266,11 @@ static void disas_print_addr_reloc(bfd_vma addr, struct disassemble_info *dinfo)
264266
*/
265267
if (reloc->sym->type == STT_SECTION) {
266268
str = offstr(reloc->sym->sec, reloc->sym->offset + offset);
267-
DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, str);
269+
DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, str);
268270
free(str);
269271
} else {
270272
sprint_name(symstr, reloc->sym->name, offset);
271-
DINFO_FPRINTF(dinfo, "0x%lx <%s>", addr, symstr);
273+
DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, symstr);
272274
}
273275
}
274276

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

tools/objtool/elf.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@
1818
#include <errno.h>
1919
#include <libgen.h>
2020
#include <ctype.h>
21+
#include <linux/align.h>
22+
#include <linux/kernel.h>
2123
#include <linux/interval_tree_generic.h>
24+
#include <linux/log2.h>
2225
#include <objtool/builtin.h>
2326
#include <objtool/elf.h>
2427
#include <objtool/warn.h>
2528

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-
3029
static inline u32 str_hash(const char *str)
3130
{
3231
return jhash(str, strlen(str), 0);
@@ -1336,7 +1335,7 @@ unsigned int elf_add_string(struct elf *elf, struct section *strtab, const char
13361335
return -1;
13371336
}
13381337

1339-
offset = ALIGN_UP(strtab->sh.sh_size, strtab->sh.sh_addralign);
1338+
offset = ALIGN(strtab->sh.sh_size, strtab->sh.sh_addralign);
13401339

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

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

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

1505-
nr_alloc = MAX(64, ALIGN_UP_POW2(nr_relocs_new));
1504+
nr_alloc = max(64UL, roundup_pow_of_two(nr_relocs_new));
15061505
if (nr_alloc <= rsec->nr_alloc_relocs)
15071506
return 0;
15081507

tools/objtool/klp-diff.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,9 +1425,6 @@ static int clone_special_sections(struct elfs *e)
14251425
{
14261426
struct section *patched_sec;
14271427

1428-
if (create_fake_symbols(e->patched))
1429-
return -1;
1430-
14311428
for_each_sec(e->patched, patched_sec) {
14321429
if (is_special_section(patched_sec)) {
14331430
if (clone_special_section(e, patched_sec))
@@ -1704,6 +1701,17 @@ int cmd_klp_diff(int argc, const char **argv)
17041701
if (!e.out)
17051702
return -1;
17061703

1704+
/*
1705+
* Special section fake symbols are needed so that individual special
1706+
* section entries can be extracted by clone_special_sections().
1707+
*
1708+
* Note the fake symbols are also needed by clone_included_functions()
1709+
* because __WARN_printf() call sites add references to bug table
1710+
* entries in the calling functions.
1711+
*/
1712+
if (create_fake_symbols(e.patched))
1713+
return -1;
1714+
17071715
if (clone_included_functions(&e))
17081716
return -1;
17091717

0 commit comments

Comments
 (0)