diff options
Diffstat (limited to 'scripts/link-vmlinux.sh')
-rwxr-xr-x | scripts/link-vmlinux.sh | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 72a0aa627c56..e7b7eee31538 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh | |||
@@ -3,9 +3,12 @@ | |||
3 | # link vmlinux | 3 | # link vmlinux |
4 | # | 4 | # |
5 | # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and | 5 | # vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and |
6 | # $(KBUILD_VMLINUX_MAIN). Most are built-in.o files from top-level directories | 6 | # $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.o files |
7 | # in the kernel tree, others are specified in arch/$(ARCH)/Makefile. | 7 | # from top-level directories in the kernel tree, others are specified in |
8 | # Ordering when linking is important, and $(KBUILD_VMLINUX_INIT) must be first. | 8 | # arch/$(ARCH)/Makefile. Ordering when linking is important, and |
9 | # $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives | ||
10 | # which are linked conditionally (not within --whole-archive), and do not | ||
11 | # require symbol indexes added. | ||
9 | # | 12 | # |
10 | # vmlinux | 13 | # vmlinux |
11 | # ^ | 14 | # ^ |
@@ -16,6 +19,9 @@ | |||
16 | # +--< $(KBUILD_VMLINUX_MAIN) | 19 | # +--< $(KBUILD_VMLINUX_MAIN) |
17 | # | +--< drivers/built-in.o mm/built-in.o + more | 20 | # | +--< drivers/built-in.o mm/built-in.o + more |
18 | # | | 21 | # | |
22 | # +--< $(KBUILD_VMLINUX_LIBS) | ||
23 | # | +--< lib/lib.a + more | ||
24 | # | | ||
19 | # +-< ${kallsymso} (see description in KALLSYMS section) | 25 | # +-< ${kallsymso} (see description in KALLSYMS section) |
20 | # | 26 | # |
21 | # vmlinux version (uname -v) cannot be updated during normal | 27 | # vmlinux version (uname -v) cannot be updated during normal |
@@ -37,9 +43,10 @@ info() | |||
37 | fi | 43 | fi |
38 | } | 44 | } |
39 | 45 | ||
40 | # Thin archive build here makes a final archive with | 46 | # Thin archive build here makes a final archive with symbol table and indexes |
41 | # symbol table and indexes from vmlinux objects, which can be | 47 | # from vmlinux objects INIT and MAIN, which can be used as input to linker. |
42 | # used as input to linker. | 48 | # KBUILD_VMLINUX_LIBS archives should already have symbol table and indexes |
49 | # added. | ||
43 | # | 50 | # |
44 | # Traditional incremental style of link does not require this step | 51 | # Traditional incremental style of link does not require this step |
45 | # | 52 | # |
@@ -63,11 +70,17 @@ modpost_link() | |||
63 | local objects | 70 | local objects |
64 | 71 | ||
65 | if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then | 72 | if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then |
66 | objects="--whole-archive built-in.o --no-whole-archive" | 73 | objects="--whole-archive \ |
74 | built-in.o \ | ||
75 | --no-whole-archive \ | ||
76 | --start-group \ | ||
77 | ${KBUILD_VMLINUX_LIBS} \ | ||
78 | --end-group" | ||
67 | else | 79 | else |
68 | objects="${KBUILD_VMLINUX_INIT} \ | 80 | objects="${KBUILD_VMLINUX_INIT} \ |
69 | --start-group \ | 81 | --start-group \ |
70 | ${KBUILD_VMLINUX_MAIN} \ | 82 | ${KBUILD_VMLINUX_MAIN} \ |
83 | ${KBUILD_VMLINUX_LIBS} \ | ||
71 | --end-group" | 84 | --end-group" |
72 | fi | 85 | fi |
73 | ${LD} ${LDFLAGS} -r -o ${1} ${objects} | 86 | ${LD} ${LDFLAGS} -r -o ${1} ${objects} |
@@ -83,11 +96,18 @@ vmlinux_link() | |||
83 | 96 | ||
84 | if [ "${SRCARCH}" != "um" ]; then | 97 | if [ "${SRCARCH}" != "um" ]; then |
85 | if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then | 98 | if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then |
86 | objects="--whole-archive built-in.o ${1} --no-whole-archive" | 99 | objects="--whole-archive \ |
100 | built-in.o \ | ||
101 | --no-whole-archive \ | ||
102 | --start-group \ | ||
103 | ${KBUILD_VMLINUX_LIBS} \ | ||
104 | --end-group \ | ||
105 | ${1}" | ||
87 | else | 106 | else |
88 | objects="${KBUILD_VMLINUX_INIT} \ | 107 | objects="${KBUILD_VMLINUX_INIT} \ |
89 | --start-group \ | 108 | --start-group \ |
90 | ${KBUILD_VMLINUX_MAIN} \ | 109 | ${KBUILD_VMLINUX_MAIN} \ |
110 | ${KBUILD_VMLINUX_LIBS} \ | ||
91 | --end-group \ | 111 | --end-group \ |
92 | ${1}" | 112 | ${1}" |
93 | fi | 113 | fi |
@@ -96,11 +116,18 @@ vmlinux_link() | |||
96 | -T ${lds} ${objects} | 116 | -T ${lds} ${objects} |
97 | else | 117 | else |
98 | if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then | 118 | if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then |
99 | objects="-Wl,--whole-archive built-in.o ${1} -Wl,--no-whole-archive" | 119 | objects="-Wl,--whole-archive \ |
120 | built-in.o \ | ||
121 | -Wl,--no-whole-archive \ | ||
122 | -Wl,--start-group \ | ||
123 | ${KBUILD_VMLINUX_LIBS} \ | ||
124 | -Wl,--end-group \ | ||
125 | ${1}" | ||
100 | else | 126 | else |
101 | objects="${KBUILD_VMLINUX_INIT} \ | 127 | objects="${KBUILD_VMLINUX_INIT} \ |
102 | -Wl,--start-group \ | 128 | -Wl,--start-group \ |
103 | ${KBUILD_VMLINUX_MAIN} \ | 129 | ${KBUILD_VMLINUX_MAIN} \ |
130 | ${KBUILD_VMLINUX_LIBS} \ | ||
104 | -Wl,--end-group \ | 131 | -Wl,--end-group \ |
105 | ${1}" | 132 | ${1}" |
106 | fi | 133 | fi |