安装交叉编译器gdbserver 按readme来编译报错找不到
linux-arm-low.c: In function ‘CORE_ADDR arm_sigreturn_next_pc(regcache*, int, int*)’:
linux-arm-low.c:769:29: error: ‘__NR_sigreturn’ was not declared in this scope
gdb_assert (svc_number == __NR_sigreturn || svc_number == __NR_rt_sigreturn);
^
./../common/gdb_assert.h:34:13: note: in definition of macro ‘gdb_assert’
((void) ((expr) ? 0 : \
^
linux-arm-low.c: In function ‘CORE_ADDR get_next_pcs_syscall_next_pc(arm_get_next_pcs*)’:
linux-arm-low.c:823:21: error: ‘__NR_sigreturn’ was not declared in this scope
if (svc_number == __NR_sigreturn || svc_number == __NR_rt_sigreturn)
^
make: *** [linux-arm-low.o] 错误 1
按博客方法处理https://www.codenong.com/cs106254960/
//在这个linux-arm-low.c文件添加文件包含
#ifndef __NR_sigreturn
#include <asm/unistd.h>
#endif
继续编译又引入新的问题,新问题参考博客https://www.programmersought.com/article/98671620102/
/usr/bin/ld: build-gnulib-gdbserver/import/libgnu.a(fcntl.o): Normal ELF relocation (M: 40)
/usr/bin/ld: build-gnulib-gdbserver/import/libgnu.a(fcntl.o): Normal ELF relocation (M: 40)
/usr/bin/ld: build-gnulib-gdbserver/import/libgnu.a(fcntl.o): Normal ELF relocation (M: 40)
/usr/bin/ld: build-gnulib-gdbserver/import/libgnu.a(fcntl.o): Normal ELF relocation (M: 40)
/usr/bin/ld: build-gnulib-gdbserver/import/libgnu.a(fcntl.o): Normal ELF relocation (M: 40)
build-gnulib-gdbserver/import/libgnu.a: Unable to add symbol: File format error
collect2: error: ld returned 1 exit status
Makefile:399: recipe for target ‘gdbserver’ failed
make: *** [gdbserver] Error 1
查阅了会,链接工具不一致,迎着头皮看了遍make输出信息,截取部分输出
make[4]: Entering directory '/home/lala0903/linux/tool/gdb-9.1/gdb/gdbserver/build-gnulib-gdbserver/import'
GEN alloca.h
GEN configmake.h
GEN warn-on-use.h
make all-recursive
make[5]: Entering directory '/home/lala0903/linux/tool/gdb-9.1/gdb/gdbserver/build-gnulib-gdbserver/import'
CC cloexec.o
CC dirname-lgpl.o
CC stripslash.o
GEN ref-add.sed
GEN ref-del.sed
AR libgnu.a
arm-linux-gnueabihf-ranlib ./libiberty.a; \
cd ..; \
else true; fi
make[2]: Leaving directory '/home/lala0903/linux/tool/gdb-9.1/gdb/gdbserver/build-libiberty-gdbserver'
make[1]: Leaving directory '/home/lala0903/linux/tool/gdb-9.1/gdb/gdbserver'
CXX alloc.o
CXX arch/arm-linux.o
CXX gdbsupport/agent.o
CXX gdbsupport/btrace-common.o
从上面看出有CC 和CXX,感觉奇怪应该是不止gcc还有g++,于是查看了下makefile
CC = arm-linux-gnueabihf-gcc
CXX = g++
CXX_DIALECT = -std=gnu++11
AR = arm-linux-gnueabihf-ar
AR_FLAGS = rc
不知道为什么配置出来的make中g++ 竟然不是交叉编译工具,本地没装arm g++,装了一个修改makefile解决问题,不知道是否是不存在g++交叉编译工具导致的config配置问题,需要实验一下
在尝试交叉编译gdbserver时遇到了'__NR_sigreturn'未声明的错误。通过查阅博客和错误信息,发现可能是链接工具不一致导致。在分析makefile后,发现g++并不是交叉编译工具,于是安装了arm g++并修改makefile,解决了问题。这可能是由于config配置中缺少g++交叉编译工具引起的。

4995

被折叠的 条评论
为什么被折叠?



