hi3519a 移植gbd


原文链接: hi3519a 移植gbd
  1. 下载源码

编译环境

一、下载GDB压缩包 gdb-8.3.tar.gz
aria2c -x 16 -c http://ftp.gnu.org/gnu/gdb/gdb-9.2.tar.xz
tar -xf gdb-9.2.tar.xz

二、解压压缩包

tar xvf gdb-8.3.tar.gz

三、配置编译器

进入到GDB的文件目录,然后执行

./configure --host=arm-himix200-linux --program-prefix=arm-hisi- --prefix=`pwd`/output

四、修改文件

由于海思提供的交叉编译工具的版本比较旧,在编译的时候回出现一些错误

     1、dwarf-index-write.c的错误

CXX dwarf-index-write.o
dwarf-index-write.c: In member function 'void debug_names::build()':
dwarf-index-write.c:704:32: error: 'log2' is not a member of 'std'

   (std::pow (2, std::ceil (std::log2 (name_count * 4 / 3))));
                            ^~~

dwarf-index-write.c:704:32: note: suggested alternative:
In file included from /opt/toolchain/arm-himix100-linux/target/usr/include/features.h:416:0,

             from /opt/toolchain/arm-himix100-linux/target/usr/include/stdio.h:28,
             from build-gnulib/import/stdio.h:43,
             from common/common-defs.h:76,
             from defs.h:28,
             from dwarf-index-write.c:20:

/opt/toolchain/arm-himix100-linux/target/usr/include/bits/mathcalls.h:158:1: note: 'log2'
__MATHCALL (log2,, (Mdouble __x))
^
make[2]: *** [dwarf-index-write.o] Error 1
make[2]: Leaving directory /opt/hisi-linux/GDB/gdb-8.3/gdb' make[1]: *** [all-gdb] Error 2 make[1]: Leaving directory/opt/hisi-linux/GDB/gdb-8.3'
make: *** [all] Error 2
   解决方法:使用log函数替换log2方法

将dwarf-index-write.c

m_bucket_table.resize
  (std::pow (2, std::ceil (std::log2 (name_count * 4 / 3))));

使用log函数替换log2方法

m_bucket_table.resize
  (std::pow (2, std::ceil (std::log(name_count * 4 / 3) / std::log((float)2.0))));

  

   2、undefined reference to `_obstack_free' 错误

   解决方法:使用宏定义使用_obstack_free函数替换obstack_free

在obstack.h中增加定义
#ifndef obstack_free
#define _obstack_free obstack_free
#endif

五、编译、安装

make && make install

六、生成编译文件

在GDB的目录下会有一个Output目录,下面就是我们编译出来的文件。

`