Commit 32164845 authored by Masahiro Yamada's avatar Masahiro Yamada

kbuild: use obj-y instead extra-y for objects placed at the head

The objects placed at the head of vmlinux need special treatments:

 - arch/$(SRCARCH)/Makefile adds them to head-y in order to place
   them before other archives in the linker command line.

 - arch/$(SRCARCH)/kernel/Makefile adds them to extra-y instead of
   obj-y to avoid them going into built-in.a.

This commit gets rid of the latter.

Create vmlinux.a to collect all the objects that are unconditionally
linked to vmlinux. The objects listed in head-y are moved to the head
of vmlinux.a by using 'ar m'.

With this, arch/$(SRCARCH)/kernel/Makefile can consistently use obj-y
for builtin objects.

There is no *.o that is directly linked to vmlinux. Drop unneeded code
in scripts/clang-tools/gen_compile_commands.py.

$(AR) mPi needs 'T' to workaround the llvm-ar bug. The fix was suggested
by Nathan Chancellor [1].

[1]: https://lore.kernel.org/llvm/YyjjT5gQ2hGMH0ni@dev-arch.thelio-3990X/Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Reviewed-by: default avatarNicolas Schier <nicolas@fjasle.eu>
parent 4b098659
...@@ -340,19 +340,7 @@ more details, with real examples. ...@@ -340,19 +340,7 @@ more details, with real examples.
Examples are: Examples are:
1) head objects 1) vmlinux linker script
Some objects must be placed at the head of vmlinux. They are
directly linked to vmlinux without going through built-in.a
A typical use-case is an object that contains the entry point.
arch/$(SRCARCH)/Makefile should specify such objects as head-y.
Discussion:
Given that we can control the section order in the linker script,
why do we need head-y?
2) vmlinux linker script
The linker script for vmlinux is located at The linker script for vmlinux is located at
arch/$(SRCARCH)/kernel/vmlinux.lds arch/$(SRCARCH)/kernel/vmlinux.lds
...@@ -360,10 +348,6 @@ more details, with real examples. ...@@ -360,10 +348,6 @@ more details, with real examples.
Example:: Example::
# arch/x86/kernel/Makefile # arch/x86/kernel/Makefile
extra-y := head_$(BITS).o
extra-y += head$(BITS).o
extra-y += ebda.o
extra-y += platform-quirks.o
extra-y += vmlinux.lds extra-y += vmlinux.lds
$(extra-y) should only contain targets needed for vmlinux. $(extra-y) should only contain targets needed for vmlinux.
......
...@@ -645,6 +645,8 @@ else ...@@ -645,6 +645,8 @@ else
__all: modules __all: modules
endif endif
targets :=
# Decide whether to build built-in, modular, or both. # Decide whether to build built-in, modular, or both.
# Normally, just do built-in. # Normally, just do built-in.
...@@ -1107,7 +1109,7 @@ export ARCH_LIB := $(filter %/, $(libs-y)) ...@@ -1107,7 +1109,7 @@ export ARCH_LIB := $(filter %/, $(libs-y))
export ARCH_DRIVERS := $(drivers-y) $(drivers-m) export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
# Externally visible symbols (used by link-vmlinux.sh) # Externally visible symbols (used by link-vmlinux.sh)
KBUILD_VMLINUX_OBJS := $(head-y) ./built-in.a KBUILD_VMLINUX_OBJS := ./built-in.a
ifdef CONFIG_MODULES ifdef CONFIG_MODULES
KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y))) KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y)) KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
...@@ -1115,7 +1117,7 @@ else ...@@ -1115,7 +1117,7 @@ else
KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y)) KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
endif endif
export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS export KBUILD_VMLINUX_LIBS
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
# Recurse until adjust_autoksyms.sh is satisfied # Recurse until adjust_autoksyms.sh is satisfied
...@@ -1140,7 +1142,18 @@ quiet_cmd_autoksyms_h = GEN $@ ...@@ -1140,7 +1142,18 @@ quiet_cmd_autoksyms_h = GEN $@
$(autoksyms_h): $(autoksyms_h):
$(call cmd,autoksyms_h) $(call cmd,autoksyms_h)
vmlinux.o: autoksyms_recursive $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
quiet_cmd_ar_vmlinux.a = AR $@
cmd_ar_vmlinux.a = \
rm -f $@; \
$(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \
$(AR) mPiT $$($(AR) t $@ | head -n1) $@ $(head-y)
targets += vmlinux.a
vmlinux.a: $(KBUILD_VMLINUX_OBJS) autoksyms_recursive FORCE
$(call if_changed,ar_vmlinux.a)
vmlinux.o: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
...@@ -1153,7 +1166,7 @@ cmd_link-vmlinux = \ ...@@ -1153,7 +1166,7 @@ cmd_link-vmlinux = \
vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) modpost FORCE vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) modpost FORCE
+$(call if_changed_dep,link-vmlinux) +$(call if_changed_dep,link-vmlinux)
targets := vmlinux targets += vmlinux
# The actual objects are generated when descending, # The actual objects are generated when descending,
# make sure no implicit rule kicks in # make sure no implicit rule kicks in
...@@ -1878,7 +1891,7 @@ quiet_cmd_gen_compile_commands = GEN $@ ...@@ -1878,7 +1891,7 @@ quiet_cmd_gen_compile_commands = GEN $@
cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs)) cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
$(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \ $(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
$(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \ $(if $(KBUILD_EXTMOD),, vmlinux.a $(KBUILD_VMLINUX_LIBS)) \
$(if $(CONFIG_MODULES), $(MODORDER)) FORCE $(if $(CONFIG_MODULES), $(MODORDER)) FORCE
$(call if_changed,gen_compile_commands) $(call if_changed,gen_compile_commands)
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
# Makefile for the linux kernel. # Makefile for the linux kernel.
# #
extra-y := head.o vmlinux.lds extra-y := vmlinux.lds
asflags-y := $(KBUILD_CFLAGS) asflags-y := $(KBUILD_CFLAGS)
ccflags-y := -Wno-sign-compare ccflags-y := -Wno-sign-compare
obj-y := entry.o traps.o process.o osf_sys.o irq.o \ obj-y := head.o entry.o traps.o process.o osf_sys.o irq.o \
irq_alpha.o signal.o setup.o ptrace.o time.o \ irq_alpha.o signal.o setup.o ptrace.o time.o \
systbls.o err_common.o io.o bugs.o systbls.o err_common.o io.o bugs.o
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) # Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
# #
obj-y := arcksyms.o setup.o irq.o reset.o ptrace.o process.o devtree.o obj-y := head.o arcksyms.o setup.o irq.o reset.o ptrace.o process.o devtree.o
obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o
obj-$(CONFIG_ISA_ARCOMPACT) += entry-compact.o intc-compact.o obj-$(CONFIG_ISA_ARCOMPACT) += entry-compact.o intc-compact.o
obj-$(CONFIG_ISA_ARCV2) += entry-arcv2.o intc-arcv2.o obj-$(CONFIG_ISA_ARCV2) += entry-arcv2.o intc-arcv2.o
...@@ -31,4 +31,4 @@ else ...@@ -31,4 +31,4 @@ else
obj-y += ctx_sw_asm.o obj-y += ctx_sw_asm.o
endif endif
extra-y := vmlinux.lds head.o extra-y := vmlinux.lds
...@@ -89,7 +89,7 @@ obj-$(CONFIG_VDSO) += vdso.o ...@@ -89,7 +89,7 @@ obj-$(CONFIG_VDSO) += vdso.o
obj-$(CONFIG_EFI) += efi.o obj-$(CONFIG_EFI) += efi.o
obj-$(CONFIG_PARAVIRT) += paravirt.o obj-$(CONFIG_PARAVIRT) += paravirt.o
head-y := head$(MMUEXT).o obj-y += head$(MMUEXT).o
obj-$(CONFIG_DEBUG_LL) += debug.o obj-$(CONFIG_DEBUG_LL) += debug.o
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
obj-$(CONFIG_ARM_PATCH_PHYS_VIRT) += phys2virt.o obj-$(CONFIG_ARM_PATCH_PHYS_VIRT) += phys2virt.o
...@@ -109,4 +109,4 @@ obj-$(CONFIG_HAVE_ARM_SMCCC) += smccc-call.o ...@@ -109,4 +109,4 @@ obj-$(CONFIG_HAVE_ARM_SMCCC) += smccc-call.o
obj-$(CONFIG_GENERIC_CPU_VULNERABILITIES) += spectre.o obj-$(CONFIG_GENERIC_CPU_VULNERABILITIES) += spectre.o
extra-y := $(head-y) vmlinux.lds extra-y := vmlinux.lds
...@@ -85,8 +85,8 @@ $(obj)/vdso-wrap.o: $(obj)/vdso/vdso.so ...@@ -85,8 +85,8 @@ $(obj)/vdso-wrap.o: $(obj)/vdso/vdso.so
$(obj)/vdso32-wrap.o: $(obj)/vdso32/vdso.so $(obj)/vdso32-wrap.o: $(obj)/vdso32/vdso.so
obj-y += probes/ obj-y += probes/
head-y := head.o obj-y += head.o
extra-y += $(head-y) vmlinux.lds extra-y += vmlinux.lds
ifeq ($(CONFIG_DEBUG_EFI),y) ifeq ($(CONFIG_DEBUG_EFI),y)
AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\"" AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\""
......
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
extra-y := head.o vmlinux.lds extra-y := vmlinux.lds
obj-y += entry.o atomic.o signal.o traps.o irq.o time.o vdso.o vdso/ obj-y += head.o entry.o atomic.o signal.o traps.o irq.o time.o vdso.o vdso/
obj-y += power.o syscall.o syscall_table.o setup.o io.o obj-y += power.o syscall.o syscall_table.o setup.o io.o
obj-y += process.o cpu-probe.o ptrace.o stacktrace.o obj-y += process.o cpu-probe.o ptrace.o stacktrace.o
obj-y += probes/ obj-y += probes/
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
extra-y := head.o vmlinux.lds extra-y := vmlinux.lds
obj-y += head.o
obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SMP) += smp.o
obj-y += setup.o irq_cpu.o traps.o syscalltab.o signal.o time.o obj-y += setup.o irq_cpu.o traps.o syscalltab.o signal.o time.o
......
...@@ -7,9 +7,9 @@ ifdef CONFIG_DYNAMIC_FTRACE ...@@ -7,9 +7,9 @@ ifdef CONFIG_DYNAMIC_FTRACE
CFLAGS_REMOVE_ftrace.o = -pg CFLAGS_REMOVE_ftrace.o = -pg
endif endif
extra-y := head.o vmlinux.lds extra-y := vmlinux.lds
obj-y := entry.o efi.o efi_stub.o gate-data.o fsys.o irq.o irq_ia64.o \ obj-y := head.o entry.o efi.o efi_stub.o gate-data.o fsys.o irq.o irq_ia64.o \
irq_lsapic.o ivt.o pal.o patch.o process.o ptrace.o sal.o \ irq_lsapic.o ivt.o pal.o patch.o process.o ptrace.o sal.o \
salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \ salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \
unwind.o mca.o mca_asm.o topology.o dma-mapping.o iosapic.o acpi.o \ unwind.o mca.o mca_asm.o topology.o dma-mapping.o iosapic.o acpi.o \
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
# Makefile for the Linux/LoongArch kernel. # Makefile for the Linux/LoongArch kernel.
# #
extra-y := head.o vmlinux.lds extra-y := vmlinux.lds
obj-y += cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \ obj-y += head.o cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \
traps.o irq.o idle.o process.o dma.o mem.o io.o reset.o switch.o \ traps.o irq.o idle.o process.o dma.o mem.o io.o reset.o switch.o \
elf.o syscall.o signal.o time.o topology.o inst.o ptrace.o vdso.o elf.o syscall.o signal.o time.o topology.o inst.o ptrace.o vdso.o
......
...@@ -17,4 +17,4 @@ obj-$(CONFIG_DRAGEN2) += dragen2.o ...@@ -17,4 +17,4 @@ obj-$(CONFIG_DRAGEN2) += dragen2.o
obj-$(CONFIG_UCSIMM) += ucsimm.o obj-$(CONFIG_UCSIMM) += ucsimm.o
obj-$(CONFIG_UCDIMM) += ucsimm.o obj-$(CONFIG_UCDIMM) += ucsimm.o
extra-y := head.o obj-y += head.o
...@@ -45,4 +45,4 @@ obj-$(CONFIG_STMARK2) += stmark2.o ...@@ -45,4 +45,4 @@ obj-$(CONFIG_STMARK2) += stmark2.o
obj-$(CONFIG_PCI) += pci.o obj-$(CONFIG_PCI) += pci.o
obj-y += gpio.o obj-y += gpio.o
extra-y := head.o obj-y += head.o
...@@ -3,19 +3,20 @@ ...@@ -3,19 +3,20 @@
# Makefile for the linux kernel. # Makefile for the linux kernel.
# #
extra-$(CONFIG_AMIGA) := head.o
extra-$(CONFIG_ATARI) := head.o
extra-$(CONFIG_MAC) := head.o
extra-$(CONFIG_APOLLO) := head.o
extra-$(CONFIG_VME) := head.o
extra-$(CONFIG_HP300) := head.o
extra-$(CONFIG_Q40) := head.o
extra-$(CONFIG_SUN3X) := head.o
extra-$(CONFIG_VIRT) := head.o
extra-$(CONFIG_SUN3) := sun3-head.o
extra-y += vmlinux.lds extra-y += vmlinux.lds
obj-y := entry.o irq.o module.o process.o ptrace.o obj-$(CONFIG_AMIGA) := head.o
obj-$(CONFIG_ATARI) := head.o
obj-$(CONFIG_MAC) := head.o
obj-$(CONFIG_APOLLO) := head.o
obj-$(CONFIG_VME) := head.o
obj-$(CONFIG_HP300) := head.o
obj-$(CONFIG_Q40) := head.o
obj-$(CONFIG_SUN3X) := head.o
obj-$(CONFIG_VIRT) := head.o
obj-$(CONFIG_SUN3) := sun3-head.o
obj-y += entry.o irq.o module.o process.o ptrace.o
obj-y += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o obj-y += setup.o signal.o sys_m68k.o syscalltable.o time.o traps.o
obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o obj-$(CONFIG_MMU_MOTOROLA) += ints.o vectors.o
......
...@@ -12,9 +12,9 @@ CFLAGS_REMOVE_ftrace.o = -pg ...@@ -12,9 +12,9 @@ CFLAGS_REMOVE_ftrace.o = -pg
CFLAGS_REMOVE_process.o = -pg CFLAGS_REMOVE_process.o = -pg
endif endif
extra-y := head.o vmlinux.lds extra-y := vmlinux.lds
obj-y += dma.o exceptions.o \ obj-y += head.o dma.o exceptions.o \
hw_exception_handler.o irq.o \ hw_exception_handler.o irq.o \
process.o prom.o ptrace.o \ process.o prom.o ptrace.o \
reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o reset.o setup.o signal.o sys_microblaze.o timer.o traps.o unwind.o
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
# Makefile for the Linux/MIPS kernel. # Makefile for the Linux/MIPS kernel.
# #
extra-y := head.o vmlinux.lds extra-y := vmlinux.lds
obj-y += branch.o cmpxchg.o elf.o entry.o genex.o idle.o irq.o \ obj-y += head.o branch.o cmpxchg.o elf.o entry.o genex.o idle.o irq.o \
process.o prom.o ptrace.o reset.o setup.o signal.o \ process.o prom.o ptrace.o reset.o setup.o signal.o \
syscall.o time.o topology.o traps.o unaligned.o watch.o \ syscall.o time.o topology.o traps.o unaligned.o watch.o \
vdso.o cacheinfo.o vdso.o cacheinfo.o
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
# Makefile for the nios2 linux kernel. # Makefile for the nios2 linux kernel.
# #
extra-y += head.o
extra-y += vmlinux.lds extra-y += vmlinux.lds
obj-y += head.o
obj-y += cpuinfo.o obj-y += cpuinfo.o
obj-y += entry.o obj-y += entry.o
obj-y += insnemu.o obj-y += insnemu.o
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
# Makefile for the linux kernel. # Makefile for the linux kernel.
# #
extra-y := head.o vmlinux.lds extra-y := vmlinux.lds
obj-y := setup.o or32_ksyms.o process.o dma.o \ obj-y := head.o setup.o or32_ksyms.o process.o dma.o \
traps.o time.o irq.o entry.o ptrace.o signal.o \ traps.o time.o irq.o entry.o ptrace.o signal.o \
sys_call_table.o unwinder.o sys_call_table.o unwinder.o
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
# Makefile for arch/parisc/kernel # Makefile for arch/parisc/kernel
# #
extra-y := head.o vmlinux.lds extra-y := vmlinux.lds
obj-y := cache.o pacache.o setup.o pdt.o traps.o time.o irq.o \ obj-y := head.o cache.o pacache.o setup.o pdt.o traps.o time.o irq.o \
pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \ pa7300lc.o syscall.o entry.o sys_parisc.o firmware.o \
ptrace.o hardware.o inventory.o drivers.o alternative.o \ ptrace.o hardware.o inventory.o drivers.o alternative.o \
signal.o hpmc.o real2.o parisc_ksyms.o unaligned.o \ signal.o hpmc.o real2.o parisc_ksyms.o unaligned.o \
......
...@@ -118,12 +118,12 @@ obj-$(CONFIG_PPC_FSL_BOOK3E) += cpu_setup_fsl_booke.o ...@@ -118,12 +118,12 @@ obj-$(CONFIG_PPC_FSL_BOOK3E) += cpu_setup_fsl_booke.o
obj-$(CONFIG_PPC_DOORBELL) += dbell.o obj-$(CONFIG_PPC_DOORBELL) += dbell.o
obj-$(CONFIG_JUMP_LABEL) += jump_label.o obj-$(CONFIG_JUMP_LABEL) += jump_label.o
extra-$(CONFIG_PPC64) := head_64.o obj-$(CONFIG_PPC64) += head_64.o
extra-$(CONFIG_PPC_BOOK3S_32) := head_book3s_32.o obj-$(CONFIG_PPC_BOOK3S_32) += head_book3s_32.o
extra-$(CONFIG_40x) := head_40x.o obj-$(CONFIG_40x) += head_40x.o
extra-$(CONFIG_44x) := head_44x.o obj-$(CONFIG_44x) += head_44x.o
extra-$(CONFIG_FSL_BOOKE) := head_fsl_booke.o obj-$(CONFIG_FSL_BOOKE) += head_fsl_booke.o
extra-$(CONFIG_PPC_8xx) := head_8xx.o obj-$(CONFIG_PPC_8xx) += head_8xx.o
extra-y += vmlinux.lds extra-y += vmlinux.lds
obj-$(CONFIG_RELOCATABLE) += reloc_$(BITS).o obj-$(CONFIG_RELOCATABLE) += reloc_$(BITS).o
...@@ -198,10 +198,10 @@ KCOV_INSTRUMENT_paca.o := n ...@@ -198,10 +198,10 @@ KCOV_INSTRUMENT_paca.o := n
CFLAGS_setup_64.o += -fno-stack-protector CFLAGS_setup_64.o += -fno-stack-protector
CFLAGS_paca.o += -fno-stack-protector CFLAGS_paca.o += -fno-stack-protector
extra-$(CONFIG_PPC_FPU) += fpu.o obj-$(CONFIG_PPC_FPU) += fpu.o
extra-$(CONFIG_ALTIVEC) += vector.o obj-$(CONFIG_ALTIVEC) += vector.o
extra-$(CONFIG_PPC64) += entry_64.o obj-$(CONFIG_PPC64) += entry_64.o
extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init.o obj-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init.o
extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init_check extra-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += prom_init_check
......
...@@ -28,9 +28,9 @@ KASAN_SANITIZE_cpufeature.o := n ...@@ -28,9 +28,9 @@ KASAN_SANITIZE_cpufeature.o := n
endif endif
endif endif
extra-y += head.o
extra-y += vmlinux.lds extra-y += vmlinux.lds
obj-y += head.o
obj-y += soc.o obj-y += soc.o
obj-$(CONFIG_RISCV_ALTERNATIVE) += alternative.o obj-$(CONFIG_RISCV_ALTERNATIVE) += alternative.o
obj-y += cpu.o obj-y += cpu.o
......
...@@ -33,7 +33,7 @@ CFLAGS_stacktrace.o += -fno-optimize-sibling-calls ...@@ -33,7 +33,7 @@ CFLAGS_stacktrace.o += -fno-optimize-sibling-calls
CFLAGS_dumpstack.o += -fno-optimize-sibling-calls CFLAGS_dumpstack.o += -fno-optimize-sibling-calls
CFLAGS_unwind_bc.o += -fno-optimize-sibling-calls CFLAGS_unwind_bc.o += -fno-optimize-sibling-calls
obj-y := traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o obj-y := head64.o traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
obj-y += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o obj-y += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o cpufeature.o
obj-y += sysinfo.o lgr.o os_info.o machine_kexec.o obj-y += sysinfo.o lgr.o os_info.o machine_kexec.o
...@@ -42,7 +42,7 @@ obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o ...@@ -42,7 +42,7 @@ obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o
obj-y += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o obj-y += nospec-branch.o ipl_vmparm.o machine_kexec_reloc.o unwind_bc.o
obj-y += smp.o text_amode31.o stacktrace.o obj-y += smp.o text_amode31.o stacktrace.o
extra-y += head64.o vmlinux.lds extra-y += vmlinux.lds
obj-$(CONFIG_SYSFS) += nospec-sysfs.o obj-$(CONFIG_SYSFS) += nospec-sysfs.o
CFLAGS_REMOVE_nospec-branch.o += $(CC_FLAGS_EXPOLINE) CFLAGS_REMOVE_nospec-branch.o += $(CC_FLAGS_EXPOLINE)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Makefile for the Linux/SuperH kernel. # Makefile for the Linux/SuperH kernel.
# #
extra-y := head_32.o vmlinux.lds extra-y := vmlinux.lds
ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_FUNCTION_TRACER
# Do not profile debug and lowlevel utilities # Do not profile debug and lowlevel utilities
...@@ -12,7 +12,7 @@ endif ...@@ -12,7 +12,7 @@ endif
CFLAGS_REMOVE_return_address.o = -pg CFLAGS_REMOVE_return_address.o = -pg
obj-y := debugtraps.o dumpstack.o \ obj-y := head_32.o debugtraps.o dumpstack.o \
idle.o io.o irq.o irq_32.o kdebugfs.o \ idle.o io.o irq.o irq_32.o kdebugfs.o \
machvec.o nmi_debug.o process.o \ machvec.o nmi_debug.o process.o \
process_32.o ptrace.o ptrace_32.o \ process_32.o ptrace.o ptrace_32.o \
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
asflags-y := -ansi asflags-y := -ansi
ccflags-y := -Werror ccflags-y := -Werror
extra-y := head_$(BITS).o
# Undefine sparc when processing vmlinux.lds - it is used # Undefine sparc when processing vmlinux.lds - it is used
# And teach CPP we are doing $(BITS) builds (for this case) # And teach CPP we are doing $(BITS) builds (for this case)
CPPFLAGS_vmlinux.lds := -Usparc -m$(BITS) CPPFLAGS_vmlinux.lds := -Usparc -m$(BITS)
...@@ -22,6 +20,7 @@ CFLAGS_REMOVE_perf_event.o := -pg ...@@ -22,6 +20,7 @@ CFLAGS_REMOVE_perf_event.o := -pg
CFLAGS_REMOVE_pcr.o := -pg CFLAGS_REMOVE_pcr.o := -pg
endif endif
obj-y := head_$(BITS).o
obj-$(CONFIG_SPARC64) += urtt_fill.o obj-$(CONFIG_SPARC64) += urtt_fill.o
obj-$(CONFIG_SPARC32) += entry.o wof.o wuf.o obj-$(CONFIG_SPARC32) += entry.o wof.o wuf.o
obj-$(CONFIG_SPARC32) += etrap_32.o obj-$(CONFIG_SPARC32) += etrap_32.o
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
# Makefile for the linux kernel. # Makefile for the linux kernel.
# #
extra-y := head_$(BITS).o
extra-y += head$(BITS).o
extra-y += ebda.o
extra-y += platform-quirks.o
extra-y += vmlinux.lds extra-y += vmlinux.lds
CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE) CPPFLAGS_vmlinux.lds += -U$(UTS_MACHINE)
...@@ -42,7 +38,11 @@ KCOV_INSTRUMENT := n ...@@ -42,7 +38,11 @@ KCOV_INSTRUMENT := n
CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace
obj-y := process_$(BITS).o signal.o obj-y += head_$(BITS).o
obj-y += head$(BITS).o
obj-y += ebda.o
obj-y += platform-quirks.o
obj-y += process_$(BITS).o signal.o
obj-$(CONFIG_COMPAT) += signal_compat.o obj-$(CONFIG_COMPAT) += signal_compat.o
obj-y += traps.o idt.o irq.o irq_$(BITS).o dumpstack_$(BITS).o obj-y += traps.o idt.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
obj-y += time.o ioport.o dumpstack.o nmi.o obj-y += time.o ioport.o dumpstack.o nmi.o
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
# Makefile for the Linux/Xtensa kernel. # Makefile for the Linux/Xtensa kernel.
# #
extra-y := head.o vmlinux.lds extra-y := vmlinux.lds
obj-y := align.o coprocessor.o entry.o irq.o platform.o process.o \ obj-y := head.o align.o coprocessor.o entry.o irq.o platform.o process.o \
ptrace.o setup.o signal.o stacktrace.o syscall.o time.o traps.o \ ptrace.o setup.o signal.o stacktrace.o syscall.o time.o traps.o \
vectors.o vectors.o
......
...@@ -70,13 +70,12 @@ quiet_cmd_vmlinux_objs = GEN $@ ...@@ -70,13 +70,12 @@ quiet_cmd_vmlinux_objs = GEN $@
for f in $(real-prereqs); do \ for f in $(real-prereqs); do \
case $${f} in \ case $${f} in \
*libgcc.a) ;; \ *libgcc.a) ;; \
*.a) $(AR) t $${f} ;; \ *) $(AR) t $${f} ;; \
*) echo $${f} ;; \
esac \ esac \
done > $@ done > $@
targets += .vmlinux.objs targets += .vmlinux.objs
.vmlinux.objs: $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE .vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
$(call if_changed,vmlinux_objs) $(call if_changed,vmlinux_objs)
vmlinux.o-if-present := $(wildcard vmlinux.o) vmlinux.o-if-present := $(wildcard vmlinux.o)
......
...@@ -18,7 +18,7 @@ quiet_cmd_gen_initcalls_lds = GEN $@ ...@@ -18,7 +18,7 @@ quiet_cmd_gen_initcalls_lds = GEN $@
$(PERL) $(real-prereqs) > $@ $(PERL) $(real-prereqs) > $@
.tmp_initcalls.lds: $(srctree)/scripts/generate_initcall_order.pl \ .tmp_initcalls.lds: $(srctree)/scripts/generate_initcall_order.pl \
$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
$(call if_changed,gen_initcalls_lds) $(call if_changed,gen_initcalls_lds)
targets := .tmp_initcalls.lds targets := .tmp_initcalls.lds
...@@ -48,7 +48,7 @@ quiet_cmd_ld_vmlinux.o = LD $@ ...@@ -48,7 +48,7 @@ quiet_cmd_ld_vmlinux.o = LD $@
cmd_ld_vmlinux.o = \ cmd_ld_vmlinux.o = \
$(LD) ${KBUILD_LDFLAGS} -r -o $@ \ $(LD) ${KBUILD_LDFLAGS} -r -o $@ \
$(addprefix -T , $(initcalls-lds)) \ $(addprefix -T , $(initcalls-lds)) \
--whole-archive $(KBUILD_VMLINUX_OBJS) --no-whole-archive \ --whole-archive vmlinux.a --no-whole-archive \
--start-group $(KBUILD_VMLINUX_LIBS) --end-group \ --start-group $(KBUILD_VMLINUX_LIBS) --end-group \
$(cmd_objtool) $(cmd_objtool)
...@@ -57,7 +57,7 @@ define rule_ld_vmlinux.o ...@@ -57,7 +57,7 @@ define rule_ld_vmlinux.o
$(call cmd,gen_objtooldep) $(call cmd,gen_objtooldep)
endef endef
vmlinux.o: $(initcalls-lds) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
$(call if_changed_rule,ld_vmlinux.o) $(call if_changed_rule,ld_vmlinux.o)
targets += vmlinux.o targets += vmlinux.o
......
...@@ -109,20 +109,6 @@ def to_cmdfile(path): ...@@ -109,20 +109,6 @@ def to_cmdfile(path):
return os.path.join(dir, '.' + base + '.cmd') return os.path.join(dir, '.' + base + '.cmd')
def cmdfiles_for_o(obj):
"""Generate the iterator of .cmd files associated with the object
Yield the .cmd file used to build the given object
Args:
obj: The object path
Yields:
The path to .cmd file
"""
yield to_cmdfile(obj)
def cmdfiles_for_a(archive, ar): def cmdfiles_for_a(archive, ar):
"""Generate the iterator of .cmd files associated with the archive. """Generate the iterator of .cmd files associated with the archive.
...@@ -211,13 +197,10 @@ def main(): ...@@ -211,13 +197,10 @@ def main():
for path in paths: for path in paths:
# If 'path' is a directory, handle all .cmd files under it. # If 'path' is a directory, handle all .cmd files under it.
# Otherwise, handle .cmd files associated with the file. # Otherwise, handle .cmd files associated with the file.
# Most of built-in objects are linked via archives (built-in.a or lib.a) # built-in objects are linked via vmlinux.a
# but some objects are linked to vmlinux directly.
# Modules are listed in modules.order. # Modules are listed in modules.order.
if os.path.isdir(path): if os.path.isdir(path):
cmdfiles = cmdfiles_in_dir(path) cmdfiles = cmdfiles_in_dir(path)
elif path.endswith('.o'):
cmdfiles = cmdfiles_for_o(path)
elif path.endswith('.a'): elif path.endswith('.a'):
cmdfiles = cmdfiles_for_a(path, ar) cmdfiles = cmdfiles_for_a(path, ar)
elif path.endswith('modules.order'): elif path.endswith('modules.order'):
......
...@@ -3,17 +3,15 @@ ...@@ -3,17 +3,15 @@
# #
# link vmlinux # link vmlinux
# #
# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and # vmlinux is linked from the objects in vmlinux.a and $(KBUILD_VMLINUX_LIBS).
# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories # vmlinux.a contains objects that are linked unconditionally.
# in the kernel tree, others are specified in arch/$(ARCH)/Makefile.
# $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally # $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally
# (not within --whole-archive), and do not require symbol indexes added. # (not within --whole-archive), and do not require symbol indexes added.
# #
# vmlinux # vmlinux
# ^ # ^
# | # |
# +--< $(KBUILD_VMLINUX_OBJS) # +--< vmlinux.a
# | +--< init/built-in.a drivers/built-in.a mm/built-in.a + more
# | # |
# +--< $(KBUILD_VMLINUX_LIBS) # +--< $(KBUILD_VMLINUX_LIBS)
# | +--< lib/lib.a + more # | +--< lib/lib.a + more
...@@ -67,7 +65,7 @@ vmlinux_link() ...@@ -67,7 +65,7 @@ vmlinux_link()
objs=vmlinux.o objs=vmlinux.o
libs= libs=
else else
objs="${KBUILD_VMLINUX_OBJS}" objs=vmlinux.a
libs="${KBUILD_VMLINUX_LIBS}" libs="${KBUILD_VMLINUX_LIBS}"
fi fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment