2015-01-21 84 views
0

我对GDB的源代码做了一些更改,所以我想编译一个新的可执行文件。我已经成功编译了一个新的GDB,但是当编译gdb-server时,它失败了,我需要在Makefile中生成LDFLAGS = -static,因为Android没有一些库。失败的消息是这样的:如何编译静态gdbserver

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?

非常感谢。

+0

您是否试过做错误消息告诉您要做的事情?也就是说,用-fPIC标志重新编译。 – NasaGeek 2015-01-21 06:11:27

回答

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的链接行,而不是在命令行上将的所有内容都添加到