To establish this toolchain, we should do the following steps.
1. Source tool and source code:
1)
Binutils-2.14.tar.gz
The GNU binutils are a collection of binary tools. The main ones are:
Ld: the GNU linker.
As: the GNU assembler.
But they also include:
Addr2line: converts addresses into filenames and line numbers.
Ar: a utility for creating, modifying and extracting from archives.
C++filt: filter to demangle encoded C++ symbols.
Nlmconv: converts object code into an NLM.
Nm: lists symbols from object files.
Objcopy: copies and translates object files.
Objdump: displays information from object files.
Ranlib: generates an index to the contents of an archive.
Readelf: displays information from any ELF format object file.
Size: lists the section sizes of an object or archive file.
Strings: lists printable strings from files.
Strip: discards symbols.
Windres: a complier for windows resource files,
2)
Gcc-core-2.95.3.tar.gz
Gcc-core only contains the C complier. If you want other languages you can download the sources separately or you can use the
full gcc sources.
3)
Gcc-g++2.95.3.tar.gz
It suffices for C++ language.
4)
Glibc-2.2.4.tar.gz
The GNU C library is used as the C library in the GNU system and most systems with the Linux kernel.
5)
Glibc-linuxthreads-2.2.4.tar.gz
The GNU C library to support the Posix thread.
6)
Linux-2.4.21.tar.gz
Linux kernel.
7)
Patch-2.4.21-rmk1.gz
Linux kernel patch for ARM platform.
2. Procedure steps
1)
Creating working directory tree
Mkdir arm // the top directory, all works will be finished here.
Mkdir tool-chain //tools directory, complier, linker and C library compiled will store at its subdirectory bin.
Mkdir build-dir //to compile tools source code, binutils, gcc and glibc for example.
Mkdir src-dir // to store source code that decompressed from binutils, gcc and glibc.
Mkdir setup-dir // to store compressed files.
Mkdir kernel // to store all Linux kernel source code, kernel configuration and compiling will be processed here.
2)
Decompress tools source files and store them into directory src-dir.
Cd ./src-dir
Tar -xvzf ../setup-dir/ binutils-2.14.tar.gz
Tar -xvzf ../set-dir/ gcc-core-2.95.3.tar.gz
Tar -xvzf ../setup-dir/ glibc-2.2.4.tar.gz
Tar -xvzf ../setup-dir/ glibc-linuxthreads-2.2.4.tar.gz -directory=./glibc-2.2.4
3)
Create three compiling directory that correspond to tools, the compiling, configuration of tools will be finished here.
Cd ../build-dir
Mkdir ../build-dir/build-binutils
Mkdir ../build-dir/build-gcc
Mkdir ../build-dir/build-glibc
4)
Decompress kernel into kernel directory and patch for ARM.
Cd ../kernel
Tar -xvzf ../setup-dir/ linux-2.4.21.tar.gz
Cd ./linux-2.4.21
Patch -p1 < ../../setup-dir/ patch-2.4.21-rmk1
2. building
1)
Setting system variables
Cd ../../
Export TARGET=arm-linux // target
Export PREFIX=../arm/tool-chain //tool chain setup directory
Export TARGET_PREFIX=$PREFIX/$TARGET
Export KERNEL_SOURCE_LOCATION=../arm/kernel/linux-2.4.21 // kernel location
Export PATH=$PREFIX/bin:$PATH
2)
Building binutils, some tools will be created at $PREFIX/bin, arm-linux-ld and arm-linux-as for example.
Cd ./build-dir/build-binutils
Configure ../../src-dir/binutils-2.14/configure -target=$TARGET -prefix=$PREFIX
Make
Make install
3)
Kernel compiling
Cd ../../kernel/linux-2.4.21
modify Makefile and make sure ARCH = arm, CROSS_COMPILE = arm-linux-
make menuconfig
make dep // it is different with Linux 2.6
mkdir $TARGET_PREFIX/include
cp dR $KERNEL_SOURECE_LOCATION/include/arm-asm $TARGET_PREFIX/include/asm
cp dR $KERNEL_SOURCE_LOCATION/include/linux $TARGET_PREFIX/include/linux
4)
Creating boot-trap gcc. It is used for creating C lib. Arm-linux-gcc will be created at $PREFIX/bin.
Cd ../../build-dir/build-gcc
Configure ../../src-dir/gcc-2.95.3/configure -target=$TARGET -prefix=$PREFIX -with-headers=$KERNEL_SOURCE_LOCATION/
include -enable-language=c -disable-threads
Modify the file src-dir/gcc-2.95.3/gcc/config/arm/t-linux, add two defines, -Dinhibit-libc and -D__gthr-posix-h, under
TARGET_LIBGCC2_CFLAGS.
Make
Make install
5)
Building glibc
Cd ..//build-glibc
Export CC=arm-linux-gcc
Configure ../../src-dir/glibc-2.2.4/configure -host=$TARGET -prefix=$TARGET_PREFIX -enable-add-ons
Make
Make install
6)
Building all GCC and G++
Cd ../../src-dir
Tar -xvzf ../setup-dir/ gcc-g++2.95.3.tar.gz
Cd ../build-dir/build-gcc
Export CC=gcc
Configure ../../src-dir/gcc-2.95.3/confirgure -target=$TARGET -prefix=$PREFIX -enable-language=c,c++
Modfigy the file src-dir/gcc-2.95.3/gcc/arm/t-linux, delete two defines, -Dinhibit-libc and -D__gthr-posix-h, under
TARGET_LIBGCC2_CFLAGS.
Make
Make install
Now I have built the arm-linux cross-compiler environment successfully.

