Linux 远程gdb会话在进入main之前接收信号SIGSEGV

Linux 远程gdb会话在进入main之前接收信号SIGSEGV,linux,gcc,gdb,cross-compiling,gdbserver,Linux,Gcc,Gdb,Cross Compiling,Gdbserver,我正在尝试使用GDB7.7为嵌入式linux平台设置远程调试,运行使用i586 geode linux gnu gcc crosstool NG 1.19.0 4.8.1编译的代码 此处使用的示例是以下程序: #include <stdio.h> #include <stdlib.h> int main(char* argc, char* argv[]) { printf("Hello, 1!"); printf("Hello, 2!"); pr

我正在尝试使用GDB7.7为嵌入式linux平台设置远程调试,运行使用i586 geode linux gnu gcc crosstool NG 1.19.0 4.8.1编译的代码

此处使用的示例是以下程序:

#include <stdio.h>
#include <stdlib.h>

int main(char* argc, char* argv[])
{
    printf("Hello, 1!");
    printf("Hello, 2!");
    printf("Hello, 3!");

    return 0;
}
第二步。在主机PC上:

chetic@ubuntu:~/Documents/tmp/remotetest$ gdb testsc 
GNU gdb (GDB) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from testsc...done.
步骤4:

(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x4000f9ef in ?? () from /lib/ld-linux.so.2
(gdb) 
我尝试在main设置断点,但没有遇到。如果我在目标机上使用gdb运行程序,或者使用常规gcc进行编译,并在pc主机上本地运行远程会话,那么一切都可以很好地进行调试

我已经在主机上为目标和主机编译并安装了gdb 7.7和gdbserver 7.7

谷歌搜索这个问题主要是建议更改堆栈大小,但我尝试使用“ulimit-s”更改堆栈大小限制,使用不同的值,包括unlimited,并在/proc/[pid]/映射中看到堆栈受到影响,但问题仍然存在

内存映射此示例使用“ulimit-s unlimited”:

# cat /proc/`pidof gdbserver`/maps
08048000-08090000 r-xp 00000000 03:01 60919      /usr/bin/gdbserver
08090000-08092000 rw-p 00048000 03:01 60919      /usr/bin/gdbserver
08092000-080be000 rw-p 00000000 00:00 0          [heap]
40000000-4001f000 r-xp 00000000 03:01 45729      /lib/ld-2.17.so
4001f000-40020000 r--p 0001f000 03:01 45729      /lib/ld-2.17.so
40020000-40021000 rw-p 00020000 03:01 45729      /lib/ld-2.17.so
40021000-40022000 r-xp 00000000 00:00 0          [vdso]
40022000-40024000 rw-p 00000000 00:00 0 
40025000-40028000 r-xp 00000000 03:01 45726      /lib/libdl-2.17.so
40028000-40029000 r--p 00002000 03:01 45726      /lib/libdl-2.17.so
40029000-4002a000 rw-p 00003000 03:01 45726      /lib/libdl-2.17.so
4002a000-40195000 r-xp 00000000 03:01 45711      /lib/libc-2.17.so
40195000-40196000 ---p 0016b000 03:01 45711      /lib/libc-2.17.so
40196000-40198000 r--p 0016b000 03:01 45711      /lib/libc-2.17.so
40198000-40199000 rw-p 0016d000 03:01 45711      /lib/libc-2.17.so
40199000-4069e000 rw-p 00000000 00:00 0 
bfb24000-bfb39000 rw-p 00000000 00:00 0          [stack]

您是否也有i586 geode linux gnu gdb或类似产品?如果您这样做了,请使用它连接到gdbserver.No,这就是我自己编译gdb的原因。在主机PC上,在gdb中显示配置显示:-host=x86_64-unknown-linux-gnu-target=i586 geode-linux-gnu,这对我来说很好,除非在编译gdb用于这种用途时还有什么我应该担心的?对不起,这很好,我以为你在使用主机gdb,它可能与您的目标兼容,也可能与您的目标不兼容。除非您设置sysroot,否则gdb将尝试从本地文件系统读取内容。这很少是正确的,请参阅/lib/ld linux消息。。。。我建议在目标远程之前设置sysroot remote:。这可能有点帮助。你找到解决办法了吗?
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x4000f9ef in ?? () from /lib/ld-linux.so.2
(gdb) 
# cat /proc/`pidof gdbserver`/maps
08048000-08090000 r-xp 00000000 03:01 60919      /usr/bin/gdbserver
08090000-08092000 rw-p 00048000 03:01 60919      /usr/bin/gdbserver
08092000-080be000 rw-p 00000000 00:00 0          [heap]
40000000-4001f000 r-xp 00000000 03:01 45729      /lib/ld-2.17.so
4001f000-40020000 r--p 0001f000 03:01 45729      /lib/ld-2.17.so
40020000-40021000 rw-p 00020000 03:01 45729      /lib/ld-2.17.so
40021000-40022000 r-xp 00000000 00:00 0          [vdso]
40022000-40024000 rw-p 00000000 00:00 0 
40025000-40028000 r-xp 00000000 03:01 45726      /lib/libdl-2.17.so
40028000-40029000 r--p 00002000 03:01 45726      /lib/libdl-2.17.so
40029000-4002a000 rw-p 00003000 03:01 45726      /lib/libdl-2.17.so
4002a000-40195000 r-xp 00000000 03:01 45711      /lib/libc-2.17.so
40195000-40196000 ---p 0016b000 03:01 45711      /lib/libc-2.17.so
40196000-40198000 r--p 0016b000 03:01 45711      /lib/libc-2.17.so
40198000-40199000 rw-p 0016d000 03:01 45711      /lib/libc-2.17.so
40199000-4069e000 rw-p 00000000 00:00 0 
bfb24000-bfb39000 rw-p 00000000 00:00 0          [stack]