diff options
-rw-r--r-- | Documentation/kbuild/kbuild.txt | 8 | ||||
-rw-r--r-- | Makefile | 8 | ||||
-rwxr-xr-x | scripts/link-vmlinux.sh | 45 |
3 files changed, 46 insertions, 15 deletions
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt index 0ff6a466a05b..ac2363ea05c5 100644 --- a/Documentation/kbuild/kbuild.txt +++ b/Documentation/kbuild/kbuild.txt | |||
@@ -236,5 +236,9 @@ Files specified with KBUILD_VMLINUX_INIT are linked first. | |||
236 | KBUILD_VMLINUX_MAIN | 236 | KBUILD_VMLINUX_MAIN |
237 | -------------------------------------------------- | 237 | -------------------------------------------------- |
238 | All object files for the main part of vmlinux. | 238 | All object files for the main part of vmlinux. |
239 | KBUILD_VMLINUX_INIT and KBUILD_VMLINUX_MAIN together specify | 239 | |
240 | all the object files used to link vmlinux. | 240 | KBUILD_VMLINUX_LIBS |
241 | -------------------------------------------------- | ||
242 | All .a "lib" files for vmlinux. | ||
243 | KBUILD_VMLINUX_INIT, KBUILD_VMLINUX_MAIN, and KBUILD_VMLINUX_LIBS together | ||
244 | specify all the object files used to link vmlinux. | ||
@@ -952,19 +952,19 @@ core-y := $(patsubst %/, %/built-in.o, $(core-y)) | |||
952 | drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) | 952 | drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) |
953 | net-y := $(patsubst %/, %/built-in.o, $(net-y)) | 953 | net-y := $(patsubst %/, %/built-in.o, $(net-y)) |
954 | libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) | 954 | libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) |
955 | libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) | 955 | libs-y2 := $(filter-out %.a, $(patsubst %/, %/built-in.o, $(libs-y))) |
956 | libs-y := $(libs-y1) $(libs-y2) | ||
957 | virt-y := $(patsubst %/, %/built-in.o, $(virt-y)) | 956 | virt-y := $(patsubst %/, %/built-in.o, $(virt-y)) |
958 | 957 | ||
959 | # Externally visible symbols (used by link-vmlinux.sh) | 958 | # Externally visible symbols (used by link-vmlinux.sh) |
960 | export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) | 959 | export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) |
961 | export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y) $(virt-y) | 960 | export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y) |
961 | export KBUILD_VMLINUX_LIBS := $(libs-y1) | ||
962 | export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds | 962 | export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds |
963 | export LDFLAGS_vmlinux | 963 | export LDFLAGS_vmlinux |
964 | # used by scripts/pacmage/Makefile | 964 | # used by scripts/pacmage/Makefile |
965 | export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) | 965 | export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) |
966 | 966 | ||
967 | vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) | 967 | vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) |
968 | 968 | ||
969 | # Include targets which we want to execute sequentially if the rest of the | 969 | # Include targets which we want to execute sequentially if the rest of the |
970 | # kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be | 970 | # kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be |
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 |