Commit f49821ee authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Masahiro Yamada

kbuild: rename built-in.o to built-in.a

Incremental linking is gone, so rename built-in.o to built-in.a, which
is the usual extension for archive files.

This patch does two things, first is a simple search/replace:

git grep -l 'built-in\.o' | xargs sed -i 's/built-in\.o/built-in\.a/g'

The second is to invert nesting of nested text manipulations to avoid
filtering built-in.a out from libs-y2:

-libs-y2 := $(filter-out %.a, $(patsubst %/, %/built-in.a, $(libs-y)))
+libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y)))
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
parent 6358d6e8
...@@ -153,18 +153,18 @@ more details, with real examples. ...@@ -153,18 +153,18 @@ more details, with real examples.
configuration. configuration.
Kbuild compiles all the $(obj-y) files. It then calls Kbuild compiles all the $(obj-y) files. It then calls
"$(AR) rcSTP" to merge these files into one built-in.o file. "$(AR) rcSTP" to merge these files into one built-in.a file.
This is a thin archive without a symbol table, which makes it This is a thin archive without a symbol table, which makes it
unsuitable as a linker input. unsuitable as a linker input.
The scripts/link-vmlinux.sh script later makes an aggregate The scripts/link-vmlinux.sh script later makes an aggregate
built-in.o with "${AR} rcsTP", which creates the thin archive built-in.a with "${AR} rcsTP", which creates the thin archive
with a symbol table and an index, making it a valid input for with a symbol table and an index, making it a valid input for
the final vmlinux link passes. the final vmlinux link passes.
The order of files in $(obj-y) is significant. Duplicates in The order of files in $(obj-y) is significant. Duplicates in
the lists are allowed: the first instance will be linked into the lists are allowed: the first instance will be linked into
built-in.o and succeeding instances will be ignored. built-in.a and succeeding instances will be ignored.
Link order is significant, because certain functions Link order is significant, because certain functions
(module_init() / __initcall) will be called during boot in the (module_init() / __initcall) will be called during boot in the
...@@ -228,7 +228,7 @@ more details, with real examples. ...@@ -228,7 +228,7 @@ more details, with real examples.
Note: Of course, when you are building objects into the kernel, Note: Of course, when you are building objects into the kernel,
the syntax above will also work. So, if you have CONFIG_EXT2_FS=y, the syntax above will also work. So, if you have CONFIG_EXT2_FS=y,
kbuild will build an ext2.o file for you out of the individual kbuild will build an ext2.o file for you out of the individual
parts and then link this into built-in.o, as you would expect. parts and then link this into built-in.a, as you would expect.
--- 3.4 Objects which export symbols --- 3.4 Objects which export symbols
...@@ -238,7 +238,7 @@ more details, with real examples. ...@@ -238,7 +238,7 @@ more details, with real examples.
--- 3.5 Library file goals - lib-y --- 3.5 Library file goals - lib-y
Objects listed with obj-* are used for modules, or Objects listed with obj-* are used for modules, or
combined in a built-in.o for that specific directory. combined in a built-in.a for that specific directory.
There is also the possibility to list objects that will There is also the possibility to list objects that will
be included in a library, lib.a. be included in a library, lib.a.
All objects listed with lib-y are combined in a single All objects listed with lib-y are combined in a single
...@@ -250,7 +250,7 @@ more details, with real examples. ...@@ -250,7 +250,7 @@ more details, with real examples.
Note that the same kbuild makefile may list files to be built-in Note that the same kbuild makefile may list files to be built-in
and to be part of a library. Therefore the same directory and to be part of a library. Therefore the same directory
may contain both a built-in.o and a lib.a file. may contain both a built-in.a and a lib.a file.
Example: Example:
#arch/x86/lib/Makefile #arch/x86/lib/Makefile
...@@ -992,7 +992,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -992,7 +992,7 @@ When kbuild executes, the following steps are followed (roughly):
$(head-y) lists objects to be linked first in vmlinux. $(head-y) lists objects to be linked first in vmlinux.
$(libs-y) lists directories where a lib.a archive can be located. $(libs-y) lists directories where a lib.a archive can be located.
The rest list directories where a built-in.o object file can be The rest list directories where a built-in.a object file can be
located. located.
$(init-y) objects will be located after $(head-y). $(init-y) objects will be located after $(head-y).
...@@ -1077,7 +1077,7 @@ When kbuild executes, the following steps are followed (roughly): ...@@ -1077,7 +1077,7 @@ When kbuild executes, the following steps are followed (roughly):
extra-y := head.o init_task.o extra-y := head.o init_task.o
In this example, extra-y is used to list object files that In this example, extra-y is used to list object files that
shall be built, but shall not be linked as part of built-in.o. shall be built, but shall not be linked as part of built-in.a.
--- 6.7 Commands useful for building a boot image --- 6.7 Commands useful for building a boot image
......
...@@ -78,7 +78,7 @@ Binutils ...@@ -78,7 +78,7 @@ Binutils
-------- --------
The build system has, as of 4.13, switched to using thin archives (`ar T`) The build system has, as of 4.13, switched to using thin archives (`ar T`)
rather than incremental linking (`ld -r`) for built-in.o intermediate steps. rather than incremental linking (`ld -r`) for built-in.a intermediate steps.
This requires binutils 2.20 or newer. This requires binutils 2.20 or newer.
Flex Flex
......
...@@ -35,7 +35,7 @@ unexport GREP_OPTIONS ...@@ -35,7 +35,7 @@ unexport GREP_OPTIONS
# Most importantly: sub-Makefiles should only ever modify files in # Most importantly: sub-Makefiles should only ever modify files in
# their own directory. If in some directory we have a dependency on # their own directory. If in some directory we have a dependency on
# a file in another dir (which doesn't happen often, but it's often # a file in another dir (which doesn't happen often, but it's often
# unavoidable when linking the built-in.o targets which finally # unavoidable when linking the built-in.a targets which finally
# turn into vmlinux), we will call a sub make in that other dir, and # turn into vmlinux), we will call a sub make in that other dir, and
# after that we are sure that everything which is in that other dir # after that we are sure that everything which is in that other dir
# is now up to date. # is now up to date.
...@@ -982,13 +982,13 @@ vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ ...@@ -982,13 +982,13 @@ vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \ vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \
$(init-) $(core-) $(drivers-) $(net-) $(libs-) $(virt-)))) $(init-) $(core-) $(drivers-) $(net-) $(libs-) $(virt-))))
init-y := $(patsubst %/, %/built-in.o, $(init-y)) init-y := $(patsubst %/, %/built-in.a, $(init-y))
core-y := $(patsubst %/, %/built-in.o, $(core-y)) core-y := $(patsubst %/, %/built-in.a, $(core-y))
drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y))
net-y := $(patsubst %/, %/built-in.o, $(net-y)) net-y := $(patsubst %/, %/built-in.a, $(net-y))
libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
libs-y2 := $(filter-out %.a, $(patsubst %/, %/built-in.o, $(libs-y))) libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y)))
virt-y := $(patsubst %/, %/built-in.o, $(virt-y)) virt-y := $(patsubst %/, %/built-in.a, $(virt-y))
# Externally visible symbols (used by link-vmlinux.sh) # Externally visible symbols (used by link-vmlinux.sh)
export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) export KBUILD_VMLINUX_INIT := $(head-y) $(init-y)
......
...@@ -36,7 +36,7 @@ EXPORT_SYMBOL(memchr); ...@@ -36,7 +36,7 @@ EXPORT_SYMBOL(memchr);
/* /*
* Because string functions are both inline and exported functions and * Because string functions are both inline and exported functions and
* folder arch/blackfin/lib is configured as a library path in Makefile, * folder arch/blackfin/lib is configured as a library path in Makefile,
* symbols exported in folder lib is not linked into built-in.o but * symbols exported in folder lib is not linked into built-in.a but
* inlined only. In order to export string symbols to kernel module * inlined only. In order to export string symbols to kernel module
* properly, they should be exported here. * properly, they should be exported here.
*/ */
......
...@@ -165,7 +165,7 @@ systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i ...@@ -165,7 +165,7 @@ systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i
$(call cmd,systbl_chk) $(call cmd,systbl_chk)
ifeq ($(CONFIG_PPC_OF_BOOT_TRAMPOLINE),y) ifeq ($(CONFIG_PPC_OF_BOOT_TRAMPOLINE),y)
$(obj)/built-in.o: prom_init_check $(obj)/built-in.a: prom_init_check
quiet_cmd_prom_init_check = CALL $< quiet_cmd_prom_init_check = CALL $<
cmd_prom_init_check = $(CONFIG_SHELL) $< "$(NM)" "$(obj)/prom_init.o" cmd_prom_init_check = $(CONFIG_SHELL) $< "$(NM)" "$(obj)/prom_init.o"
......
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
obj-y += cio/ block/ char/ crypto/ net/ scsi/ virtio/ obj-y += cio/ block/ char/ crypto/ net/ scsi/ virtio/
drivers-y += drivers/s390/built-in.o drivers-y += drivers/s390/built-in.a
...@@ -324,11 +324,11 @@ config DEBUG_SECTION_MISMATCH ...@@ -324,11 +324,11 @@ config DEBUG_SECTION_MISMATCH
the analysis would not catch the illegal reference. the analysis would not catch the illegal reference.
This option tells gcc to inline less (but it does result in This option tells gcc to inline less (but it does result in
a larger kernel). a larger kernel).
- Run the section mismatch analysis for each module/built-in.o file. - Run the section mismatch analysis for each module/built-in.a file.
When we run the section mismatch analysis on vmlinux.o, we When we run the section mismatch analysis on vmlinux.o, we
lose valuable information about where the mismatch was lose valuable information about where the mismatch was
introduced. introduced.
Running the analysis for each module/built-in.o file Running the analysis for each module/built-in.a file
tells where the mismatch happens much closer to the tells where the mismatch happens much closer to the
source. The drawback is that the same mismatch is source. The drawback is that the same mismatch is
reported at least twice. reported at least twice.
......
...@@ -77,7 +77,7 @@ obj-y += $(obj)/lib-ksyms.o ...@@ -77,7 +77,7 @@ obj-y += $(obj)/lib-ksyms.o
endif endif
ifneq ($(strip $(obj-y) $(need-builtin)),) ifneq ($(strip $(obj-y) $(need-builtin)),)
builtin-target := $(obj)/built-in.o builtin-target := $(obj)/built-in.a
endif endif
modorder-target := $(obj)/modules.order modorder-target := $(obj)/modules.order
...@@ -104,7 +104,7 @@ ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) ...@@ -104,7 +104,7 @@ ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ; cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ;
endif endif
# Do section mismatch analysis for each module/built-in.o # Do section mismatch analysis for each module/built-in.a
ifdef CONFIG_DEBUG_SECTION_MISMATCH ifdef CONFIG_DEBUG_SECTION_MISMATCH
cmd_secanalysis = ; scripts/mod/modpost $@ cmd_secanalysis = ; scripts/mod/modpost $@
endif endif
...@@ -458,15 +458,15 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; ...@@ -458,15 +458,15 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
# #
ifdef builtin-target ifdef builtin-target
# built-in.o archives are made with no symbol table or index which # built-in.a archives are made with no symbol table or index which
# makes them small and fast, but unable to be used by the linker. # makes them small and fast, but unable to be used by the linker.
# scripts/link-vmlinux.sh builds an aggregate built-in.o with a symbol # scripts/link-vmlinux.sh builds an aggregate built-in.a with a symbol
# table and index. # table and index.
cmd_make_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) cmd_make_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS)
cmd_make_empty_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) cmd_make_empty_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS)
quiet_cmd_link_o_target = AR $@ quiet_cmd_link_o_target = AR $@
# If the list of objects to link is empty, just create an empty built-in.o # If the list of objects to link is empty, just create an empty built-in.a
cmd_link_o_target = $(if $(strip $(obj-y)),\ cmd_link_o_target = $(if $(strip $(obj-y)),\
$(cmd_make_builtin) $@ $(filter $(obj-y), $^) \ $(cmd_make_builtin) $@ $(filter $(obj-y), $^) \
$(cmd_secanalysis),\ $(cmd_secanalysis),\
......
...@@ -27,7 +27,7 @@ modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko ...@@ -27,7 +27,7 @@ modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko
# Handle objects in subdirs # Handle objects in subdirs
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o # o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a
# and add the directory to the list of dirs to descend into: $(subdir-y) # and add the directory to the list of dirs to descend into: $(subdir-y)
# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) # o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
# and add the directory to the list of dirs to descend into: $(subdir-m) # and add the directory to the list of dirs to descend into: $(subdir-m)
...@@ -35,7 +35,7 @@ __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) ...@@ -35,7 +35,7 @@ __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
subdir-y += $(__subdir-y) subdir-y += $(__subdir-y)
__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
subdir-m += $(__subdir-m) subdir-m += $(__subdir-m)
obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) obj-y := $(patsubst %/, %/built-in.a, $(obj-y))
obj-m := $(filter-out %/, $(obj-m)) obj-m := $(filter-out %/, $(obj-m))
# Subdirectories we need to descend into # Subdirectories we need to descend into
...@@ -54,7 +54,7 @@ multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) ...@@ -54,7 +54,7 @@ multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
# tell kbuild to descend # tell kbuild to descend
subdir-obj-y := $(filter %/built-in.o, $(obj-y)) subdir-obj-y := $(filter %/built-in.a, $(obj-y))
# Replace multi-part objects by their individual parts, look at local dir only # Replace multi-part objects by their individual parts, look at local dir only
real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# link vmlinux # link vmlinux
# #
# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and
# $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.o files # $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files
# from top-level directories in the kernel tree, others are specified in # from top-level directories in the kernel tree, others are specified in
# arch/$(ARCH)/Makefile. Ordering when linking is important, and # arch/$(ARCH)/Makefile. Ordering when linking is important, and
# $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives # $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# | +--< init/version.o + more # | +--< init/version.o + more
# | # |
# +--< $(KBUILD_VMLINUX_MAIN) # +--< $(KBUILD_VMLINUX_MAIN)
# | +--< drivers/built-in.o mm/built-in.o + more # | +--< drivers/built-in.a mm/built-in.a + more
# | # |
# +--< $(KBUILD_VMLINUX_LIBS) # +--< $(KBUILD_VMLINUX_LIBS)
# | +--< lib/lib.a + more # | +--< lib/lib.a + more
...@@ -51,13 +51,13 @@ info() ...@@ -51,13 +51,13 @@ info()
# #
# Traditional incremental style of link does not require this step # Traditional incremental style of link does not require this step
# #
# built-in.o output file # built-in.a output file
# #
archive_builtin() archive_builtin()
{ {
info AR built-in.o info AR built-in.a
rm -f built-in.o; rm -f built-in.a;
${AR} rcsTP${KBUILD_ARFLAGS} built-in.o \ ${AR} rcsTP${KBUILD_ARFLAGS} built-in.a \
${KBUILD_VMLINUX_INIT} \ ${KBUILD_VMLINUX_INIT} \
${KBUILD_VMLINUX_MAIN} ${KBUILD_VMLINUX_MAIN}
} }
...@@ -69,7 +69,7 @@ modpost_link() ...@@ -69,7 +69,7 @@ modpost_link()
local objects local objects
objects="--whole-archive \ objects="--whole-archive \
built-in.o \ built-in.a \
--no-whole-archive \ --no-whole-archive \
--start-group \ --start-group \
${KBUILD_VMLINUX_LIBS} \ ${KBUILD_VMLINUX_LIBS} \
...@@ -88,7 +88,7 @@ vmlinux_link() ...@@ -88,7 +88,7 @@ vmlinux_link()
if [ "${SRCARCH}" != "um" ]; then if [ "${SRCARCH}" != "um" ]; then
objects="--whole-archive \ objects="--whole-archive \
built-in.o \ built-in.a \
--no-whole-archive \ --no-whole-archive \
--start-group \ --start-group \
${KBUILD_VMLINUX_LIBS} \ ${KBUILD_VMLINUX_LIBS} \
...@@ -99,7 +99,7 @@ vmlinux_link() ...@@ -99,7 +99,7 @@ vmlinux_link()
-T ${lds} ${objects} -T ${lds} ${objects}
else else
objects="-Wl,--whole-archive \ objects="-Wl,--whole-archive \
built-in.o \ built-in.a \
-Wl,--no-whole-archive \ -Wl,--no-whole-archive \
-Wl,--start-group \ -Wl,--start-group \
${KBUILD_VMLINUX_LIBS} \ ${KBUILD_VMLINUX_LIBS} \
...@@ -164,7 +164,7 @@ cleanup() ...@@ -164,7 +164,7 @@ cleanup()
rm -f .tmp_System.map rm -f .tmp_System.map
rm -f .tmp_kallsyms* rm -f .tmp_kallsyms*
rm -f .tmp_vmlinux* rm -f .tmp_vmlinux*
rm -f built-in.o rm -f built-in.a
rm -f System.map rm -f System.map
rm -f vmlinux rm -f vmlinux
rm -f vmlinux.o rm -f vmlinux.o
......
...@@ -164,7 +164,7 @@ sub linux_objects ...@@ -164,7 +164,7 @@ sub linux_objects
s:^\./::; s:^\./::;
if (/.*\.o$/ && if (/.*\.o$/ &&
! ( ! (
m:/built-in.o$: m:/built-in.a$:
|| m:arch/x86/vdso/: || m:arch/x86/vdso/:
|| m:arch/x86/boot/: || m:arch/x86/boot/:
|| m:arch/ia64/ia32/ia32.o$: || m:arch/ia64/ia32/ia32.o$:
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
ld -m elf_i386 --format binary --oformat elf32-i386 -r \ ld -m elf_i386 --format binary --oformat elf32-i386 -r \
-T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o
ld -m elf_i386 -r -o built-in.o initramfs_data.o ld -m elf_i386 -r -o built-in.a initramfs_data.o
For including the .init.ramfs sections, see include/asm-generic/vmlinux.lds. For including the .init.ramfs sections, see include/asm-generic/vmlinux.lds.
......
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