ztxx194 发表于 2014-12-09 14:45

gcc-4.8.3 编译linux-2.6.31内核,数组访问出错的问题求助?

测试代码如下:

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;
    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;
    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;”这行代码时挂死了;

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




ztxx194 发表于 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)
页: [1]
查看完整版本: gcc-4.8.3 编译linux-2.6.31内核,数组访问出错的问题求助?