Commit d107b32
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: 2c05ca0 ("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>1 parent fd4eeb3 commit d107b32
1 file changed
Lines changed: 6 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
1336 | 1335 | | |
1337 | 1336 | | |
1338 | 1337 | | |
1339 | | - | |
| 1338 | + | |
1340 | 1339 | | |
1341 | 1340 | | |
1342 | 1341 | | |
| |||
1378 | 1377 | | |
1379 | 1378 | | |
1380 | 1379 | | |
1381 | | - | |
| 1380 | + | |
1382 | 1381 | | |
1383 | 1382 | | |
1384 | 1383 | | |
| |||
1502 | 1501 | | |
1503 | 1502 | | |
1504 | 1503 | | |
1505 | | - | |
| 1504 | + | |
1506 | 1505 | | |
1507 | 1506 | | |
1508 | 1507 | | |
| |||
0 commit comments