summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChris Boot <bootc@debian.org>2021-12-27 13:00:05 +0000
committerChris Boot <bootc@debian.org>2021-12-27 13:00:05 +0000
commit7ae50eedeb8861ecf9c3acb232d527ca1884d9d3 (patch)
tree605788911762c54b7129bfbb05a9d7c4f977b47b /scripts
parentb193de597fcfb44f77408a1e0b82f93764467455 (diff)
parente512aeb0fb3c585948ae6517cfdf4a53cf99774d (diff)
New upstream version 1.35.0
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include1
-rw-r--r--scripts/Makefile.IMA1
-rw-r--r--scripts/Makefile.lib8
-rw-r--r--scripts/basic/docproc.c18
-rw-r--r--scripts/basic/fixdep.c12
-rw-r--r--scripts/basic/split-include.c5
-rwxr-xr-xscripts/bb_release1
-rwxr-xr-xscripts/bloat-o-meter21
-rwxr-xr-xscripts/checkstack.pl108
-rw-r--r--scripts/echo.c1
-rwxr-xr-xscripts/gcc-version.sh4
-rwxr-xr-xscripts/gen_build_files.sh2
-rw-r--r--scripts/kconfig/conf.c12
-rw-r--r--scripts/kconfig/confdata.c19
-rw-r--r--scripts/kconfig/lxdialog/lxdialog.c2
-rw-r--r--scripts/kconfig/mconf.c9
-rwxr-xr-xscripts/randomtest27
-rwxr-xr-xscripts/randomtest.loop11
-rwxr-xr-xscripts/trylink20
19 files changed, 192 insertions, 90 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 6ec1809a2..5b4db5c2c 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -4,6 +4,7 @@
# Convinient variables
comma := ,
squote := '
+quote := "
empty :=
space := $(empty) $(empty)
diff --git a/scripts/Makefile.IMA b/scripts/Makefile.IMA
index f155108d7..1e3005864 100644
--- a/scripts/Makefile.IMA
+++ b/scripts/Makefile.IMA
@@ -49,7 +49,6 @@ OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
CFLAGS := $(CFLAGS)
-CPPFLAGS += -D"KBUILD_STR(s)=\#s" #-Q
# We need some generic definitions
include $(srctree)/scripts/Kbuild.include
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3e54ea712..d8d768a28 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -81,10 +81,10 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
# Note: It's possible that one object gets potentially linked into more
# than one module. In that case KBUILD_MODNAME will be set to foo_bar,
# where foo and bar are the name of the modules.
-name-fix = $(subst $(comma),_,$(subst -,_,$1))
-basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(*F)))"
+name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
+basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(*F))
modname_flags = $(if $(filter 1,$(words $(modname))),\
- -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
+ -DKBUILD_MODNAME=$(call name-fix,$(modname)))
_c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o)
_a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
@@ -110,7 +110,7 @@ endif
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
$(__c_flags) $(modkern_cflags) \
- -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
+ $(basename_flags) $(modname_flags)
a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
$(__a_flags) $(modkern_aflags)
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
index 720098a23..4464e1874 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/basic/docproc.c
@@ -182,10 +182,10 @@ void find_export_symbols(char * filename)
perror(real_filename);
}
while (fgets(line, MAXLINESZ, fp)) {
- char *p;
- char *e;
- if (((p = strstr(line, "EXPORT_SYMBOL_GPL")) != 0) ||
- ((p = strstr(line, "EXPORT_SYMBOL")) != 0)) {
+ unsigned char *p;
+ unsigned char *e;
+ if (((p = (unsigned char *)strstr(line, "EXPORT_SYMBOL_GPL")) != 0) ||
+ ((p = (unsigned char *)strstr(line, "EXPORT_SYMBOL")) != 0)) {
/* Skip EXPORT_SYMBOL{_GPL} */
while (isalnum(*p) || *p == '_')
p++;
@@ -202,7 +202,7 @@ void find_export_symbols(char * filename)
while (isalnum(*e) || *e == '_')
e++;
*e = '\0';
- add_new_symbol(sym, p);
+ add_new_symbol(sym, (char*)p);
}
}
fclose(fp);
@@ -266,7 +266,7 @@ void singfunc(char * filename, char * line)
/* Split line up in individual parameters preceded by FUNCTION */
for (i=0; line[i]; i++) {
- if (isspace(line[i])) {
+ if (isspace((unsigned char) line[i])) {
line[i] = '\0';
startofsym = 1;
continue;
@@ -293,10 +293,10 @@ void singfunc(char * filename, char * line)
void parse_file(FILE *infile)
{
char line[MAXLINESZ];
- char * s;
+ unsigned char * s;
while (fgets(line, MAXLINESZ, infile)) {
if (line[0] == '!') {
- s = line + 2;
+ s = (unsigned char *)line + 2;
switch (line[1]) {
case 'E':
while (*s && !isspace(*s)) s++;
@@ -320,7 +320,7 @@ void parse_file(FILE *infile)
/* function names */
while (isspace(*s))
s++;
- singlefunctions(line +2, s);
+ singlefunctions(line +2, (char*)s);
break;
default:
defaultline(line);
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 19f82df09..426b4888b 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -226,10 +226,10 @@ void use_config(char *m, int slen)
void parse_config_file(char *map, size_t len)
{
/* modified for bbox */
- char *end_3 = map + len - 3; /* 3 == length of "IF_" */
- char *end_7 = map + len - 7;
- char *p = map;
- char *q;
+ unsigned char *end_3 = (unsigned char *)map + len - 3; /* 3 == length of "IF_" */
+ unsigned char *end_7 = (unsigned char *)map + len - 7;
+ unsigned char *p = (unsigned char *)map;
+ unsigned char *q;
int off;
for (; p <= end_3; p++) {
@@ -263,7 +263,7 @@ void parse_config_file(char *map, size_t len)
break;
}
if (q != p) {
- use_config(p, q-p);
+ use_config((char*)p, q - p);
}
}
}
@@ -335,7 +335,7 @@ void parse_dep_file(void *map, size_t len)
p = m;
while (p < end && *p != ' ') p++;
if (p == end) {
- do p--; while (!isalnum(*p));
+ do p--; while (!isalnum((unsigned char)*p));
p++;
}
memcpy(s, m, p-m); s[p-m] = 0;
diff --git a/scripts/basic/split-include.c b/scripts/basic/split-include.c
index e328788e2..6ef29195e 100644
--- a/scripts/basic/split-include.c
+++ b/scripts/basic/split-include.c
@@ -116,7 +116,7 @@ int main(int argc, const char * argv [])
/* We found #define CONFIG_foo or #undef CONFIG_foo.
* Make the output file name. */
str_config += sizeof(" CONFIG_") - 1;
- for (itarget = 0; !isspace(str_config[itarget]); itarget++)
+ for (itarget = 0; !isspace((unsigned char)str_config[itarget]); itarget++)
{
int c = (unsigned char) str_config[itarget];
if (isupper(c)) c = tolower(c);
@@ -131,7 +131,8 @@ int main(int argc, const char * argv [])
is_same = 0;
if ((fp_target = fopen(ptarget, "r")) != NULL)
{
- fgets(old_line, buffer_size, fp_target);
+ if (!fgets(old_line, buffer_size, fp_target) && ferror(fp_target))
+ ERROR_EXIT(ptarget);
if (fclose(fp_target) != 0)
ERROR_EXIT(ptarget);
if (!strcmp(line, old_line))
diff --git a/scripts/bb_release b/scripts/bb_release
index 2e146bf84..545440d3a 100755
--- a/scripts/bb_release
+++ b/scripts/bb_release
@@ -8,6 +8,7 @@
#svn co svn://busybox.net/trunk/busybox
cd busybox || { echo "cd busybox failed"; exit 1; }
+chmod -Rc u+w,a+rX,go-w .
make release || { echo "make release failed"; exit 1; }
cd ..
diff --git a/scripts/bloat-o-meter b/scripts/bloat-o-meter
index cb861b8e9..b4a1d2811 100755
--- a/scripts/bloat-o-meter
+++ b/scripts/bloat-o-meter
@@ -43,7 +43,15 @@ if f1 is None or f2 is None:
sym_args = " ".join(sys.argv[3 + flag_timing + dashes:])
def getsizes(file):
- sym, alias, lut = {}, {}, {}
+ sym, alias, lut, section = {}, {}, {}, {}
+ for l in os.popen("readelf -W -S " + file).readlines():
+ x = l.replace("[ ", "[", 1).split()
+ if len(x)<6: continue
+ # Should take these into account too!
+ #if x[1] not in [".text", ".rodata", ".symtab", ".strtab"]: continue
+ if x[1] not in [".rodata"]: continue
+ sym[x[1]] = {"addr" : int(x[3], 16), "size" : int(x[5], 16)}
+ section[x[0][1:-1]] = {"name" : x[1]}
for l in os.popen("readelf -W -s %s %s" % (sym_args, file)).readlines():
l = l.strip()
if not (len(l) and l[0].isdigit() and len(l.split()) == 8):
@@ -59,6 +67,10 @@ def getsizes(file):
else:
sym[name] = {"addr" : value, "size": size}
lut[(value, size)] = 0
+ # If this item is in a known section deduct its size from
+ # the size of the section
+ if ndx in section:
+ sym[section[ndx]["name"]]["size"] -= size
for addr, sz in iter(alias.keys()):
# If the non-GLOBAL sym has an implementation elsewhere then
# it's an alias, disregard it.
@@ -66,13 +78,6 @@ def getsizes(file):
# If this non-GLOBAL sym does not have an implementation at
# another address, then treat it as a normal symbol.
sym[alias[(addr, sz)]["name"]] = {"addr" : addr, "size": sz}
- for l in os.popen("readelf -W -S " + file).readlines():
- x = l.split()
- if len(x)<6: continue
- # Should take these into account too!
- #if x[1] not in [".text", ".rodata", ".symtab", ".strtab"]: continue
- if x[1] not in [".rodata"]: continue
- sym[x[1]] = {"addr" : int(x[3], 16), "size" : int(x[5], 16)}
return sym
if flag_timing:
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 55cdd78c1..cf912e0fb 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -1,10 +1,11 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
+# SPDX-License-Identifier: GPL-2.0
# Stolen from Linux kernel :)
# Check the stack usage of functions
#
-# Copyright Joern Engel <joern@wh.fh-wedel.de>
+# Copyright Joern Engel <joern@lazybastard.org>
# Inspired by Linus Torvalds
# Original idea maybe from Keith Owens
# s390 port and big speedup by Arnd Bergmann <arnd@bergmann-dalldorf.de>
@@ -14,40 +15,57 @@
# sh64 port by Paul Mundt
# Random bits by Matt Mackall <mpm@selenic.com>
# M68k port by Geert Uytterhoeven and Andreas Schwab
+# blackfin port by Alex Landau
+# AArch64, PARISC ports by Kyle McMartin
+# sparc port by Martin Habets <errandir_news@mph.eclipse.co.uk>
+# ppc64le port by Breno Leitao <leitao@debian.org>
#
# Usage:
-# objdump -d vmlinux | checkstack.pl [arch]
+# objdump -d vmlinux | scripts/checkstack.pl [arch]
#
# TODO : Port to all architectures (one regex per arch)
+use strict;
+
# check for arch
#
# $re is used for two matches:
# $& (whole re) matches the complete objdump line with the stack growth
# $1 (first bracket) matches the size of the stack growth
#
+# $dre is similar, but for dynamic stack reductions:
+# $& (whole re) matches the complete objdump line with the stack growth
+# $1 (first bracket) matches the dynamic amount of the stack growth
+#
# use anything else and feel the pain ;)
-my (@stack, $re, $x, $xs);
+my (@stack, $re, $dre, $x, $xs, $funcre);
{
my $arch = shift;
if ($arch eq "") {
$arch = `uname -m`;
+ chomp($arch);
}
$x = "[0-9a-f]"; # hex character
$xs = "[0-9a-f ]"; # hex character or space
- if ($arch eq 'arm') {
+ $funcre = qr/^$x* <(.*)>:$/;
+ if ($arch eq 'aarch64') {
+ #ffffffc0006325cc: a9bb7bfd stp x29, x30, [sp, #-80]!
+ #a110: d11643ff sub sp, sp, #0x590
+ $re = qr/^.*stp.*sp, \#-([0-9]{1,8})\]\!/o;
+ $dre = qr/^.*sub.*sp, sp, #(0x$x{1,8})/o;
+ } elsif ($arch eq 'arm') {
#c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64
$re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;
+ } elsif ($arch =~ /^x86(_64)?$/ || $arch =~ /^i[3456]86$/) {
+ #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp
+ # or
+ # 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp
+ $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%(e|r)sp$/o;
+ $dre = qr/^.*[as][du][db] (%.*),\%(e|r)sp$/o;
} elsif ($arch eq 'blackfin') {
# 52: 00 e8 03 00 LINK 0xc;
- $re = qr/.*LINK (0x$x{1,5});$/o;
- } elsif ($arch =~ /^i[3456]86$/) {
- #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp
- $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o;
- } elsif ($arch eq 'x86_64') {
- # 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp
- $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%rsp$/o;
+ $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o;
} elsif ($arch eq 'ia64') {
#e0000000044011fc: 01 0f fc 8c adds r12=-384,r12
$re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;
@@ -61,42 +79,43 @@ my (@stack, $re, $x, $xs);
} elsif ($arch eq 'mips') {
#88003254: 27bdffe0 addiu sp,sp,-32
$re = qr/.*addiu.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
- } elsif ($arch eq 'ppc') {
- #c00029f4: 94 21 ff 30 stwu r1,-208(r1)
- $re = qr/.*stwu.*r1,-($x{1,8})\(r1\)/o;
- } elsif ($arch eq 'ppc64') {
- #XXX
- $re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o;
- } elsif ($arch eq 'powerpc') {
+ } elsif ($arch eq 'nios2') {
+ #25a8: defffb04 addi sp,sp,-20
+ $re = qr/.*addi.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+ } elsif ($arch eq 'openrisc') {
+ # c000043c: 9c 21 fe f0 l.addi r1,r1,-272
+ $re = qr/.*l\.addi.*r1,r1,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+ } elsif ($arch eq 'parisc' || $arch eq 'parisc64') {
+ $re = qr/.*ldo ($x{1,8})\(sp\),sp/o;
+ } elsif ($arch eq 'powerpc' || $arch =~ /^ppc(64)?(le)?$/ ) {
+ # powerpc : 94 21 ff 30 stwu r1,-208(r1)
+ # ppc64(le) : 81 ff 21 f8 stdu r1,-128(r1)
$re = qr/.*st[dw]u.*r1,-($x{1,8})\(r1\)/o;
} elsif ($arch =~ /^s390x?$/) {
# 11160: a7 fb ff 60 aghi %r15,-160
- $re = qr/.*ag?hi.*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+ # or
+ # 100092: e3 f0 ff c8 ff 71 lay %r15,-56(%r15)
+ $re = qr/.*(?:lay|ag?hi).*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})
+ (?:\(\%r15\))?$/ox;
} elsif ($arch =~ /^sh64$/) {
#XXX: we only check for the immediate case presently,
# though we will want to check for the movi/sub
# pair for larger users. -- PFM.
#a00048e0: d4fc40f0 addi.l r15,-240,r15
$re = qr/.*addi\.l.*r15,-(([0-9]{2}|[3-9])[0-9]{2}),r15/o;
+ } elsif ($arch eq 'sparc' || $arch eq 'sparc64') {
+ # f0019d10: 9d e3 bf 90 save %sp, -112, %sp
+ $re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o;
} else {
- print("wrong or unknown architecture\n");
+ print("wrong or unknown architecture \"$arch\"\n");
exit
}
}
-sub bysize($) {
- my ($asize, $bsize);
- ($asize = $a) =~ s/.*: *(.*)$/$1/;
- ($bsize = $b) =~ s/.*: *(.*)$/$1/;
- $bsize <=> $asize
-}
-
#
# main()
#
-my $funcre = qr/^$x* <(.*)>:$/;
-my $func;
-my $file, $lastslash;
+my ($func, $file, $lastslash);
while (my $line = <STDIN>) {
if ($line =~ m/$funcre/) {
@@ -136,6 +155,31 @@ while (my $line = <STDIN>) {
next if ($size < 100);
push @stack, "$intro$size\n";
}
+ elsif (defined $dre && $line =~ m/$dre/) {
+ my $size = "Dynamic ($1)";
+
+ next if $line !~ m/^($xs*)/;
+ my $addr = $1;
+ $addr =~ s/ /0/g;
+ $addr = "0x$addr";
+
+ #bbox: was: my $intro = "$addr $func [$file]:";
+ my $intro = "$func [$file]:";
+ my $padlen = 56 - length($intro);
+ while ($padlen > 0) {
+ $intro .= ' ';
+ $padlen -= 8;
+ }
+ push @stack, "$intro$size\n";
+ }
+}
+
+sub bysize($) {
+ my ($asize, $bsize);
+ ($asize = $a) =~ s/.*: *(.*)$/$1/;
+ ($bsize = $b) =~ s/.*: *(.*)$/$1/;
+ $bsize <=> $asize
}
-print sort bysize @stack;
+# Sort output by size (last field)
+print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack;
diff --git a/scripts/echo.c b/scripts/echo.c
index 8c6b409d3..7474ccdd4 100644
--- a/scripts/echo.c
+++ b/scripts/echo.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
#include <limits.h>
+#include <unistd.h>
#define WANT_HEX_ESCAPES 1
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
index 34510804f..0eb27c7a6 100755
--- a/scripts/gcc-version.sh
+++ b/scripts/gcc-version.sh
@@ -7,6 +7,6 @@
#
compiler="$*"
-
-MAJ_MIN=$(echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
+# tr -d '\r': fix up msdos-style line endings (Cygwin et al)
+MAJ_MIN=$(echo __GNUC__ __GNUC_MINOR__ | $compiler -E -xc - | tr -d '\r' | tail -n 1)
printf '%02d%02d\n' $MAJ_MIN
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index 92de681ac..8b5b15a1b 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -4,6 +4,8 @@
# but users complain that many sed implementations
# are misinterpreting --.
+export LC_ALL=C
+
test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
# cd to objtree
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 57734b590..39ec1cdb6 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -44,7 +44,7 @@ static void strip(char *str)
char *p = str;
int l;
- while ((isspace(*p)))
+ while ((isspace((unsigned char)*p)))
p++;
l = strlen(p);
if (p != str)
@@ -52,7 +52,7 @@ static void strip(char *str)
if (!l)
return;
p = str + l - 1;
- while ((isspace(*p)))
+ while ((isspace((unsigned char)*p)))
*p-- = 0;
}
@@ -142,7 +142,8 @@ static void conf_askvalue(struct symbol *sym, const char *def)
check_stdin();
case ask_all:
fflush(stdout);
- fgets(line, 128, stdin);
+ if (!fgets(line, 128, stdin))
+ exit(1);
return;
case set_default:
printf("%s\n", def);
@@ -390,7 +391,8 @@ static int conf_choice(struct menu *menu)
check_stdin();
case ask_all:
fflush(stdout);
- fgets(line, 128, stdin);
+ if (!fgets(line, 128, stdin))
+ exit(1);
strip(line);
if (line[0] == '?') {
printf("\n%s\n", menu->sym->help ?
@@ -399,7 +401,7 @@ static int conf_choice(struct menu *menu)
}
if (!line[0])
cnt = def;
- else if (isdigit(line[0]))
+ else if (isdigit((unsigned char)line[0]))
cnt = atoi(line);
else
continue;
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index b05b96e45..249a3195e 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -54,7 +54,7 @@ static char *conf_expand_value(const char *in)
strncat(res_value, in, src - in);
src++;
dst = name;
- while (isalnum(*src) || *src == '_')
+ while (isalnum((unsigned char)*src) || *src == '_')
*dst++ = *src++;
*dst = 0;
sym = sym_lookup(name, 0);
@@ -342,6 +342,8 @@ int conf_write(const char *name)
time_t now;
int use_timestamp = 1;
char *env;
+ char *source_date_epoch;
+ struct tm *build_time;
dirname[0] = 0;
if (name && name[0]) {
@@ -378,7 +380,16 @@ int conf_write(const char *name)
}
sym = sym_lookup("KERNELVERSION", 0);
sym_calc_value(sym);
- time(&now);
+
+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch && *source_date_epoch) {
+ now = strtoull(source_date_epoch, NULL, 10);
+ build_time = gmtime(&now);
+ } else {
+ time(&now);
+ build_time = localtime(&now);
+ }
+
env = getenv("KCONFIG_NOTIMESTAMP");
if (env && *env)
use_timestamp = 0;
@@ -398,14 +409,14 @@ int conf_write(const char *name)
if (use_timestamp) {
size_t ret = \
strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP "
- "\"%Y-%m-%d %H:%M:%S %Z\"\n", localtime(&now));
+ "\"%Y-%m-%d %H:%M:%S %Z\"\n", build_time);
/* if user has Factory timezone or some other odd install, the
* %Z above will overflow the string leaving us with undefined
* results ... so let's try again without the timezone.
*/
if (ret == 0)
strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP "
- "\"%Y-%m-%d %H:%M:%S\"\n", localtime(&now));
+ "\"%Y-%m-%d %H:%M:%S\"\n", build_time);
} else { /* bbox */
strcpy(buf, "#define AUTOCONF_TIMESTAMP \"\"\n");
}
diff --git a/scripts/kconfig/lxdialog/lxdialog.c b/scripts/kconfig/lxdialog/lxdialog.c
index 79f6c5fb5..5b8e3e947 100644
--- a/scripts/kconfig/lxdialog/lxdialog.c
+++ b/scripts/kconfig/lxdialog/lxdialog.c
@@ -189,7 +189,7 @@ int j_inputbox(const char *t, int ac, const char *const *av)
int ret = dialog_inputbox(t, av[2], atoi(av[3]), atoi(av[4]),
ac == 6 ? av[5] : (char *)NULL);
if (ret == 0)
- fprintf(stderr, dialog_input_result);
+ fprintf(stderr, "%s", dialog_input_result);
return ret;
}
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index adba1141b..aaf82820e 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -482,7 +482,8 @@ static int exec_conf(void)
*argptr++ = NULL;
- pipe(pipefd);
+ if (pipe(pipefd))
+ _exit(EXIT_FAILURE);
pid = fork();
if (pid == 0) {
sigprocmask(SIG_SETMASK, &osset, NULL);
@@ -770,7 +771,7 @@ static void conf(struct menu *menu)
if (!type)
continue;
- for (i = 0; input_buf[i] && !isspace(input_buf[i]); i++)
+ for (i = 0; input_buf[i] && !isspace((unsigned char)input_buf[i]); i++)
;
if (i >= sizeof(active_entry))
i = sizeof(active_entry) - 1;
@@ -846,9 +847,11 @@ static void conf(struct menu *menu)
static void show_textbox(const char *title, const char *text, int r, int c)
{
int fd;
+ int len = strlen(text);
fd = creat(".help.tmp", 0777);
- write(fd, text, strlen(text));
+ if (write(fd, text, len) != len)
+ exit(1);
close(fd);
show_file(".help.tmp", title, r, c);
unlink(".help.tmp");
diff --git a/scripts/randomtest b/scripts/randomtest
index 94709a99f..f6e0c9d8c 100755
--- a/scripts/randomtest
+++ b/scripts/randomtest
@@ -83,7 +83,6 @@ if test x"$LIBC" = x"uclibc"; then
\
| grep -v CONFIG_FEATURE_2_4_MODULES \
| grep -v CONFIG_FEATURE_SYNC_FANCY \
- | grep -v CONFIG_FEATURE_TOUCH_NODEREF \
| grep -v CONFIG_NANDWRITE \
| grep -v CONFIG_NANDDUMP \
| grep -v CONFIG_BLKDISCARD \
@@ -100,7 +99,6 @@ if test x"$LIBC" = x"uclibc"; then
echo '# CONFIG_PIE is not set' >>.config
echo '# CONFIG_FEATURE_2_4_MODULES is not set' >>.config
echo '# CONFIG_FEATURE_SYNC_FANCY is not set' >>.config
- echo '# CONFIG_FEATURE_TOUCH_NODEREF is not set' >>.config
# My uclibc installation does not support some needed APIs...
echo '# CONFIG_NANDWRITE is not set' >>.config
echo '# CONFIG_NANDDUMP is not set' >>.config
@@ -113,6 +111,31 @@ if test x"$LIBC" = x"uclibc"; then
echo 'CONFIG_ASH_INTERNAL_GLOB=y' >>.config
fi
+# If musl
+if test x"$LIBC" = x"musl"; then
+ cat .config \
+ | grep -v CONFIG_STATIC \
+ | grep -v CONFIG_DEBUG_SANITIZE \
+ | grep -v CONFIG_LFS \
+ | grep -v CONFIG_EXTRA_COMPAT \
+ | grep -v CONFIG_FEATURE_2_4_MODULES \
+ | grep -v CONFIG_FEATURE_VI_REGEX_SEARCH \
+ | grep -v CONFIG_FEATURE_MOUNT_NFS \
+ | grep -v CONFIG_FEATURE_INETD_RPC \
+ >.config.new
+ mv .config.new .config
+ echo 'CONFIG_STATIC=y' >>.config
+ # "error: cannot specify -static with -fsanitize=address":
+ echo '# CONFIG_DEBUG_SANITIZE is not set' >>.config
+ # with LFS off, uoff_t will have wrong width:
+ echo 'CONFIG_LFS=y' >>.config
+ echo '# CONFIG_EXTRA_COMPAT is not set' >>.config
+ echo '# CONFIG_FEATURE_2_4_MODULES is not set' >>.config
+ echo '# CONFIG_FEATURE_VI_REGEX_SEARCH is not set' >>.config
+ echo '# CONFIG_FEATURE_MOUNT_NFS is not set' >>.config
+ echo '# CONFIG_FEATURE_INETD_RPC is not set' >>.config
+fi
+
# If STATIC, remove some things.
# PAM with static linking is probably pointless
# (but I need to try - now I don't have libpam.a on my system, only libpam.so)
diff --git a/scripts/randomtest.loop b/scripts/randomtest.loop
index edfbc5c58..c6d2cdcda 100755
--- a/scripts/randomtest.loop
+++ b/scripts/randomtest.loop
@@ -6,13 +6,18 @@ run_testsuite=true
run_single_test=false
run_single_test=true
-test -d "$1" || { echo "'$1' is not a directory"; exit 1; }
-test -x "$1/scripts/randomtest" || { echo "No scripts/randomtest in '$1'"; exit 1; }
-
export LIBC="uclibc"
export CROSS_COMPILER_PREFIX="i686-"
export MAKEOPTS="-j9"
+test -d "$1" || { echo "'$1' is not a directory"; exit 1; }
+test -x "$1/scripts/randomtest" || { echo "No scripts/randomtest in '$1'"; exit 1; }
+
+test "$SKIP_MOUNT_MAND_TESTS" = "1" || {
+ echo "SKIP_MOUNT_MAND_TESTS not set, some mount tests will fail"
+ echo "if current kernel has CONFIG_MANDATORY_FILE_LOCKING off."
+}
+
cnt=0
fail=0
while sleep 1; do
diff --git a/scripts/trylink b/scripts/trylink
index bb6b2de2f..2255deee7 100755
--- a/scripts/trylink
+++ b/scripts/trylink
@@ -1,5 +1,6 @@
#!/bin/sh
+#debug=true
debug=false
# Linker flags used:
@@ -50,9 +51,6 @@ check_cc() {
echo "int main(int argc,char**argv){return argv?argc:0;}" >"$tempname".c
# Can use "-o /dev/null", but older gcc tend to *unlink it* on failure! :(
# Was using "-xc /dev/null", but we need a valid C program.
- # "eval" may be needed if CFLAGS can contain
- # '... -D"BB_VER=KBUILD_STR(1.N.M)" ...'
- # and we need shell to process quotes!
$CC $CFLAGS $LDFLAGS $1 "$tempname".c -o "$tempname" >/dev/null 2>&1
exitcode=$?
rm -f "$tempname" "$tempname".c "$tempname".o
@@ -80,7 +78,13 @@ CFLAGS="$3"
LDFLAGS="$4"
O_FILES="$5"
A_FILES="$6"
+# We try to drop libraries from LDLIBS if build works without them,
+# but ones from CONFIG_EXTRA_LDLIBS are always linked in.
+# (For example, musl has stub utmp implementation, and if you link with
+# a real utmp library in LDLIBS, dropping it "works" but resulting binary
+# does not work properly).
LDLIBS="$7"
+CONFIG_EXTRA_LDLIBS="$8"
# The --sort-section option is not supported by older versions of ld
SORT_SECTION="-Wl,--sort-section,alignment"
@@ -128,8 +132,8 @@ LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs`
# First link with all libs. If it fails, bail out
echo "Trying libraries: $LDLIBS"
# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
-l_list=`echo " $LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g'`
-test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP"
+l_list=`echo " $LDLIBS $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'`
+test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP"
try $CC $CFLAGS $LDFLAGS \
-o $EXE \
$SORT_COMMON \
@@ -154,7 +158,7 @@ while test "$LDLIBS"; do
for one in $LDLIBS; do
without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs`
# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
- l_list=`echo " $without_one " | sed -e 's: \([^- ][^ ]*\): -l\1:g'`
+ l_list=`echo " $without_one $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'`
test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP"
$debug && echo "Trying -l options: '$l_list'"
try $CC $CFLAGS $LDFLAGS \
@@ -182,8 +186,8 @@ done
# Make the binary with final, minimal list of libs
echo "Final link with: ${LDLIBS:-<none>}"
-l_list=`echo " $LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g'`
-test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP"
+l_list=`echo " $LDLIBS $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'`
+test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP"
# --verbose gives us gobs of info to stdout (e.g. linker script used)
if ! test -f busybox_ldscript; then
try $CC $CFLAGS $LDFLAGS \