Commit dee94953 authored by Masahiro Yamada's avatar Masahiro Yamada

kbuild: remove top-level built-in.a

The symbol table in the final archive is unneeded; the linker does not
require the symbol table after the --whole-archive option. Every object
file in the archive is included in the link anyway.

Pass thin archives from subdirectories directly to the linker, and
remove the final archiving step.

Fix up the document and comments as well.
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: default avatarNicholas Piggin <npiggin@gmail.com>
parent 58156ba4
...@@ -154,13 +154,8 @@ more details, with real examples. ...@@ -154,13 +154,8 @@ more details, with real examples.
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.a 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. It will be later
unsuitable as a linker input. linked into vmlinux by scripts/link-vmlinux.sh
The scripts/link-vmlinux.sh script later makes an aggregate
built-in.a with "${AR} rcsTP", which creates the thin archive
with a symbol table and an index, making it a valid input for
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
......
...@@ -394,14 +394,10 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler ...@@ -394,14 +394,10 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
$(sort $(subdir-obj-y)): $(subdir-ym) ; $(sort $(subdir-obj-y)): $(subdir-ym) ;
# #
# Rule to compile a set of .o files into one .o file # Rule to compile a set of .o files into one .a file (without symbol table)
# #
ifdef builtin-target ifdef builtin-target
# 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.
# scripts/link-vmlinux.sh builds an aggregate built-in.a with a symbol
# table and index.
quiet_cmd_ar_builtin = AR $@ quiet_cmd_ar_builtin = AR $@
cmd_ar_builtin = rm -f $@; \ cmd_ar_builtin = rm -f $@; \
$(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^) $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^)
...@@ -426,7 +422,7 @@ $(modorder-target): $(subdir-ym) FORCE ...@@ -426,7 +422,7 @@ $(modorder-target): $(subdir-ym) FORCE
$(Q)(cat /dev/null; $(modorder-cmds)) > $@ $(Q)(cat /dev/null; $(modorder-cmds)) > $@
# #
# Rule to compile a set of .o files into one .a file # Rule to compile a set of .o files into one .a file (with symbol table)
# #
ifdef lib-target ifdef lib-target
quiet_cmd_link_l_target = AR $@ quiet_cmd_link_l_target = AR $@
......
...@@ -44,24 +44,6 @@ info() ...@@ -44,24 +44,6 @@ info()
fi fi
} }
# Thin archive build here makes a final archive with symbol table and indexes
# from vmlinux objects INIT and MAIN, which can be used as input to linker.
# KBUILD_VMLINUX_LIBS archives should already have symbol table and indexes
# added.
#
# Traditional incremental style of link does not require this step
#
# built-in.a output file
#
archive_builtin()
{
info AR built-in.a
rm -f built-in.a;
${AR} rcsTP${KBUILD_ARFLAGS} built-in.a \
${KBUILD_VMLINUX_INIT} \
${KBUILD_VMLINUX_MAIN}
}
# Link of vmlinux.o used for section mismatch analysis # Link of vmlinux.o used for section mismatch analysis
# ${1} output file # ${1} output file
modpost_link() modpost_link()
...@@ -69,7 +51,8 @@ modpost_link() ...@@ -69,7 +51,8 @@ modpost_link()
local objects local objects
objects="--whole-archive \ objects="--whole-archive \
built-in.a \ ${KBUILD_VMLINUX_INIT} \
${KBUILD_VMLINUX_MAIN} \
--no-whole-archive \ --no-whole-archive \
--start-group \ --start-group \
${KBUILD_VMLINUX_LIBS} \ ${KBUILD_VMLINUX_LIBS} \
...@@ -88,7 +71,8 @@ vmlinux_link() ...@@ -88,7 +71,8 @@ vmlinux_link()
if [ "${SRCARCH}" != "um" ]; then if [ "${SRCARCH}" != "um" ]; then
objects="--whole-archive \ objects="--whole-archive \
built-in.a \ ${KBUILD_VMLINUX_INIT} \
${KBUILD_VMLINUX_MAIN} \
--no-whole-archive \ --no-whole-archive \
--start-group \ --start-group \
${KBUILD_VMLINUX_LIBS} \ ${KBUILD_VMLINUX_LIBS} \
...@@ -99,7 +83,8 @@ vmlinux_link() ...@@ -99,7 +83,8 @@ vmlinux_link()
-T ${lds} ${objects} -T ${lds} ${objects}
else else
objects="-Wl,--whole-archive \ objects="-Wl,--whole-archive \
built-in.a \ ${KBUILD_VMLINUX_INIT} \
${KBUILD_VMLINUX_MAIN} \
-Wl,--no-whole-archive \ -Wl,--no-whole-archive \
-Wl,--start-group \ -Wl,--start-group \
${KBUILD_VMLINUX_LIBS} \ ${KBUILD_VMLINUX_LIBS} \
...@@ -160,7 +145,6 @@ cleanup() ...@@ -160,7 +145,6 @@ 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.a
rm -f System.map rm -f System.map
rm -f vmlinux rm -f vmlinux
rm -f vmlinux.o rm -f vmlinux.o
...@@ -217,8 +201,6 @@ fi; ...@@ -217,8 +201,6 @@ fi;
# final build of init/ # final build of init/
${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
archive_builtin
#link vmlinux.o #link vmlinux.o
info LD vmlinux.o info LD vmlinux.o
modpost_link vmlinux.o modpost_link vmlinux.o
......
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