summaryrefslogtreecommitdiffstats
path: root/scripts
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
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')
-rw-r--r--scripts/Makefile.build43
-rw-r--r--scripts/Makefile.modpost14
-rw-r--r--scripts/basic/fixdep.c86
-rwxr-xr-xscripts/gen_initramfs_list.sh5
-rw-r--r--scripts/genksyms/lex.l35
-rw-r--r--scripts/genksyms/lex.lex.c_shipped35
-rwxr-xr-xscripts/link-vmlinux.sh71
7 files changed, 174 insertions, 115 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 11602e5efb3b..de46ab03f063 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -81,6 +81,7 @@ endif
81 81
82ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) 82ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
83lib-target := $(obj)/lib.a 83lib-target := $(obj)/lib.a
84obj-y += $(obj)/lib-ksyms.o
84endif 85endif
85 86
86ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) 87ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
@@ -358,12 +359,22 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
358# Rule to compile a set of .o files into one .o file 359# Rule to compile a set of .o files into one .o file
359# 360#
360ifdef builtin-target 361ifdef builtin-target
361quiet_cmd_link_o_target = LD $@ 362
363ifdef CONFIG_THIN_ARCHIVES
364 cmd_make_builtin = rm -f $@; $(AR) rcST$(KBUILD_ARFLAGS)
365 cmd_make_empty_builtin = rm -f $@; $(AR) rcST$(KBUILD_ARFLAGS)
366 quiet_cmd_link_o_target = AR $@
367else
368 cmd_make_builtin = $(LD) $(ld_flags) -r -o
369 cmd_make_empty_builtin = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS)
370 quiet_cmd_link_o_target = LD $@
371endif
372
362# If the list of objects to link is empty, just create an empty built-in.o 373# If the list of objects to link is empty, just create an empty built-in.o
363cmd_link_o_target = $(if $(strip $(obj-y)),\ 374cmd_link_o_target = $(if $(strip $(obj-y)),\
364 $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ 375 $(cmd_make_builtin) $@ $(filter $(obj-y), $^) \
365 $(cmd_secanalysis),\ 376 $(cmd_secanalysis),\
366 rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@) 377 $(cmd_make_empty_builtin) $@)
367 378
368$(builtin-target): $(obj-y) FORCE 379$(builtin-target): $(obj-y) FORCE
369 $(call if_changed,link_o_target) 380 $(call if_changed,link_o_target)
@@ -389,12 +400,36 @@ $(modorder-target): $(subdir-ym) FORCE
389# 400#
390ifdef lib-target 401ifdef lib-target
391quiet_cmd_link_l_target = AR $@ 402quiet_cmd_link_l_target = AR $@
392cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y) 403
404ifdef CONFIG_THIN_ARCHIVES
405 cmd_link_l_target = rm -f $@; $(AR) rcsT$(KBUILD_ARFLAGS) $@ $(lib-y)
406else
407 cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y)
408endif
393 409
394$(lib-target): $(lib-y) FORCE 410$(lib-target): $(lib-y) FORCE
395 $(call if_changed,link_l_target) 411 $(call if_changed,link_l_target)
396 412
397targets += $(lib-target) 413targets += $(lib-target)
414
415dummy-object = $(obj)/.lib_exports.o
416ksyms-lds = $(dot-target).lds
417ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
418ref_prefix = EXTERN(_
419else
420ref_prefix = EXTERN(
421endif
422
423quiet_cmd_export_list = EXPORTS $@
424cmd_export_list = $(OBJDUMP) -h $< | \
425 sed -ne '/___ksymtab/{s/.*+/$(ref_prefix)/;s/ .*/)/;p}' >$(ksyms-lds);\
426 rm -f $(dummy-object);\
427 $(AR) rcs$(KBUILD_ARFLAGS) $(dummy-object);\
428 $(LD) $(ld_flags) -r -o $@ -T $(ksyms-lds) $(dummy-object);\
429 rm $(dummy-object) $(ksyms-lds)
430
431$(obj)/lib-ksyms.o: $(lib-target) FORCE
432 $(call if_changed,export_list)
398endif 433endif
399 434
400# 435#
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 1366a94b6c39..16923ba4b5b1 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -115,14 +115,18 @@ $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
115 115
116targets += $(modules:.ko=.mod.o) 116targets += $(modules:.ko=.mod.o)
117 117
118# Step 6), final link of the modules 118ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
119
120# Step 6), final link of the modules with optional arch pass after final link
119quiet_cmd_ld_ko_o = LD [M] $@ 121quiet_cmd_ld_ko_o = LD [M] $@
120 cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \ 122 cmd_ld_ko_o = \
121 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ 123 $(LD) -r $(LDFLAGS) \
122 -o $@ $(filter-out FORCE,$^) 124 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
125 -o $@ $(filter-out FORCE,$^) ; \
126 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
123 127
124$(modules): %.ko :%.o %.mod.o FORCE 128$(modules): %.ko :%.o %.mod.o FORCE
125 $(call if_changed,ld_ko_o) 129 +$(call if_changed,ld_ko_o)
126 130
127targets += $(modules) 131targets += $(modules)
128 132
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 746ec1ece614..fff818b92acb 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -82,8 +82,7 @@
82 * to date before even starting the recursive build, so it's too late 82 * to date before even starting the recursive build, so it's too late
83 * at this point anyway. 83 * at this point anyway.
84 * 84 *
85 * The algorithm to grep for "CONFIG_..." is bit unusual, but should 85 * We don't even try to really parse the header files, but
86 * be fast ;-) We don't even try to really parse the header files, but
87 * merely grep, i.e. if CONFIG_FOO is mentioned in a comment, it will 86 * merely grep, i.e. if CONFIG_FOO is mentioned in a comment, it will
88 * be picked up as well. It's not a problem with respect to 87 * be picked up as well. It's not a problem with respect to
89 * correctness, since that can only give too many dependencies, thus 88 * correctness, since that can only give too many dependencies, thus
@@ -115,11 +114,6 @@
115#include <ctype.h> 114#include <ctype.h>
116#include <arpa/inet.h> 115#include <arpa/inet.h>
117 116
118#define INT_CONF ntohl(0x434f4e46)
119#define INT_ONFI ntohl(0x4f4e4649)
120#define INT_NFIG ntohl(0x4e464947)
121#define INT_FIG_ ntohl(0x4649475f)
122
123int insert_extra_deps; 117int insert_extra_deps;
124char *target; 118char *target;
125char *depfile; 119char *depfile;
@@ -241,37 +235,22 @@ static void use_config(const char *m, int slen)
241 print_config(m, slen); 235 print_config(m, slen);
242} 236}
243 237
244static void parse_config_file(const char *map, size_t len) 238static void parse_config_file(const char *p)
245{ 239{
246 const int *end = (const int *) (map + len); 240 const char *q, *r;
247 /* start at +1, so that p can never be < map */ 241
248 const int *m = (const int *) map + 1; 242 while ((p = strstr(p, "CONFIG_"))) {
249 const char *p, *q;
250
251 for (; m < end; m++) {
252 if (*m == INT_CONF) { p = (char *) m ; goto conf; }
253 if (*m == INT_ONFI) { p = (char *) m-1; goto conf; }
254 if (*m == INT_NFIG) { p = (char *) m-2; goto conf; }
255 if (*m == INT_FIG_) { p = (char *) m-3; goto conf; }
256 continue;
257 conf:
258 if (p > map + len - 7)
259 continue;
260 if (memcmp(p, "CONFIG_", 7))
261 continue;
262 p += 7; 243 p += 7;
263 for (q = p; q < map + len; q++) { 244 q = p;
264 if (!(isalnum(*q) || *q == '_')) 245 while (*q && (isalnum(*q) || *q == '_'))
265 goto found; 246 q++;
266 } 247 if (memcmp(q - 7, "_MODULE", 7) == 0)
267 continue; 248 r = q - 7;
268 249 else
269 found: 250 r = q;
270 if (!memcmp(q - 7, "_MODULE", 7)) 251 if (r > p)
271 q -= 7; 252 use_config(p, r - p);
272 if (q - p < 0) 253 p = q;
273 continue;
274 use_config(p, q - p);
275 } 254 }
276} 255}
277 256
@@ -291,7 +270,7 @@ static void do_config_file(const char *filename)
291{ 270{
292 struct stat st; 271 struct stat st;
293 int fd; 272 int fd;
294 void *map; 273 char *map;
295 274
296 fd = open(filename, O_RDONLY); 275 fd = open(filename, O_RDONLY);
297 if (fd < 0) { 276 if (fd < 0) {
@@ -308,18 +287,23 @@ static void do_config_file(const char *filename)
308 close(fd); 287 close(fd);
309 return; 288 return;
310 } 289 }
311 map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); 290 map = malloc(st.st_size + 1);
312 if ((long) map == -1) { 291 if (!map) {
313 perror("fixdep: mmap"); 292 perror("fixdep: malloc");
314 close(fd); 293 close(fd);
315 return; 294 return;
316 } 295 }
296 if (read(fd, map, st.st_size) != st.st_size) {
297 perror("fixdep: read");
298 close(fd);
299 return;
300 }
301 map[st.st_size] = '\0';
302 close(fd);
317 303
318 parse_config_file(map, st.st_size); 304 parse_config_file(map);
319
320 munmap(map, st.st_size);
321 305
322 close(fd); 306 free(map);
323} 307}
324 308
325/* 309/*
@@ -446,22 +430,8 @@ static void print_deps(void)
446 close(fd); 430 close(fd);
447} 431}
448 432
449static void traps(void)
450{
451 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
452 int *p = (int *)test;
453
454 if (*p != INT_CONF) {
455 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
456 *p);
457 exit(2);
458 }
459}
460
461int main(int argc, char *argv[]) 433int main(int argc, char *argv[])
462{ 434{
463 traps();
464
465 if (argc == 5 && !strcmp(argv[1], "-e")) { 435 if (argc == 5 && !strcmp(argv[1], "-e")) {
466 insert_extra_deps = 1; 436 insert_extra_deps = 1;
467 argv++; 437 argv++;
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index 17fa901418ae..0055b07b03b6 100755
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -97,7 +97,10 @@ print_mtime() {
97} 97}
98 98
99list_parse() { 99list_parse() {
100 [ ! -L "$1" ] && echo "$1 \\" || : 100 if [ -L "$1" ]; then
101 return
102 fi
103 echo "$1" | sed 's/:/\\:/g; s/$/ \\/'
101} 104}
102 105
103# for each file print a line in following format 106# for each file print a line in following format
diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l
index e583565f2011..5235aa507ba5 100644
--- a/scripts/genksyms/lex.l
+++ b/scripts/genksyms/lex.l
@@ -289,6 +289,23 @@ repeat:
289 } 289 }
290 break; 290 break;
291 291
292 case ST_TYPEOF_1:
293 if (token == IDENT)
294 {
295 if (is_reserved_word(yytext, yyleng)
296 || find_symbol(yytext, SYM_TYPEDEF, 1))
297 {
298 yyless(0);
299 unput('(');
300 lexstate = ST_NORMAL;
301 token = TYPEOF_KEYW;
302 break;
303 }
304 _APP("(", 1);
305 }
306 lexstate = ST_TYPEOF;
307 /* FALLTHRU */
308
292 case ST_TYPEOF: 309 case ST_TYPEOF:
293 switch (token) 310 switch (token)
294 { 311 {
@@ -313,24 +330,6 @@ repeat:
313 } 330 }
314 break; 331 break;
315 332
316 case ST_TYPEOF_1:
317 if (token == IDENT)
318 {
319 if (is_reserved_word(yytext, yyleng)
320 || find_symbol(yytext, SYM_TYPEDEF, 1))
321 {
322 yyless(0);
323 unput('(');
324 lexstate = ST_NORMAL;
325 token = TYPEOF_KEYW;
326 break;
327 }
328 _APP("(", 1);
329 }
330 APP;
331 lexstate = ST_TYPEOF;
332 goto repeat;
333
334 case ST_BRACKET: 333 case ST_BRACKET:
335 APP; 334 APP;
336 switch (token) 335 switch (token)
diff --git a/scripts/genksyms/lex.lex.c_shipped b/scripts/genksyms/lex.lex.c_shipped
index f82740a69b85..985c5541aae4 100644
--- a/scripts/genksyms/lex.lex.c_shipped
+++ b/scripts/genksyms/lex.lex.c_shipped
@@ -2098,6 +2098,23 @@ repeat:
2098 } 2098 }
2099 break; 2099 break;
2100 2100
2101 case ST_TYPEOF_1:
2102 if (token == IDENT)
2103 {
2104 if (is_reserved_word(yytext, yyleng)
2105 || find_symbol(yytext, SYM_TYPEDEF, 1))
2106 {
2107 yyless(0);
2108 unput('(');
2109 lexstate = ST_NORMAL;
2110 token = TYPEOF_KEYW;
2111 break;
2112 }
2113 _APP("(", 1);
2114 }
2115 lexstate = ST_TYPEOF;
2116 /* FALLTHRU */
2117
2101 case ST_TYPEOF: 2118 case ST_TYPEOF:
2102 switch (token) 2119 switch (token)
2103 { 2120 {
@@ -2122,24 +2139,6 @@ repeat:
2122 } 2139 }
2123 break; 2140 break;
2124 2141
2125 case ST_TYPEOF_1:
2126 if (token == IDENT)
2127 {
2128 if (is_reserved_word(yytext, yyleng)
2129 || find_symbol(yytext, SYM_TYPEDEF, 1))
2130 {
2131 yyless(0);
2132 unput('(');
2133 lexstate = ST_NORMAL;
2134 token = TYPEOF_KEYW;
2135 break;
2136 }
2137 _APP("(", 1);
2138 }
2139 APP;
2140 lexstate = ST_TYPEOF;
2141 goto repeat;
2142
2143 case ST_BRACKET: 2142 case ST_BRACKET:
2144 APP; 2143 APP;
2145 switch (token) 2144 switch (token)
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