免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1280 | 回复: 1
打印 上一主题 下一主题

[内核入门] gcc-4.8.3 编译linux-2.6.31内核,数组访问出错的问题求助? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-12-09 14:45 |只看该作者 |倒序浏览
测试代码如下:

unsigned char _ctype[] = {
_C,_C,_C,_C,_C,_C,_C,_C,            /* 0-7 */
_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C,        /* 8-15 */
_C,_C,_C,_C,_C,_C,_C,_C,            /* 16-23 */
_C,_C,_C,_C,_C,_C,_C,_C,            /* 24-31 */
_S|_SP,_P,_P,_P,_P,_P,_P,_P,            /* 32-39 */
_P,_P,_P,_P,_P,_P,_P,_P,            /* 40-47 */
_D,_D,_D,_D,_D,_D,_D,_D,            /* 48-55 */
_D,_D,_P,_P,_P,_P,_P,_P,            /* 56-63 */
_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U,    /* 64-71 */
_U,_U,_U,_U,_U,_U,_U,_U,            /* 72-79 */
_U,_U,_U,_U,_U,_U,_U,_U,            /* 80-87 */
_U,_U,_U,_P,_P,_P,_P,_P,            /* 88-95 */
_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L,    /* 96-103 */
_L,_L,_L,_L,_L,_L,_L,_L,            /* 104-111 */
_L,_L,_L,_L,_L,_L,_L,_L,            /* 112-119 */
_L,_L,_L,_P,_P,_P,_P,_C,            /* 120-127 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,        /* 128-143 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,        /* 144-159 */
_S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,   /* 160-175 */
_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,       /* 176-191 */
_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,       /* 192-207 */
_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L,       /* 208-223 */
_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */

static int format_decode(const char *fmt, struct printf_spec *spec)
{
    ......
    unsigned int index;
    unsigned char uch;
    ......
test:
    prom_putstr("format_decode=>");
    prom_putstr(fmt);
    prom_putstr("\n");

    if (isdigit('1')) {
        prom_putstr("format_decode=>1 is digit\n");
    }

    uch = _ctype[115];
    if (uch == 0x02) {
        prom_putstr("format_decode=>115 is 0x02\n");
    }

    index = (unsigned int)(unsigned char)(*fmt);
    if (index == 115)
        prom_putstr("format_decode=>index is 115\n");

    uch = _ctype[index];
    if (uch == 0x02) {
        prom_putstr("format_decode=>index is 0x02\n");
    }

    goto test;
    ......
}


上面的代码用gcc-4.3.3编译时,运行是没有问题的;

当用gcc-4.8.8编译时,运行的结果为:
format_decode=>s
format_decode=>1 is digit
format_decode=>115 is 0x02
format_decode=>index is 115
也就是说执行“uch = _ctype[index];”这行代码时挂死了;

请教一下各位高手,上面的问题可能是什么原因引起的?谢谢。




论坛徽章:
0
2 [报告]
发表于 2014-12-09 15:38 |只看该作者
补充一下:
gcc 4.3.3的版本信息如下:
Using built-in specs.
Target: mips-linux-uclibc
Configured with: /home/u/ar9342_mi124_ap/sdk/build/gcc-4.3.3/toolchain_build_mips/gcc-4.3.3/configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=mips-linux-uclibc --enable-languages=c --with-sysroot=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.3.3/build_mips/staging_dir --with-build-time-tools=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.3.3/build_mips/staging_dir/usr/mips-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.3.3/toolchain_build_mips/gmp --with-mpfr=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.3.3/toolchain_build_mips/mpfr --disable-nls --enable-threads --disable-multilib --disable-decimal-float --with-float=soft --with-abi=32 --with-tune=mips32r2 : (reconfigured) /home/u/ar9342_mi124_ap/sdk/build/gcc-4.3.3/toolchain_build_mips/gcc-4.3.3/configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=mips-linux-uclibc --enable-languages=c --with-sysroot=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.3.3/build_mips/staging_dir --with-build-time-tools=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.3.3/build_mips/staging_dir/usr/mips-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-libssp --disable-tls --enable-shared --with-gmp=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.3.3/toolchain_build_mips/gmp --with-mpfr=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.3.3/toolchain_build_mips/mpfr --disable-nls --enable-threads --disable-multilib --disable-decimal-float --with-float=soft --with-abi=32 --with-tune=mips32r2
Thread model: posix
gcc version 4.3.3 (GCC)

gcc 4.8.3的版本信息如下:
使用内建 specs。
COLLECT_GCC=mips-linux-gcc
COLLECT_LTO_WRAPPER=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.8.3/output/host/usr/libexec/gcc/mips-buildroot-linux-uclibc/4.8.3/lto-wrapper
目标:mips-buildroot-linux-uclibc
配置为:./configure --prefix=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.8.3/output/host/usr --sysconfdir=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.8.3/output/host/etc --enable-static --target=mips-buildroot-linux-uclibc --with-sysroot=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.8.3/output/host/usr/mips-buildroot-linux-uclibc/sysroot --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --with-gmp=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.8.3/output/host/usr --with-mpfr=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.8.3/output/host/usr --enable-target-optspace --disable-libquadmath --disable-libsanitizer --enable-tls --disable-libmudflap --enable-threads --with-mpc=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.8.3/output/host/usr --without-isl --without-cloog --with-float=soft --disable-decimal-float --with-arch=mips32r2 --with-abi=32 --with-pkgversion='Buildroot 2015.02-git'  --enable-languages=c --with-build-time-tools=/home/u/ar9342_mi124_ap/sdk/build/gcc-4.8.3/output/host/usr/mips-buildroot-linux-uclibc/bin --enable-shared --disable-libgomp
线程模型:posix
gcc 版本 4.8.3 (Buildroot 2015.02-git)
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP