1 任务:移植gdb到arm-linux
gdb版本:gdb-7.12.tar.gz
termcap版本:termcap-1.3.1.tar.gz
交叉编译工具链:arm-hisiv500-linux
2 termcap移植
cd termcap-1.3.1/
./configure --host=arm-linux --prefix=$(pwd)/../termapinstall --without-ada --enable-termcap --with-shared
注意:虽然执行了上述configure命令,但是仔细一点便会发现termcap-1.-3.1的Makefile中的gcc没有改变,因此需要手动更改Makefile中的编译器。
vim Makefile
#.............
# 在gcc前添加对应交叉工具链名
CC = arm-hisiv500-linux-gcc
AR = arm-hisiv500-linux-ar
RANLIB = arm-hisiv500-linux-ranlib
#..........
更改完Makefile之后,用root用户执行命令
make
make install
3 gdb移植
cd gdb-7.12/
./configure --host=arm-hisiv500-linux --enable-shared --prefix=$(pwd)/../gdbinstall --without-x --disable-gdbtk --disable-tui --without-included-regex --without-included-gettext LDFLAGS="-L$(pwd)/../termapinstall/lib" CPPFLAGS="-I$(pwd)/../termapinstall/include"
make
配置完后,执行make命令,会出现如下错误:
/home/gdb-7.12/gdb/c-exp.y:2381:对‘_obstack_free’未定义的引用
c-exp.o:在函数‘parse_string_or_char’中:
/home/gdb-7.12/gdb/c-exp.y:2127:对‘_obstack_free’未定义的引用
c-exp.o:在函数‘c_yylex’中:
/home/gdb-7.12/gdb/c-exp.y:3071:对‘_obstack_free’未定义的引用
ada-exp.o:在函数‘ada_parse(parser_state*)’中:
/home/gdb-7.12/gdb/ada-exp.y:745:对‘_obstack_free’未定义的引用
d-exp.o:在函数‘parse_string_or_char’中:
/home/gdb-7.12/gdb/d-exp.y:906:对‘_obstack_free’未定义的引用
d-exp.o:/home//gdb-7.12/gdb/d-exp.y:1538: 跟着更多未定义的参考到 _obstack_free
上述所报错误是说,编译器没有找到_obstack_free()这个函数,属于为定义引用。然后我到/usr/include/目录下搜索_obstack_free()该函数,发现存在一个obstack_free(),但不是_obstack_free()函数。
然后我又去了交叉编译工具链中查找obstack_free()函数,发现没有obstack_free()而有_obstack_free()。
据此,猜测是gdb版本问题,然后我进入了gdb-7.12/include目录,将obstack.h头文件出现的_obstack_free()全部改为obstack_free()函数。然后执行命令:
make
make install
顺利编译完成。
最后编译出来的gdb文件有25M之大,应该是里面含有一些符号表吧。于是我对gdb可执行文件strip一下,最后gdb程序大小在4M
arm-hisiv500-linux-strip ./gdb -o armgdb
最后将armgdb拷贝到开发板,可以运行。
over!