0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 D=tools/testing/selftests/rcutorture
0011
0012
0013 [ -z "$D" ] && echo >&2 "No argument supplied" && exit 1
0014 if [ ! -d "$D" ]; then
0015 echo >&2 "$D does not exist: Malformed kernel source tree?"
0016 exit 1
0017 fi
0018 if [ -s "$D/initrd/init" ]; then
0019 echo "$D/initrd/init already exists, no need to create it"
0020 exit 0
0021 fi
0022
0023
0024
0025 echo "Creating a statically linked C-language initrd"
0026 cd $D
0027 mkdir -p initrd
0028 cd initrd
0029 cat > init.c << '___EOF___'
0030
0031
0032
0033
0034
0035 volatile unsigned long delaycount;
0036
0037 int main(int argc, int argv[])
0038 {
0039 int i;
0040 struct timeval tv;
0041 struct timeval tvb;
0042
0043 for (;;) {
0044 sleep(1);
0045 /* Need some userspace time. */
0046 if (gettimeofday(&tvb, NULL))
0047 continue;
0048 do {
0049 for (i = 0; i < 1000 * 100; i++)
0050 delaycount = i * i;
0051 if (gettimeofday(&tv, NULL))
0052 break;
0053 tv.tv_sec -= tvb.tv_sec;
0054 if (tv.tv_sec > 1)
0055 break;
0056 tv.tv_usec += tv.tv_sec * 1000 * 1000;
0057 tv.tv_usec -= tvb.tv_usec;
0058 } while (tv.tv_usec < 1000);
0059 }
0060 return 0;
0061 }
0062 ___EOF___
0063
0064
0065
0066 if echo -e "#if __x86_64__||__i386__||__i486__||__i586__||__i686__" \
0067 "||__ARM_EABI__||__aarch64__\nyes\n#endif" \
0068 | ${CROSS_COMPILE}gcc -E -nostdlib -xc - \
0069 | grep -q '^yes'; then
0070
0071 ${CROSS_COMPILE}gcc -fno-asynchronous-unwind-tables -fno-ident \
0072 -nostdlib -include ../../../../include/nolibc/nolibc.h \
0073 -s -static -Os -o init init.c -lgcc
0074 else
0075 ${CROSS_COMPILE}gcc -s -static -Os -o init init.c
0076 fi
0077
0078 rm init.c
0079 echo "Done creating a statically linked C-language initrd"
0080
0081 exit 0