Commit ce697cce authored by Masahiro Yamada's avatar Masahiro Yamada
Browse files

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.

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 32164845
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -1070,8 +1070,7 @@ When kbuild executes, the following steps are followed (roughly):
   - The values of the above variables are expanded in arch/$(SRCARCH)/Makefile.
5) All object files are then linked and the resulting file vmlinux is
   located at the root of the obj tree.
   The very first objects linked are listed in head-y, assigned by
   arch/$(SRCARCH)/Makefile.
   The very first objects linked are listed in scripts/head-object-list.txt.
6) Finally, the architecture-specific part does any required post processing
   and builds the final bootimage.
   - This includes building boot records
@@ -1219,6 +1218,9 @@ When kbuild executes, the following steps are followed (roughly):
	All object files for vmlinux. They are linked to vmlinux in the same
	order as listed in KBUILD_VMLINUX_OBJS.

	The objects listed in scripts/head-object-list.txt are exceptions;
	they are placed before the other objects.

    KBUILD_VMLINUX_LIBS

	All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and
@@ -1262,8 +1264,7 @@ When kbuild executes, the following steps are followed (roughly):
	machinery is all architecture-independent.


	head-y, core-y, libs-y, drivers-y
	    $(head-y) lists objects to be linked first in vmlinux.
	core-y, libs-y, drivers-y

	    $(libs-y) lists directories where a lib.a archive can be located.

+2 −2
Original line number Diff line number Diff line
@@ -1147,10 +1147,10 @@ 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)
	$(AR) mPiT $$($(AR) t $@ | head -n1) $@ $$($(AR) t $@ | grep -F --file=$(srctree)/scripts/head-object-list.txt)

targets += vmlinux.a
vmlinux.a: $(KBUILD_VMLINUX_OBJS) autoksyms_recursive FORCE
vmlinux.a: $(KBUILD_VMLINUX_OBJS) scripts/head-object-list.txt autoksyms_recursive FORCE
	$(call if_changed,ar_vmlinux.a)

vmlinux.o: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
+0 −2
Original line number Diff line number Diff line
@@ -36,8 +36,6 @@ cflags-y += $(cpuflags-y)
# BWX is most important, but we don't really want any emulation ever.
KBUILD_CFLAGS += $(cflags-y) -Wa,-mev6

head-y := arch/alpha/kernel/head.o

libs-y				+= arch/alpha/lib/

# export what is needed by arch/alpha/boot/Makefile
+0 −2
Original line number Diff line number Diff line
@@ -82,8 +82,6 @@ KBUILD_CFLAGS += $(cflags-y)
KBUILD_AFLAGS	+= $(KBUILD_CFLAGS)
KBUILD_LDFLAGS	+= $(ldflags-y)

head-y		:= arch/arc/kernel/head.o

# w/o this dtb won't embed into kernel binary
core-y		+= arch/arc/boot/dts/

+0 −3
Original line number Diff line number Diff line
@@ -134,9 +134,6 @@ KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/uni

CHECKFLAGS	+= -D__arm__

#Default value
head-y		:= arch/arm/kernel/head$(MMUEXT).o

# Text offset. This list is sorted numerically by address in order to
# provide a means to avoid/resolve conflicts in multi-arch kernels.
# Note: the 32kB below this value is reserved for use by the kernel
Loading