[PATCH 0/2] kbuild: link-vmlinux.sh: more reliable 3rd pass linking

André Draszik <[email protected]> Tue, 28 Jul 2026 13:42:38 +0100
Newsgroups org.kernel.vger.linux-kbuild,dev.linux.lists.llvm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
link-vmlinux.sh currently only uses the file size of
.tmp_vmlinux?.kallsyms.o to determine if it needs to do a third pass. I
was hitting a case where file size didn't change, but symbols changed
sufficiently to still move subsequent symbols in vmlinux to invalidate
kallsyms.

In particular kallsyms_names grew by one byte between
.tmp_vmlinux1.kallsyms.o and .tmp_vmlinux2.kallsyms.o, moving the next
symbol to the next alignment offset (4 bytes), moving many subsequent
symbols in the final vmlinux image in turn (until abosrbed by further
alignment instructions). This failed the final link with:

    Inconsistent kallsyms data
    Try "make KALLSYMS_EXTRA_PASS=1" as a workaround

The two patches here are independent of each other:
* Patch 2 in this series addresses the actual issue and also has a more
  detailed explanation with exact failure case
* Patch 1 could be omitted if deemed useless, but I found it useful
  while debugging the issue. It just updates the kallsyms.c to instruct
  the assembler to also emit symbol sizes.

Cheers,
Andre'

Signed-off-by: André Draszik <[email protected]>
---
André Draszik (2):
      kallsyms: add symbol size for kallsyms symbols that can change size
      kbuild: link-vmlinux.sh: improve detection of third pass requirement

 scripts/kallsyms.c      |  4 ++++
 scripts/link-vmlinux.sh | 20 +++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
---
base-commit: 0d33d21e47d9dc66f91e44da3fc9220c74d93df7
change-id: 20260728-linux-kallsyms-fix-95eff49b75b3

Best regards,
-- 
André Draszik <[email protected]>