Re: [PATCH] objtool: Replace custom macros in elf.c with shared ones
From: Josh Poimboeuf
Date: Mon Jan 26 2026 - 19:15:12 EST
On Mon, Jan 26, 2026 at 04:13:48PM +0100, Petr Pavlu wrote:
> 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@xxxxxxxx>
Thanks!
Acked-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
--
Josh