]> git.ipfire.org Git - thirdparty/linux.git/commit
objtool: Replace custom macros in elf.c with shared ones
authorPetr Pavlu <petr.pavlu@suse.com>
Mon, 26 Jan 2026 15:13:48 +0000 (16:13 +0100)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 27 Jan 2026 16:20:41 +0000 (08:20 -0800)
commitd107b3265aa5e61a1e326b2815a767526ddb12ac
tree7b29ae5426f5106dbf6b8a326b55cc0838f0a2d3
parentfd4eeb30b9e30ca1118a618be0755287bcbb2da9
objtool: Replace custom macros in elf.c with shared ones

The source file tools/objtool/elf.c defines the macros ALIGN_UP(),
ALIGN_UP_POW2() and MAX(). These macros unnecessarily duplicate
functionality already available under tools/include/, specifically ALIGN(),
roundup_pow_of_two() and max().

More importantly, the definition of ALIGN_UP_POW2() is incorrect when the
input is 1, as it results in a call to __builtin_clz(0), which produces an
undefined result. This issue impacts the function elf_alloc_reloc(). When
adding the first relocation to a section, the function allocates an
undefined number of relocations.

Replace the custom macros with the shared functionality to resolve these
issues.

Fixes: 2c05ca026218 ("objtool: Add elf_create_reloc() and elf_init_reloc()")
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Link: https://patch.msgid.link/20260126151356.3924887-1-petr.pavlu@suse.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
tools/objtool/elf.c