主题 : tiny210,使用官方带的交叉编译链,编译后的可执行文件放到开发板上运行,提示段错误。 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 135055
精华: 0
发帖: 3
金钱: 15 两
威望: 3 点
贡献值: 0 点
综合积分: 6 分
注册时间: 2017-10-15
最后登录: 2017-10-21
楼主  发表于: 2017-10-15 09:42

 tiny210,使用官方带的交叉编译链,编译后的可执行文件放到开发板上运行,提示段错误。

使用官方带的交叉编译链,编译后的可执行文件放到开发板上提示段错误。

1. 交叉编译链信息(友善之臂官方带的交叉编译链)
Using built-in specs.COLLECT_GCC=arm-linux-gccCOLLECT_LTO_WRAPPER=/opt/gcc-arm/210/4.5.1/bin/../libexec/gcc/arm-none-linux-gnueabi/4.5.1/lto-wrapperTarget: arm-none-linux-gnueabiConfigured with: /work/toolchain/build/src/gcc-4.5.1/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.5.1 --with-sysroot=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root --enable-languages=c,c++ --disable-multilib --with-cpu=arm1176jzf-s --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=softfp --with-pkgversion=ctng-1.8.1-FA --with-bugurl=http://www.arm9.net/ --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-gmp=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-mpfr=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-ppl=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-cloog=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-mpc=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-libelf=/work/toolchain/build/arm-none-linux-gnueabi/build/static --enable-threads=posix --with-local-prefix=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root --disable-nls --enable-symvers=gnu --enable-c99 --enable-long-longThread model: posixgcc version 4.5.1 (ctng-1.8.1-FA)

2.测试代码

#include <stdio.h>
int main()
{
   printf("chen\n"); 
 return 0;
}

3.编译

arm-linux-gcc -o hello ./hello.c

4. 可执行文件依赖的动态库

# arm-linux-readelf -d ./hello

Dynamic section at offset 0xf18 contains 24 entries:
  Tag        Type                         Name/Value
0x00000001 (NEEDED)                     Shared library: [libc.so.6]
0x0000000c (INIT)                       0x82b4
0x0000000d (FINI)                       0x843c
0x00000019 (INIT_ARRAY)                 0x10f0c
0x0000001b (INIT_ARRAYSZ)               4 (bytes)
0x0000001a (FINI_ARRAY)                 0x10f10
0x0000001c (FINI_ARRAYSZ)               4 (bytes)
0x00000004 (HASH)                       0x81a8
0x00000005 (STRTAB)                     0x8220
0x00000006 (SYMTAB)                     0x81d0
0x0000000a (STRSZ)                      65 (bytes)
0x0000000b (SYMENT)                     16 (bytes)
0x00000015 (DEBUG)                      0x0
0x00000003 (PLTGOT)                     0x11000
0x00000002 (PLTRELSZ)                   32 (bytes)
0x00000014 (PLTREL)                     REL
0x00000017 (JMPREL)                     0x8294
0x00000011 (REL)                        0x828c
0x00000012 (RELSZ)                      8 (bytes)
0x00000013 (RELENT)                     8 (bytes)
0x6ffffffe (VERNEED)                    0x826c
0x6fffffff (VERNEEDNUM)                 1
0x6ffffff0 (VERSYM)                     0x8262
0x00000000 (NULL)                       0x0

5.查看开发板上是否有该动态库

[root@FriendlyARM /]# find / -name "libc.so.6"
/lib/libc.so.6

6.在开发板上运行

[root@FriendlyARM /]# chmod +x /opt/hello 
[root@FriendlyARM /]# ./opt/hello
Segmentation fault

7.求解答,求帮助。
[ 此帖被esuoyanyu在2017-10-15 10:29重新编辑 ]