如何遵守静态 gdb 服务器



我对GDB的源代码进行了一些更改,所以我想编译一个新的可执行文件。我已经成功地编译了一个新的GDB,但是当涉及到编译gdb-server时,它失败了,我需要在Makefile中制作LDFLAGS = -static,因为Android没有一些库。失败消息如下所示:

gcc -shared -fPIC -Wl,--no-undefined -g -O2     -I. -I. -I./../common -I./../regformats -I./.. -I./../../include -I./../gnulib/import -Ibuild-gnulib-gdbserver/import -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-char-subscripts -Wempty-body  -DGDBSERVER 
-static  -Wl,--dynamic-list=./proc-service.list -o libinproctrace.so ax-ipa.o tracepoint-ipa.o format-ipa.o utils-ipa.o regcache-ipa.o remote-utils-ipa.o common-utils-ipa.o tdesc-ipa.o print-utils-ipa.o rsp-low-ipa.o amd64-linux-ipa.o linux-amd64-ipa.o -ldl -pthread
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.6/crtbeginT.o: relocation R_X86_64_32 against `__DTOR_END__' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.6/crtbeginT.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libinproctrace.so] Error 1

使用 ld 时失败,所以我想知道如何编译静态 gdbserver?

多谢。

gcc -shared -fPIC ... -static ... -o libinproctrace.so ...

在此命令中,您要求 GCC 使用-static标志链接共享库libinproctrace.so。海湾合作委员会的回答是:"对不起,戴夫,恐怕我做不到"。

所以不要那样做。相反,请编辑Makefile并将-static专门添加到 gdbserver 的链接行,而不是添加到命令行上的所有内容

最新更新