Gdb / buildroot 交叉编译。
使用buildroot 编译低版本的mips gdb 的时候,gdb源码需要手动打补丁,主要是uClibc库的问题。
链接:
https://git.busybox.net/uClibc/commit/?id=2da958760f798224065508431787e3a83b7fe2ae
http://uclibc.10924.n7.nabble.com/PATCH-ldso-libdl-include-dl-tls-h-for-mips-static-link-td8544.html
buildroot 在make的时候,当buildroot-2013.08.1/output/build/ 下出现选择的uClibc库的时候:uclibc-0.9.33.2,中断当前make。
然后参考上面链接,给 libdl.c ,signum.h 写上补丁代码。
1 2 3 4 5 \# if defined(USE_TLS) && USE_TLS && defined(__mips__) && !defined(SHARED) \# include <dl-tls.h> \# endif
与
然后再次进行编译。当然,buildroot版本选择要合适。2013版,才有Mips-I 的指令集。
这里我编译最低的gdb版本是 gdb7.7.1。若编译gdb.7.6 则还会出现其他错误。Gdb.7.7 是2014年的,已经够低了,没有必要在往下。
用到的一些命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 --prefix=/root/u-boot/gdb-7.8.1/include/ gdb 编译: ./configure --host=mips-buildroot-linux-uclibc --build=x86_64-redhat-linux --target=mips-buildroot-linux-uclibc CC=/home/pc/Desktop/buildroot-2014.11/output/host/usr/bin/mips-linux-gcc ./configure --target=mips-linux --host=mips-linux --program-prefix=mips-linux CC=/home/pc/Desktop/buildroot-2014.11/output/host/usr/bin/mips-linux-gcc export PATH=$PATH::/usr/local/buildroot/host/usr/bin export PATH=/home/pc/Desktop/buildroot-2014.11/output/host/usr/bin:$PATH make CFLAGS="-static" CXXFLAGS="-static" ./configure --target=mips-linux --host=mips-linux --program-prefix=mips-linux CC=/usr/local/buildroot/host/usr/bin/mips-linux-gcc CXX=/usr/local/buildroot/host/usr/bin/mips-linux-g++ make CFLAGS="-static" CXXFLAGS="-static" mips-linux-strip gdb | ls -alh gdb =========================================================================================== kali下编译,说不准root: 编译错误you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check) 解决方法: export FORCE_UNSAFE_CONFIGURE=1 =========================================================================================== export LDFLAGS="-static -L/home/pc/Desktop/termcap-1.3.1" export CPPFLAGS="-I/home/pc/Desktop/termcap-1.3.1" export PATH=$PATH::/home/pc/Desktop/buildroot-2013.11/output/host/usr/bin =========================================================================================== 交叉编译环境目录库: buildroot-2013.11/output/host/usr/mips-buildroot-linux-uclibc/sysroot/usr/lib/ =========================================================================================== http://mirrors.ustc.edu.cn/gnu/ http://mirrors.ustc.edu.cn/kernel.org/ http://mirrors.163.com/debian/ =======================================交叉编译termcap======================================= sudo ./configure CC=/home/pc/Desktop/buildroot-2016.02/output/host/usr/bin/mips-linux-gcc sudo cp libtermcap.a /home/pc/Desktop/buildroot-2016.02/output/host/usr/mips-buildroot-linux-uclibc/sysroot/usr/lib sudo cp termcap.h /home/pc/Desktop/buildroot-2016.02/output/host/usr/mips-buildroot-linux-uclibc/sysroot/usr/include/ XXXXXXX-linux-gcc --print-file-name libc.a =================================kali=================================== ./configure --target=mips-linux --host=mips-linux --program-prefix=mips-linux CC=/root/u-boot/buildroot-2019.02.4/output/host/bin/mips-linux-gcc cp libtermcap.a /root/u-boot/buildroot-2019.02.4/output/host/mips-buildroot-linux-uclibc/sysroot/usr/lib/ cp termcap.h /root/u-boot/buildroot-2019.02.4/output/host/mips-buildroot-linux-uclibc/sysroot/usr/include/ make CFLAGS="-g -O2 -static" CXXFLAGS="-g -O2 -static" export PATH=$PATH::/root/u-boot/buildroot-2019.02.4/output/host/bin export LDFLAGS="-static -L/root/u-boot/termcap-1.3.1/lib" export CPPFLAGS="-I/root/u-boot/termcap-1.3.1/include" gedit /etc/profile export PATH="/root/u-boot/buildroot-2019.02.4/output/host/bin:$PATH" source /etc/profile