• 上一篇我有相关关于一个段错误的记录,现在记录当时的段错误具体是在哪里的。

    // 从 GNU 的官网下载当前在使用的 glibc 的源代码以及最新的 glibc 源代码
// 地址如下: http://ftp.gnu.org/gnu/libc/
// 下载的是 glibc-2.12.2.tar 以及最新的 glibc-2.25.tar 两个版本
// 这里要记住, glibc 2.12.2 这个版本是有一个bug 的, times 的参数不能传 NULL。
    //  解压  glibc-2.12.2.tar
tar -xvf glibc-2.12.2.tar.gz
cd glibc-2.12.2
vim sysdeps/unix/sysv/linux/times.c
    // 这个文件中的一段代码会导致程序调用了 times 运行一段时间后会产生段错误
clock_t
__times (struct tms *buf)
{
INTERNAL_SYSCALL_DECL (err);
clock_t ret = INTERNAL_SYSCALL (times, err, 1, buf);
if (INTERNAL_SYSCALL_ERROR_P (ret, err)
&& __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0))
{ // 这里如果传的 buf == NULL 的话,也会执行里面的操作。
/* This might be an error or not. For architectures which have
no separate return value and error indicators we cannot
distinguish a return value of -1 from an error. Do it the
hard way. We crash applications which pass in an invalid BUF
pointer. */
#define touch(v) \
do { \
clock_t temp = v; \
asm volatile ("" : "+r" (temp)); \
v = temp; \
} while (0)
touch (buf->tms_utime);
// 如果是 NULL->tms_utime 可能在运行一段时候后产生段错误
touch (buf->tms_stime);
touch (buf->tms_cutime);
touch (buf->tms_cstime); /* If we come here the memory is valid and the kernel did not
return an EFAULT error. Return the value given by the kernel. */
} /* Return value (clock_t) -1 signals an error, but if there wasn't any,
return the following value. */
if (ret == (clock_t) -1)
return (clock_t) 0; return ret;
}
    //  对比了最新版的 glibc , 他已经修改了对应的代码
28 if (INTERNAL_SYSCALL_ERROR_P (ret, err)
29 && __builtin_expect (INTERNAL_SYSCALL_ERRNO (ret, err) == EFAULT, 0)
30 && buf)
// 这里对 buf 进行了判断, 如果为 buff 为真才进去。
  • 目前我的解决方式是用 以前交叉编译器里面的的glibc.so.6 , 暂时运行还未出现问题。

  • 但是使用了之前的 glibc 之后,发现 gdb 不能使用,所以又将 gdb 用以前的交叉编译器编译了一次。

  • 过程如下:

    //  第一步是下载 gdb 的源码以及 ncurses 的源码 以及 termcap 的源码
gdb 下载地址 : http://ftp.gnu.org/gnu/gdb/
gdb 我是下载了一个比较保守的版本 7.2 ,我怕比较新的有问题。 ncurses 下载地址: http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.8.tar.gz
termcap 下载地址: http://ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz
  • 解压相关源代码

    tar -xvf termcap-1.3.1.tar.gz
tar -xvf gdb-7.2a.tar.bz2
  • 交叉编译 termcap

    cd termcap-1.3.1/
mkdir output
vim my.sh
#!/bin/sh ./configure --target=arm-none-linux-gnueabi --prefix=/home/sbc_7816_sdk6/test/gdb/termcap-1.3.1/output
    chmod +x my.sh
./my.sh
make
make install
    将 output/lib  下面的库copy 到交叉编译器的  lib 里面, include  也是
cp output/lib/libtermcap.a /home/sbc_7816_sdk6/aplex/linux-devkit/usr/local/arm/4.3.2/arm-none-linux-gnueabi/lib
cp output/include/termcap.h /home/sbc_7816_sdk6/aplex/linux-devkit/usr/local/arm/4.3.2/arm-none-linux-gnueabi/include/
  • 交叉编译 gdb

    cd ~/test/gdb/gdb-7.2/
mkdir output
vim my.sh
#!/bin/sh ./configure --target=arm-linux --host=arm-linux --prefix=/home/sbc_7816_sdk6/test/gdb/gdb-7.2/output
    chmod +x my.sh
./my.sh
make
make install
     将生成的 output/bin  里面的 gdb  gdbserver  拷贝到 目标文件系统的  /usr/bin 下面,要覆盖
    完成

最新文章

  1. MySQL中INFORMATION_SCHEMA是什么?(2)
  2. 尝试打开或创建物理文件 REATE FILE 遇到操作系统错误 5(拒绝访问)
  3. c#实现房贷计算的方法源码
  4. ASIHTTPRequest详解 [经典3]
  5. 在Eclipse中配置Tomcat 创建和运行Servlet/JSP
  6. 使用escape编码地址栏中的中文字符
  7. 2016 Multi-University Training Contest 1 Chess 组合游戏+状压(预处理)
  8. poj 1995 Raising Modulo Numbers【快速幂】
  9. There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
  10. [2017BUAA软工]第0次个人作业
  11. zuul超时的解决方案
  12. PHP系统左侧菜单栏的管理与实现
  13. Kafka安装之 Zookeeper
  14. 用Pytorch训练MNIST分类模型
  15. PHP获取日期时间信息
  16. 180510.最近踩过和听过的sql的坑
  17. eclipse安装quick text search插件,全文搜索
  18. [leetcode]Set Matrix Zeroes @ Python
  19. MAC高效软件必备-落雨
  20. 超频,如何超频CPU和显卡?

热门文章

  1. linux 基本命令学习
  2. Sn.exe(强名称工具)
  3. 转:VB用ADO连接SQLServer数据库
  4. Python 整数和浮点数运算
  5. js 多级联动(省、市、区)
  6. [Done]java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
  7. linux sort 、uniq 命令
  8. Oracle 计算表占用空间大小
  9. 转:发一个自己用过的makefile .
  10. 深入理解JavaScript系列(转载)