原创 HOWTO build arm-linux toolchain for ARM 4.2.1

2008-8-15 09:16 4656 9 8 分类: MCU/ 嵌入式
HOWTO build arm-linux toolchain for ARM/XSCALE
----------------------------------------------

These instructions document how to build an arm-linux tool chain
that contains both little-endian and big-endian target libraries.


1. Packages used:

binutils-2.17.tar.gz
gcc-4.2.1.tar.gz
glibc-2.3.6.tar.gz
glibc-linuxthreads-2.3.6.tar.gz
elf2flt-20060708.tar.gz


2. binutils-2.17

tar xvzf binutils-2.17.tar.gz
cd binutils-2.17
mkdir arm-linux
cd arm-linux
../configure --target=arm-linux --with-lib-path=/usr/local/arm-linux/lib:/usr/local/arm-linux/lib/be:/usr/local/arm-linux/lib/soft-float:/usr/local/arm-linux/lib/be/soft-float
make
make install
chmod 777 /usr/local/arm-linux


3. gcc-4.2.1

tar xvjf gcc-4.2.1.tar.bz2
cd gcc-4.2.1

cp $(ATTACHED t-linux file) gcc/config/arm/
vi gcc/config/arm/linux-elf.h
-- remove line that defines LIBGCC_SPEC
vi gcc/config/arm/lib1funcs.asm
-- change line 999 which are:

mov r0, #SIGFPE
bl SYM(raise) __PLT__

to be:

bl SYM (__div0) __PLT__
mov r0, #0 @ About as wrong as it could be.


mkdir arm-linux
cd arm-linux
../configure --target=arm-linux --disable-shared --disable-threads \
--disable-libmudflap --disable-libssp \
--with-headers=linux-2.6.x/include \
--prefix=/usr/local --with-gnu-as --with-gnu-ld --enable-multilib \
--enable-languages=c
make
[ ignore build failure, move to next step! ]
make install


4. glibc-2.3.6 (big-endian)

tar xvzf glibc-2.3.6.tar.gz
cd glibc-2.3.6
tar xvzf glibc-linuxthreads-2.3.6.tar.gz
rm -rf nptl

vi sysdeps/unix/sysv/linux/arm/ioperm.c
- change "BUS_ISA" to be "CTL_BUS_ISA" lines 103 and 104
vi config.make.in
- change "slibdir = @...@" to "slibdir = @libdir@"
vi Makeconfig
- remove any usage occurrances of -lgcc_eh
vi sysdeps/unix/sysv/linux/bind.S
- comment out line 5 "weak_alias (bind, __bind)"
vi sysdeps/unix/sysv/linux/getsockname.S
- comment out line 5 "weak_alias (getsockname, __getsockname)"
vi sysdeps/unix/sysv/linux/listen.S
- comment out line 5 "weak_alias (listen, __listen)"
vi sysdeps/unix/sysv/linux/setsockopt.S
- comment out line 5 "weak_alias (setsockopt, __setsockopt)"
vi sysdeps/arm/dl-machine.h
- line 360, remove "static" before function fix_bad_pc24

mkdir arm-linux
cd arm-linux
CC="arm-linux-gcc -mbig-endian" \
AS="arm-linux-as -mbig-endian" \
LD="arm-linux-ld -EB" \
../configure --host=arm-linux --build=i686-pc-linux-gnu \
--with-headers=linux-2.6.x/include \
--enable-add-ons --enable-shared --prefix=/usr/local/arm-linux \
--libdir=/usr/local/arm-linux/lib/be
make
make install


5. glibc-2.3.6 (little-endian)

tar xvzf glibc-2.3.6.tar.gz
cd glibc-2.3.6
tar xvzf glibc-linuxthreads-2.3.6.tar.gz

[ Apply same fixes as above ]

mkdir arm-linux
cd arm-linux
CC="arm-linux-gcc" \
AS="arm-linux-as" \
LD="arm-linux-ld" \
../configure --host=arm-linux --build=i686-pc-linux-gnu \
--with-headers=linux-2.6.x/include \
--enable-add-ons --enable-shared --prefix=/usr/local/arm-linux
make
make install


6. glibc-2.3.6 (big-endian/soft-float)

tar xvzf glibc-2.3.6.tar.gz
cd glibc-2.3.6
tar xvzf glibc-linuxthreads-2.3.6.tar.gz

[ Apply same fixes as above ]

mkdir arm-linux
cd arm-linux
CC="arm-linux-gcc -mbig-endian -msoft-float" \
AS="arm-linux-as -mbig-endian" \
LD="arm-linux-ld -EB" \
../configure --host=arm-linux --build=i686-pc-linux-gnu \
--with-headers=linux-2.6.x/include \
--enable-add-ons --enable-shared --prefix=/usr/local/arm-linux \
--without-fp --libdir=/usr/local/arm-linux/lib/be/soft-float
make
make install


7. glibc-2.3.6 (little-endian/soft-float)

tar xvzf glibc-2.3.6.tar.gz
cd glibc-2.3.6
tar xvzf glibc-linuxthreads-2.3.6.tar.gz

[ Apply same fixes as above ]

mkdir arm-linux
cd arm-linux

CC="arm-linux-gcc -msoft-float" \
AS="arm-linux-as" \
LD="arm-linux-ld" \
../configure --host=arm-linux --build=i686-pc-linux-gnu \
--with-headers=linux-2.6.x/include \
--enable-add-ons --enable-shared --prefix=/usr/local/arm-linux \
--without-fp --libdir=/usr/local/arm-linux/lib/soft-float
make
make install


8. gcc-4.2.1 (c++, etc)

tar xvzf gcc-4.2.1.tar.gz
cd gcc-4.2.1

cp $(ATTACHED t-linux file) gcc/config/arm/
vi gcc/config/arm/t-linux
- remove all "-Dinhibit_libc" occruances
vi gcc/config/arm/linux-elf.h
-- remove line that defines LIBGCC_SPEC
vi gcc/config/arm/lib1funcs.asm
-- change line 999 which are:

mov r0, #SIGFPE
bl SYM(raise) __PLT__

to be:

bl SYM (__div0) __PLT__
mov r0, #0 @ About as wrong as it could be.

perl -pi -e 's/int namelen/unsigned int namelen/' libjava/java/net/natInetAddressPosix.cc

mkdir arm-linux
cd arm-linux
../configure --target=arm-linux --disable-shared \
--prefix=/usr/local --with-headers=linux-2.6.x/include \
--with-gnu-as --with-gnu-ld --enable-multilib
make
make install


9. elf2flt

tar xvzf elf2flt-20060708.tar.gz
./configure --target=arm-linux \
--with-libbfd=<path>/binutils-2.17/arm-linux/bfd/libbfd.a \
--with-libiberty=<path>/binutils-2.17/arm-linux/libiberty/libiberty.a \
--with-bfd-include-dir=<path>/binutils-2.17/arm-linux/bfd
make
make install


10. packaging

cd /
find /usr/local/arm-linux -name CVS -type d | xargs rm -rf
strip /usr/local/arm-linux/bin/*
strip /usr/local/bin/arm-linux-*
strip /usr/local/libexec/gcc/arm-linux/4.2.1/*
tar cvzf /tmp/arm-linux-tools-xxxxxxxx.tar.gz
/usr/local/arm-linux \
/usr/local/lib/gcc/arm-linux \
/usr/local/libexec/gcc/arm-linux \
/usr/local/bin/arm-linux-* \
/usr/local/bin/genext2fs


------------------------------------------------------------------------------

APPENDIX A -- modified t-linux for gcc-4.2.1

------------------------------------------------------------------------------
# Just for these, we omit the frame pointer since it makes such a big
# difference. It is then pointless adding debugging.
TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC -Dinhibit_libc -D__gthr_posix
LIBGCC2_DEBUG_CFLAGS = -g0

# Don't build enquire
ENQUIRE=

LIB1ASMSRC = arm/lib1funcs.asm
LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx \
_bb_init_func _call_via_rX _interwork_call_via_rX \
_negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
_truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
_fixsfsi _fixunssfsi

MULTILIB_OPTIONS = mlittle-endian/mbig-endian mhard-float/msoft-float
MULTILIB_DIRNAMES = le be hard-float soft-float

EXTRA_MULTILIB_PARTS = crtbegin.o crtbeginS.o crtend.o crtendS.o crti.o crtn.o crtbeginT.o

LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
T_CFLAGS = -Dinhibit_libc -D__gthr_posix_h

# Assemble startup files.
$(T)crti.o: $(srcdir)/config/arm/crti.asm $(GCC_PASSES)
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
-c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/arm/crti.asm

$(T)crtn.o: $(srcdir)/config/arm/crtn.asm $(GCC_PASSES)
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
-c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/arm/crtn.asm
------------------------------------------------------------------------------
PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
9
关闭 站长推荐上一条 /3 下一条