Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kbuild: Add generic hook for architectures to use before the final vmlinux link

On powerpc, we would like to be able to make a pass on vmlinux.o and
generate a new object file to be linked into vmlinux. Add a generic pass
in Makefile.vmlinux that architectures can use for this purpose.

Architectures need to select CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX and must
provide arch/<arch>/tools/Makefile with .arch.vmlinux.o target, which
will be invoked prior to the final vmlinux link step.

Acked-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Naveen N Rao <naveen@kernel.org>
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/20241030070850.1361304-12-hbathini@linux.ibm.com

authored by

Naveen N Rao and committed by
Michael Ellerman
1198c9c6 782f46cb

+19 -1
+6
arch/Kconfig
··· 1684 1684 config ARCH_NEED_CMPXCHG_1_EMU 1685 1685 bool 1686 1686 1687 + config ARCH_WANTS_PRE_LINK_VMLINUX 1688 + bool 1689 + help 1690 + An architecture can select this if it provides arch/<arch>/tools/Makefile 1691 + with .arch.vmlinux.o target to be linked into vmlinux. 1692 + 1687 1693 endmenu
+7
scripts/Makefile.vmlinux
··· 22 22 vmlinux: .vmlinux.export.o 23 23 endif 24 24 25 + ifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX 26 + vmlinux: arch/$(SRCARCH)/tools/vmlinux.arch.o 27 + 28 + arch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE 29 + $(Q)$(MAKE) $(build)=arch/$(SRCARCH)/tools $@ 30 + endif 31 + 25 32 ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) 26 33 27 34 # Final link of vmlinux with optional arch pass after final link