【问题标题】:How to complie a static gdbserver如何编译静态 gdbserver
【发布时间】:2015-01-21 05:36:45
【问题描述】:

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

非常感谢。

【问题讨论】:

  • 您是否尝试过按照错误消息告诉您的操作?也就是说,使用 -fPIC 标志重新编译。

标签: android gdb ld gdbserver


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-06
    • 2021-11-23
    相关资源
    最近更新 更多