History

kbuild: remove head-y syntax

Kbuild puts the objects listed in head-y at the head of vmlinux. Conventionally, we do this for head*.S, which contains the kernel entry point. A counter approach is to control the section order by the linker script. Actually, the code marked as __HEAD goes into the ".head.text" section, which is placed before the normal ".text" section. I do not know if both of them are needed. From the build system perspective, head-y is not mandatory. If you can achieve the proper code placement by the linker script only, it would be cleaner. I collected the current head-y objects into head-object-list.txt. It is a whitelist. My hope is it will be reduced in the long run.

Masahiro Yamada committed 4 years ago

Commit ce697cc1 parent 321648424 files · +60 −67Browse files

Unified · Split

24 files
  1. Documentation/kbuild/makefiles.rst +5 −4
  2. Makefile +2 −2
  3. arch/alpha/Makefile +0 −2
  4. arch/arc/Makefile +0 −2
  5. arch/arm/Makefile +0 −3
  6. arch/arm64/Makefile +0 −3
  7. arch/csky/Makefile +0 −2
  8. arch/hexagon/Makefile +0 −2
  9. arch/ia64/Makefile +0 −1
  10. arch/loongarch/Makefile +0 −2
  11. arch/m68k/Makefile +0 −9
  12. arch/microblaze/Makefile +0 −1
  13. arch/mips/Makefile +0 −2
  14. arch/nios2/Makefile +0 −1
  15. arch/openrisc/Makefile +0 −2
  16. arch/parisc/Makefile +0 −2
  17. arch/powerpc/Makefile +0 −12
  18. arch/riscv/Makefile +0 −2
  19. arch/s390/Makefile +0 −2
  20. arch/sh/Makefile +0 −2
  21. arch/sparc/Makefile +0 −2
  22. arch/x86/Makefile +0 −5
  23. arch/xtensa/Makefile +0 −2
  24. scripts/head-object-list.txt +53 −0
Documentation/kbuild/makefiles.rst+5−4
@@ -1070,8 +1070,7 @@ When kbuild executes, the following steps are followed (roughly): · 1069 unmodified lines
1070 - The values of the above variables are expanded in arch/$(SRCARCH)/Makefile.1070 - The values of the above variables are expanded in arch/$(SRCARCH)/Makefile.
10715) All object files are then linked and the resulting file vmlinux is10715) All object files are then linked and the resulting file vmlinux is
1072 located at the root of the obj tree.1072 located at the root of the obj tree.
1073 The very first objects linked are listed in head-y, assigned by1073 The very first objects linked are listed in scripts/head-object-list.txt.
1074 arch/$(SRCARCH)/Makefile.
10756) Finally, the architecture-specific part does any required post processing10746) Finally, the architecture-specific part does any required post processing
1076 and builds the final bootimage.1075 and builds the final bootimage.
1077 - This includes building boot records1076 - This includes building boot records
@@ -1219,6 +1218,9 @@ When kbuild executes, the following steps are followed (roughly): · 141 unmodified lines
1219 All object files for vmlinux. They are linked to vmlinux in the same1218 All object files for vmlinux. They are linked to vmlinux in the same
1220 order as listed in KBUILD_VMLINUX_OBJS.1219 order as listed in KBUILD_VMLINUX_OBJS.
1221 1220
1221 The objects listed in scripts/head-object-list.txt are exceptions;
1222 they are placed before the other objects.
1223
1222 KBUILD_VMLINUX_LIBS1224 KBUILD_VMLINUX_LIBS
1223 1225
1224 All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and1226 All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and
@@ -1262,8 +1264,7 @@ When kbuild executes, the following steps are followed (roughly): · 37 unmodified lines
1262 machinery is all architecture-independent.1264 machinery is all architecture-independent.
1263 1265
1264 1266
1265 head-y, core-y, libs-y, drivers-y1267 core-y, libs-y, drivers-y
1266 $(head-y) lists objects to be linked first in vmlinux.
1267 1268
1268 $(libs-y) lists directories where a lib.a archive can be located.1269 $(libs-y) lists directories where a lib.a archive can be located.
1269 1270
Makefile+2−2
@@ -1147,10 +1147,10 @@ quiet_cmd_ar_vmlinux.a = AR $@ · 1146 unmodified lines
1147 cmd_ar_vmlinux.a = \1147 cmd_ar_vmlinux.a = \
1148 rm -f $@; \1148 rm -f $@; \
1149 $(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \1149 $(AR) cDPrST $@ $(KBUILD_VMLINUX_OBJS); \
1150 $(AR) mPiT $$($(AR) t $@ | head -n1) $@ $(head-y)1150 $(AR) mPiT $$($(AR) t $@ | head -n1) $@ $$($(AR) t $@ | grep -F --file=$(srctree)/scripts/head-object-list.txt)
1151 1151
1152targets += vmlinux.a1152targets += vmlinux.a
1153vmlinux.a: $(KBUILD_VMLINUX_OBJS) autoksyms_recursive FORCE1153vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt autoksyms_recursive FORCE
1154 $(call if_changed,ar_vmlinux.a)1154 $(call if_changed,ar_vmlinux.a)
1155 1155
1156vmlinux.o: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE1156vmlinux.o: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
arch/alpha/Makefile+0−2
@@ -36,8 +36,6 @@ cflags-y += $(cpuflags-y) · 35 unmodified lines
36# BWX is most important, but we don't really want any emulation ever.36# BWX is most important, but we don't really want any emulation ever.
37KBUILD_CFLAGS += $(cflags-y) -Wa,-mev637KBUILD_CFLAGS += $(cflags-y) -Wa,-mev6
38 38
39head-y := arch/alpha/kernel/head.o
40
41libs-y += arch/alpha/lib/39libs-y += arch/alpha/lib/
42 40
43# export what is needed by arch/alpha/boot/Makefile41# export what is needed by arch/alpha/boot/Makefile
arch/arc/Makefile+0−2
@@ -82,8 +82,6 @@ KBUILD_CFLAGS += $(cflags-y) · 81 unmodified lines
82KBUILD_AFLAGS += $(KBUILD_CFLAGS)82KBUILD_AFLAGS += $(KBUILD_CFLAGS)
83KBUILD_LDFLAGS += $(ldflags-y)83KBUILD_LDFLAGS += $(ldflags-y)
84 84
85head-y := arch/arc/kernel/head.o
86
87# w/o this dtb won't embed into kernel binary85# w/o this dtb won't embed into kernel binary
88core-y += arch/arc/boot/dts/86core-y += arch/arc/boot/dts/
89 87
arch/arm/Makefile+0−3
@@ -134,9 +134,6 @@ KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/uni · 133 unmodified lines
134 134
135CHECKFLAGS += -D__arm__135CHECKFLAGS += -D__arm__
136 136
137#Default value
138head-y := arch/arm/kernel/head$(MMUEXT).o
139
140# Text offset. This list is sorted numerically by address in order to137# Text offset. This list is sorted numerically by address in order to
141# provide a means to avoid/resolve conflicts in multi-arch kernels.138# provide a means to avoid/resolve conflicts in multi-arch kernels.
142# Note: the 32kB below this value is reserved for use by the kernel139# Note: the 32kB below this value is reserved for use by the kernel
arch/arm64/Makefile+0−3
@@ -133,9 +133,6 @@ ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_REGS),y) · 132 unmodified lines
133 CC_FLAGS_FTRACE := -fpatchable-function-entry=2133 CC_FLAGS_FTRACE := -fpatchable-function-entry=2
134endif134endif
135 135
136# Default value
137head-y := arch/arm64/kernel/head.o
138
139ifeq ($(CONFIG_KASAN_SW_TAGS), y)136ifeq ($(CONFIG_KASAN_SW_TAGS), y)
140KASAN_SHADOW_SCALE_SHIFT := 4137KASAN_SHADOW_SCALE_SHIFT := 4
141else ifeq ($(CONFIG_KASAN_GENERIC), y)138else ifeq ($(CONFIG_KASAN_GENERIC), y)
arch/csky/Makefile+0−2
@@ -59,8 +59,6 @@ LDFLAGS += -EL · 58 unmodified lines
59 59
60KBUILD_AFLAGS += $(KBUILD_CFLAGS)60KBUILD_AFLAGS += $(KBUILD_CFLAGS)
61 61
62head-y := arch/csky/kernel/head.o
63
64core-y += arch/csky/$(CSKYABI)/62core-y += arch/csky/$(CSKYABI)/
65 63
66libs-y += arch/csky/lib/ \64libs-y += arch/csky/lib/ \
arch/hexagon/Makefile+0−2
@@ -32,5 +32,3 @@ KBUILD_LDFLAGS += $(ldflags-y) · 31 unmodified lines
32TIR_NAME := r1932TIR_NAME := r19
33KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__33KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__
34KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME)34KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME)
35
36head-y := arch/hexagon/kernel/head.o
arch/ia64/Makefile+0−1
@@ -44,7 +44,6 @@ quiet_cmd_objcopy = OBJCOPY $@ · 43 unmodified lines
44cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@44cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
45 45
46KBUILD_CFLAGS += $(cflags-y)46KBUILD_CFLAGS += $(cflags-y)
47head-y := arch/ia64/kernel/head.o
48 47
49libs-y += arch/ia64/lib/48libs-y += arch/ia64/lib/
50 49
arch/loongarch/Makefile+0−2
@@ -72,8 +72,6 @@ CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ · 71 unmodified lines
72 sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')72 sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')
73endif73endif
74 74
75head-y := arch/loongarch/kernel/head.o
76
77libs-y += arch/loongarch/lib/75libs-y += arch/loongarch/lib/
78 76
79ifeq ($(KBUILD_EXTMOD),)77ifeq ($(KBUILD_EXTMOD),)
arch/m68k/Makefile+0−9
@@ -86,15 +86,6 @@ ifdef CONFIG_KGDB · 85 unmodified lines
86KBUILD_CFLAGS := $(subst -fomit-frame-pointer,,$(KBUILD_CFLAGS)) -g86KBUILD_CFLAGS := $(subst -fomit-frame-pointer,,$(KBUILD_CFLAGS)) -g
87endif87endif
88 88
89#
90# Select the assembler head startup code. Order is important. The default
91# head code is first, processor specific selections can override it after.
92#
93head-y := arch/m68k/kernel/head.o
94head-$(CONFIG_SUN3) := arch/m68k/kernel/sun3-head.o
95head-$(CONFIG_M68000) := arch/m68k/68000/head.o
96head-$(CONFIG_COLDFIRE) := arch/m68k/coldfire/head.o
97
98libs-y += arch/m68k/lib/89libs-y += arch/m68k/lib/
99 90
100 91
arch/microblaze/Makefile+0−1
@@ -48,7 +48,6 @@ CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER)) · 47 unmodified lines
48# r31 holds current when in kernel mode48# r31 holds current when in kernel mode
49KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2)49KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2)
50 50
51head-y := arch/microblaze/kernel/head.o
52libs-y += arch/microblaze/lib/51libs-y += arch/microblaze/lib/
53 52
54boot := arch/microblaze/boot53boot := arch/microblaze/boot
arch/mips/Makefile+0−2
@@ -324,8 +324,6 @@ endif · 323 unmodified lines
324 324
325OBJCOPYFLAGS += --remove-section=.reginfo325OBJCOPYFLAGS += --remove-section=.reginfo
326 326
327head-y := arch/mips/kernel/head.o
328
329libs-y += arch/mips/lib/327libs-y += arch/mips/lib/
330libs-$(CONFIG_MIPS_FP_SUPPORT) += arch/mips/math-emu/328libs-$(CONFIG_MIPS_FP_SUPPORT) += arch/mips/math-emu/
331 329
arch/nios2/Makefile+0−1
@@ -37,7 +37,6 @@ KBUILD_CFLAGS += -DUTS_SYSNAME=\"$(UTS_SYSNAME)\" · 36 unmodified lines
37KBUILD_CFLAGS += -fno-builtin37KBUILD_CFLAGS += -fno-builtin
38KBUILD_CFLAGS += -G 038KBUILD_CFLAGS += -G 0
39 39
40head-y := arch/nios2/kernel/head.o
41libs-y += arch/nios2/lib/ $(LIBGCC)40libs-y += arch/nios2/lib/ $(LIBGCC)
42 41
43INSTALL_PATH ?= /tftpboot42INSTALL_PATH ?= /tftpboot
arch/openrisc/Makefile+0−2
@@ -55,8 +55,6 @@ ifeq ($(CONFIG_OPENRISC_HAVE_INST_SEXT),y) · 54 unmodified lines
55 KBUILD_CFLAGS += $(call cc-option,-msext)55 KBUILD_CFLAGS += $(call cc-option,-msext)
56endif56endif
57 57
58head-y := arch/openrisc/kernel/head.o
59
60libs-y += $(LIBGCC)58libs-y += $(LIBGCC)
61 59
62PHONY += vmlinux.bin60PHONY += vmlinux.bin
arch/parisc/Makefile+0−2
@@ -113,8 +113,6 @@ cflags-$(CONFIG_PA7100LC) += -march=1.1 -mschedule=7100LC · 112 unmodified lines
113cflags-$(CONFIG_PA7300LC) += -march=1.1 -mschedule=7300113cflags-$(CONFIG_PA7300LC) += -march=1.1 -mschedule=7300
114cflags-$(CONFIG_PA8X00) += -march=2.0 -mschedule=8000114cflags-$(CONFIG_PA8X00) += -march=2.0 -mschedule=8000
115 115
116head-y := arch/parisc/kernel/head.o
117
118KBUILD_CFLAGS += $(cflags-y)116KBUILD_CFLAGS += $(cflags-y)
119LIBGCC := $(shell $(CC) -print-libgcc-file-name)117LIBGCC := $(shell $(CC) -print-libgcc-file-name)
120export LIBGCC118export LIBGCC
arch/powerpc/Makefile+0−12
@@ -226,18 +226,6 @@ KBUILD_CFLAGS += $(cpu-as-y) · 225 unmodified lines
226KBUILD_AFLAGS += $(aflags-y)226KBUILD_AFLAGS += $(aflags-y)
227KBUILD_CFLAGS += $(cflags-y)227KBUILD_CFLAGS += $(cflags-y)
228 228
229head-$(CONFIG_PPC64) := arch/powerpc/kernel/head_64.o
230head-$(CONFIG_PPC_BOOK3S_32) := arch/powerpc/kernel/head_book3s_32.o
231head-$(CONFIG_PPC_8xx) := arch/powerpc/kernel/head_8xx.o
232head-$(CONFIG_40x) := arch/powerpc/kernel/head_40x.o
233head-$(CONFIG_44x) := arch/powerpc/kernel/head_44x.o
234head-$(CONFIG_FSL_BOOKE) := arch/powerpc/kernel/head_fsl_booke.o
235
236head-$(CONFIG_PPC64) += arch/powerpc/kernel/entry_64.o
237head-$(CONFIG_PPC_FPU) += arch/powerpc/kernel/fpu.o
238head-$(CONFIG_ALTIVEC) += arch/powerpc/kernel/vector.o
239head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += arch/powerpc/kernel/prom_init.o
240
241# Default to zImage, override when needed229# Default to zImage, override when needed
242all: zImage230all: zImage
243 231
arch/riscv/Makefile+0−2
@@ -110,8 +110,6 @@ else · 109 unmodified lines
110KBUILD_IMAGE := $(boot)/Image.gz110KBUILD_IMAGE := $(boot)/Image.gz
111endif111endif
112 112
113head-y := arch/riscv/kernel/head.o
114
115libs-y += arch/riscv/lib/113libs-y += arch/riscv/lib/
116libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a114libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
117 115
arch/s390/Makefile+0−2
@@ -119,8 +119,6 @@ export KBUILD_CFLAGS_DECOMPRESSOR · 118 unmodified lines
119 119
120OBJCOPYFLAGS := -O binary120OBJCOPYFLAGS := -O binary
121 121
122head-y := arch/s390/kernel/head64.o
123
124libs-y += arch/s390/lib/122libs-y += arch/s390/lib/
125drivers-y += drivers/s390/123drivers-y += drivers/s390/
126 124
arch/sh/Makefile+0−2
@@ -114,8 +114,6 @@ endif · 113 unmodified lines
114 114
115export ld-bfd115export ld-bfd
116 116
117head-y := arch/sh/kernel/head_32.o
118
119# Mach groups117# Mach groups
120machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se118machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se
121machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx119machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx
arch/sparc/Makefile+0−2
@@ -56,8 +56,6 @@ endif · 55 unmodified lines
56 56
57endif57endif
58 58
59head-y := arch/sparc/kernel/head_$(BITS).o
60
61libs-y += arch/sparc/prom/59libs-y += arch/sparc/prom/
62libs-y += arch/sparc/lib/60libs-y += arch/sparc/lib/
63 61
arch/x86/Makefile+0−5
@@ -234,11 +234,6 @@ archheaders: · 233 unmodified lines
234###234###
235# Kernel objects235# Kernel objects
236 236
237head-y := arch/x86/kernel/head_$(BITS).o
238head-y += arch/x86/kernel/head$(BITS).o
239head-y += arch/x86/kernel/ebda.o
240head-y += arch/x86/kernel/platform-quirks.o
241
242libs-y += arch/x86/lib/237libs-y += arch/x86/lib/
243 238
244# drivers-y are linked after core-y239# drivers-y are linked after core-y
arch/xtensa/Makefile+0−2
@@ -55,8 +55,6 @@ KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs)) · 54 unmodified lines
55 55
56KBUILD_DEFCONFIG := iss_defconfig56KBUILD_DEFCONFIG := iss_defconfig
57 57
58head-y := arch/xtensa/kernel/head.o
59
60libs-y += arch/xtensa/lib/58libs-y += arch/xtensa/lib/
61 59
62boot := arch/xtensa/boot60boot := arch/xtensa/boot
scripts/head-object-list.txt+53−0
@@ -0,0 +1,53 @@
1# Head objects
2#
3# The objects listed here are placed at the head of vmlinux. A typical use-case
4# is an object that contains the entry point. This is kept for compatibility
5# with head-y, which Kbuild used to support.
6#
7# A counter approach is to control the section placement by the linker script.
8# The code marked as __HEAD goes into the ".head.text" section, which is placed
9# before the normal ".text" section.
10#
11# If you can achieve the correct code ordering by linker script, please delete
12# the entry from this file.
13#
14arch/alpha/kernel/head.o
15arch/arc/kernel/head.o
16arch/arm/kernel/head-nommu.o
17arch/arm/kernel/head.o
18arch/arm64/kernel/head.o
19arch/csky/kernel/head.o
20arch/hexagon/kernel/head.o
21arch/ia64/kernel/head.o
22arch/loongarch/kernel/head.o
23arch/m68k/68000/head.o
24arch/m68k/coldfire/head.o
25arch/m68k/kernel/head.o
26arch/m68k/kernel/sun3-head.o
27arch/microblaze/kernel/head.o
28arch/mips/kernel/head.o
29arch/nios2/kernel/head.o
30arch/openrisc/kernel/head.o
31arch/parisc/kernel/head.o
32arch/powerpc/kernel/head_40x.o
33arch/powerpc/kernel/head_44x.o
34arch/powerpc/kernel/head_64.o
35arch/powerpc/kernel/head_8xx.o
36arch/powerpc/kernel/head_book3s_32.o
37arch/powerpc/kernel/head_fsl_booke.o
38arch/powerpc/kernel/entry_64.o
39arch/powerpc/kernel/fpu.o
40arch/powerpc/kernel/vector.o
41arch/powerpc/kernel/prom_init.o
42arch/riscv/kernel/head.o
43arch/s390/kernel/head64.o
44arch/sh/kernel/head_32.o
45arch/sparc/kernel/head_32.o
46arch/sparc/kernel/head_64.o
47arch/x86/kernel/head_32.o
48arch/x86/kernel/head_64.o
49arch/x86/kernel/head32.o
50arch/x86/kernel/head64.o
51arch/x86/kernel/ebda.o
52arch/x86/kernel/platform-quirks.o
53arch/xtensa/kernel/head.o