如何编译静态gdbserver

时间:2015-01-21 05:36:45

标签: android gdb ld gdbserver

我对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?

非常感谢。

1 个答案:

答案 0 :(得分:0)

  

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

在此命令中,您要求GCC将共享库libinproctrace.so-static标记链接。 GCC的回答:"I'm sorry Dave, I'm afraid I can't do that"

所以不要这样做。相反,请修改Makefile并将-static专门添加到gdbserver的链接行,而不是在命令行中添加所有内容

相关问题