I am trying to learn linux kernel from the scratch. I have downloaded the linux kernel 2.6.20. It is compiled fine on gcc 4.4.4. I am learning the linux kernel with the help of QEMU emulator. I am giving this information so that if any one is learning the linux kernel but don't know how to start. QEMU is the best way to learn it. You will find about it more on internet. My real intention was to build old linux kernel for i386 processor. Because as linux kernel is the fastest growing kernel so it is very difficult to understand the newer linux kernel until you know the basics of it. I chose the older kernel linux-2.2.26. To do so download 1) linux-2.2.26.tar.gz 2) binutils-2.10.0.18-1.i386.rpm 3) gcc-2.95-1.i386.rpm. You can found it on internet from the redhat website. GCC 2.95 can be found at
http://rpm.pbone.net/index.php3/stat....i386.rpm.html. Please do not install directly any RPM.. Just extract this RPMs in any temporary directory. Then copy this binaries manually. Here I am showing my example. Below image shows how I extracted them in local directory(Say $extract_dir: In my case it is $extract_dir=/home/ravidborse/Downloads/Red-Hat-7.0/gcc). Now we have to copy this directory structure as it is shown in figure.
Do not copy other utilities until you use them. Do not copy $extract_dir/usr/bin/gcc as it will replace your system's gcc. Here I giving my example
Code:
cp $extract_dir/usr/bin/i386-redhat-linux-gcc /usr/bin
cp -r $extract_dir/usr/lib/gcc-lib/i386-redhat-linux/2.96/ /usr/lib/gcc-lib/i386-redhat-linux/
Now Enter in the linux-2.2.26 directory. Make changes in Makefile as shown in figure. I have commented the commands and changes to my own binutils. As shown in figure.
Then
Code:
make menuconfig
make
You will get errors. as shown
Code:
i386-redhat-linux-gcc -D__KERNEL__ -I/home/ravidborse/Downloads/Red-Hat-7.0/linux-2.2.26/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing -pipe -fno-strength-reduce -m386 -DCPU=386 -c -o process.o process.c
{standard input}: Assembler messages:
{standard input}:343: Warning: using `%eax' instead of `%ax' due to `l' suffix
{standard input}:344: Warning: using `%eax' instead of `%ax' due to `l' suffix
{standard input}:345: Warning: using `%eax' instead of `%ax' due to `l' suffix
{standard input}:346: Warning: using `%eax' instead of `%ax' due to `l' suffix
{standard input}:347: Warning: using `%eax' instead of `%ax' due to `l' suffix
{standard input}:612: Warning: using `%eax' instead of `%ax' due to `l' suffix
{standard input}:612: Warning: using `%eax' instead of `%ax' due to `l' suffix
{standard input}:820: Error: suffix or operands invalid for `mov'
{standard input}:821: Error: suffix or operands invalid for `mov'
{standard input}:976: Error: suffix or operands invalid for `mov'
{standard input}:977: Error: suffix or operands invalid for `mov'
{standard input}:1035: Error: suffix or operands invalid for `mov'
{standard input}:1036: Error: suffix or operands invalid for `mov'
{standard input}:1056: Error: suffix or operands invalid for `mov'
{standard input}:1068: Error: suffix or operands invalid for `mov'
To resolve this you have to check your assembler.
Code:
[root@localhost linux-2.2.26]# /usr/bin/as --version
GNU assembler version 2.20.51.0.2-15.fc13 20091009
Copyright 2009 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `i686-redhat-linux'.
Now you to change your assembler from i686-redhat-linux to i386-redhat-linux
Code:
cp /usr/bin/as /usr/bin/as-old
cp /home/ravidborse/Downloads/Red-Hat-7.0/binutils/usr/bin/as /usr/src/as
Now check your assembler version
Code:
[root@localhost linux-2.2.26]# /usr/bin/as --version
GNU assembler 2.10.90
Copyright 2000 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
This assembler was configured for a target of `i386-redhat-linux'.
Now compile your 2.2.26 again using
Your kernel should compile properly.
Please Check the Figures attached with this post.