summaryrefslogtreecommitdiffstats
path: root/scripts/link-vmlinux.sh
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-14 17:26:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-14 17:26:58 -0400
commit84d69848c97faab0c25aa2667b273404d2e2a64a (patch)
tree594f3fe1b271b5255a1c5281e36f8bf938acd1c0 /scripts/link-vmlinux.sh
parentd4d24d2d0a7ea3b62efd7336bfc2344e29b36bc5 (diff)
parent590abbdd273304b55824bcb9ea91840ea375575d (diff)
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kbuild updates from Michal Marek: - EXPORT_SYMBOL for asm source by Al Viro. This does bring a regression, because genksyms no longer generates checksums for these symbols (CONFIG_MODVERSIONS). Nick Piggin is working on a patch to fix this. Plus, we are talking about functions like strcpy(), which rarely change prototypes. - Fixes for PPC fallout of the above by Stephen Rothwell and Nick Piggin - fixdep speedup by Alexey Dobriyan. - preparatory work by Nick Piggin to allow architectures to build with -ffunction-sections, -fdata-sections and --gc-sections - CONFIG_THIN_ARCHIVES support by Stephen Rothwell - fix for filenames with colons in the initramfs source by me. * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: (22 commits) initramfs: Escape colons in depfile ppc: there is no clear_pages to export powerpc/64: whitelist unresolved modversions CRCs kbuild: -ffunction-sections fix for archs with conflicting sections kbuild: add arch specific post-link Makefile kbuild: allow archs to select link dead code/data elimination kbuild: allow architectures to use thin archives instead of ld -r kbuild: Regenerate genksyms lexer kbuild: genksyms fix for typeof handling fixdep: faster CONFIG_ search ia64: move exports to definitions sparc32: debride memcpy.S a bit [sparc] unify 32bit and 64bit string.h sparc: move exports to definitions ppc: move exports to definitions arm: move exports to definitions s390: move exports to definitions m68k: move exports to definitions alpha: move exports to actual definitions x86: move exports to actual definitions ...
Diffstat (limited to 'scripts/link-vmlinux.sh')
-rwxr-xr-xscripts/link-vmlinux.sh71
1 files changed, 60 insertions, 11 deletions
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 4f727eb5ec43..f742c65108b9 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -37,12 +37,40 @@ info()
37 fi 37 fi
38} 38}
39 39
40# Thin archive build here makes a final archive with
41# symbol table and indexes from vmlinux objects, which can be
42# used as input to linker.
43#
44# Traditional incremental style of link does not require this step
45#
46# built-in.o output file
47#
48archive_builtin()
49{
50 if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
51 info AR built-in.o
52 rm -f built-in.o;
53 ${AR} rcsT${KBUILD_ARFLAGS} built-in.o \
54 ${KBUILD_VMLINUX_INIT} \
55 ${KBUILD_VMLINUX_MAIN}
56 fi
57}
58
40# Link of vmlinux.o used for section mismatch analysis 59# Link of vmlinux.o used for section mismatch analysis
41# ${1} output file 60# ${1} output file
42modpost_link() 61modpost_link()
43{ 62{
44 ${LD} ${LDFLAGS} -r -o ${1} ${KBUILD_VMLINUX_INIT} \ 63 local objects
45 --start-group ${KBUILD_VMLINUX_MAIN} --end-group 64
65 if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
66 objects="--whole-archive built-in.o"
67 else
68 objects="${KBUILD_VMLINUX_INIT} \
69 --start-group \
70 ${KBUILD_VMLINUX_MAIN} \
71 --end-group"
72 fi
73 ${LD} ${LDFLAGS} -r -o ${1} ${objects}
46} 74}
47 75
48# Link of vmlinux 76# Link of vmlinux
@@ -51,18 +79,36 @@ modpost_link()
51vmlinux_link() 79vmlinux_link()
52{ 80{
53 local lds="${objtree}/${KBUILD_LDS}" 81 local lds="${objtree}/${KBUILD_LDS}"
82 local objects
54 83
55 if [ "${SRCARCH}" != "um" ]; then 84 if [ "${SRCARCH}" != "um" ]; then
56 ${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} \ 85 if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
57 -T ${lds} ${KBUILD_VMLINUX_INIT} \ 86 objects="--whole-archive built-in.o ${1}"
58 --start-group ${KBUILD_VMLINUX_MAIN} --end-group ${1} 87 else
88 objects="${KBUILD_VMLINUX_INIT} \
89 --start-group \
90 ${KBUILD_VMLINUX_MAIN} \
91 --end-group \
92 ${1}"
93 fi
94
95 ${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} \
96 -T ${lds} ${objects}
59 else 97 else
60 ${CC} ${CFLAGS_vmlinux} -o ${2} \ 98 if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
61 -Wl,-T,${lds} ${KBUILD_VMLINUX_INIT} \ 99 objects="-Wl,--whole-archive built-in.o ${1}"
62 -Wl,--start-group \ 100 else
63 ${KBUILD_VMLINUX_MAIN} \ 101 objects="${KBUILD_VMLINUX_INIT} \
64 -Wl,--end-group \ 102 -Wl,--start-group \
65 -lutil -lrt -lpthread ${1} 103 ${KBUILD_VMLINUX_MAIN} \
104 -Wl,--end-group \
105 ${1}"
106 fi
107
108 ${CC} ${CFLAGS_vmlinux} -o ${2} \
109 -Wl,-T,${lds} \
110 ${objects} \
111 -lutil -lrt -lpthread
66 rm -f linux 112 rm -f linux
67 fi 113 fi
68} 114}
@@ -119,6 +165,7 @@ cleanup()
119 rm -f .tmp_kallsyms* 165 rm -f .tmp_kallsyms*
120 rm -f .tmp_version 166 rm -f .tmp_version
121 rm -f .tmp_vmlinux* 167 rm -f .tmp_vmlinux*
168 rm -f built-in.o
122 rm -f System.map 169 rm -f System.map
123 rm -f vmlinux 170 rm -f vmlinux
124 rm -f vmlinux.o 171 rm -f vmlinux.o
@@ -162,6 +209,8 @@ case "${KCONFIG_CONFIG}" in
162 . "./${KCONFIG_CONFIG}" 209 . "./${KCONFIG_CONFIG}"
163esac 210esac
164 211
212archive_builtin
213
165#link vmlinux.o 214#link vmlinux.o
166info LD vmlinux.o 215info LD vmlinux.o
167modpost_link vmlinux.o 216modpost_link vmlinux.o