aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/link-vmlinux.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/link-vmlinux.sh')
-rwxr-xr-xscripts/link-vmlinux.sh72
1 files changed, 12 insertions, 60 deletions
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index eecc1863e556..918470d768e9 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -3,17 +3,15 @@
#
# link vmlinux
#
-# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and
-# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories
-# in the kernel tree, others are specified in arch/$(ARCH)/Makefile.
+# vmlinux is linked from the objects in vmlinux.a and $(KBUILD_VMLINUX_LIBS).
+# vmlinux.a contains objects that are linked unconditionally.
# $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally
# (not within --whole-archive), and do not require symbol indexes added.
#
# vmlinux
# ^
# |
-# +--< $(KBUILD_VMLINUX_OBJS)
-# | +--< init/built-in.a drivers/built-in.a mm/built-in.a + more
+# +--< vmlinux.a
# |
# +--< $(KBUILD_VMLINUX_LIBS)
# | +--< lib/lib.a + more
@@ -67,7 +65,7 @@ vmlinux_link()
objs=vmlinux.o
libs=
else
- objs="${KBUILD_VMLINUX_OBJS}"
+ objs=vmlinux.a
libs="${KBUILD_VMLINUX_LIBS}"
fi
@@ -75,6 +73,8 @@ vmlinux_link()
objs="${objs} .vmlinux.export.o"
fi
+ objs="${objs} init/version-timestamp.o"
+
if [ "${SRCARCH}" = "um" ]; then
wl=-Wl,
ld="${CC}"
@@ -157,7 +157,7 @@ kallsyms()
fi
info KSYMS ${2}
- ${NM} -n ${1} | scripts/kallsyms ${kallsymopt} > ${2}
+ scripts/kallsyms ${kallsymopt} ${1} > ${2}
}
# Perform one step in kallsyms generation, including temporary linking of
@@ -170,7 +170,8 @@ kallsyms_step()
kallsyms_S=${kallsyms_vmlinux}.S
vmlinux_link ${kallsyms_vmlinux} "${kallsymso_prev}" ${btf_vmlinux_bin_o}
- kallsyms ${kallsyms_vmlinux} ${kallsyms_S}
+ mksysmap ${kallsyms_vmlinux} ${kallsyms_vmlinux}.syms
+ kallsyms ${kallsyms_vmlinux}.syms ${kallsyms_S}
info AS ${kallsyms_S}
${CC} ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS} \
@@ -182,6 +183,7 @@ kallsyms_step()
# See mksymap for additional details
mksysmap()
{
+ info NM ${2}
${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2}
}
@@ -197,8 +199,6 @@ cleanup()
rm -f System.map
rm -f vmlinux
rm -f vmlinux.map
- rm -f .vmlinux.objs
- rm -f .vmlinux.export.c
}
# Use "make V=1" to debug this script
@@ -213,52 +213,7 @@ if [ "$1" = "clean" ]; then
exit 0
fi
-# Update version
-info GEN .version
-if [ -r .version ]; then
- VERSION=$(expr 0$(cat .version) + 1)
- echo $VERSION > .version
-else
- rm -f .version
- echo 1 > .version
-fi;
-
-# final build of init/
-${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1
-
-#link vmlinux.o
-${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o"
-
-# Generate the list of in-tree objects in vmlinux
-#
-# This is used to retrieve symbol versions generated by genksyms.
-for f in ${KBUILD_VMLINUX_OBJS} ${KBUILD_VMLINUX_LIBS}; do
- case ${f} in
- *libgcc.a)
- # Some architectures do '$(CC) --print-libgcc-file-name' to
- # borrow libgcc.a from the toolchain.
- # There is no EXPORT_SYMBOL in external objects. Ignore this.
- ;;
- *.a)
- ${AR} t ${f} ;;
- *)
- echo ${f} ;;
- esac
-done > .vmlinux.objs
-
-# modpost vmlinux.o to check for section mismatches
-${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
-
-info MODINFO modules.builtin.modinfo
-${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo
-info GEN modules.builtin
-# The second line aids cases where multiple modules share the same object.
-tr '\0' '\n' < modules.builtin.modinfo | sed -n 's/^[[:alnum:]:_]*\.file=//p' |
- tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$/.ko/' > modules.builtin
-
-if is_enabled CONFIG_MODULES; then
- ${MAKE} -f "${srctree}/scripts/Makefile.vmlinux" .vmlinux.export.o
-fi
+${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init init/version-timestamp.o
btf_vmlinux_bin_o=""
if is_enabled CONFIG_DEBUG_INFO_BTF; then
@@ -318,7 +273,6 @@ if is_enabled CONFIG_DEBUG_INFO_BTF && is_enabled CONFIG_BPF; then
${RESOLVE_BTFIDS} vmlinux
fi
-info SYSMAP System.map
mksysmap vmlinux System.map
if is_enabled CONFIG_BUILDTIME_TABLE_SORT; then
@@ -331,9 +285,7 @@ fi
# step a (see comment above)
if is_enabled CONFIG_KALLSYMS; then
- mksysmap ${kallsyms_vmlinux} .tmp_System.map
-
- if ! cmp -s System.map .tmp_System.map; then
+ if ! cmp -s System.map ${kallsyms_vmlinux}.syms; then
echo >&2 Inconsistent kallsyms data
echo >&2 Try "make KALLSYMS_EXTRA_PASS=1" as a workaround
exit 1