尝试为ARM构建GDB时出错

时间:2017-12-14 07:07:55

标签: linux arm gdb autoconf

我试图在我的Ubuntu 16.04计算机上为一个手臂构建GDB(版本8.0)。 我计划直接在arm机器上调试它(目前没有服务器)。

我已经执行了这些说明(正如here所解释的那样)

g++ -std=gnu++11 -g -O2   -static-libstdc++ -static-libgcc    \
    -o gdb gdb.o arm.o arm-linux.o arm-get-next-pcs.o arm-tdep.o arm-linux-tdep.o glibc-tdep.o solib-svr4.o symfile-mem.o linux-tdep.o linux-record.o ser-base.o ser-unix.o ser-pipe.o ser-tcp.o inf-ptrace.o fork-child.o arm-linux-nat.o aarch32-linux-nat.o proc-service.o linux-thread-db.o linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o linux-waitpid.o linux-personality.o linux-namespaces.o ax-gdb.o ax-general.o ctf.o dcache.o remote.o remote-fileio.o remote-notif.o tracefile.o tracefile-tfile.o tracepoint.o  cli-cmds.o cli-decode.o cli-dump.o cli-interp.o cli-logging.o cli-script.o cli-setshow.o cli-utils.o mi-cmd-break.o mi-cmd-catch.o mi-cmd-disas.o mi-cmd-env.o mi-cmd-file.o mi-cmd-info.o mi-cmd-stack.o mi-cmd-target.o mi-cmd-var.o mi-cmds.o mi-console.o mi-getopt.o mi-interp.o mi-main.o mi-out.o mi-parse.o mi-symbol-cmds.o stub-termcap.o python.o guile.o elfread.o stap-probe.o dtrace-probe.o posix-hdep.o posix-strerror.o ada-exp.o c-exp.o cp-name-parser.o d-exp.o f-exp.o go-exp.o m2-exp.o p-exp.o rust-exp.o ada-lang.o ada-tasks.o ada-typeprint.o ada-valprint.o ada-varobj.o addrmap.o agent.o annotate.o arch-utils.o auto-load.o auxv.o bcache.o bfd-target.o block.o blockframe.o break-catch-sig.o break-catch-syscall.o break-catch-throw.o breakpoint.o btrace.o btrace-common.o buffer.o build-id.o buildsym.o c-lang.o c-typeprint.o c-valprint.o c-varobj.o charset.o cleanups.o cli-out.o coff-pe-read.o coffread.o common-agent.o common-debug.o common-exceptions.o common-regcache.o common-utils.o complaints.o completer.o continuations.o copying.o corefile.o corelow.o cp-abi.o cp-namespace.o cp-support.o cp-valprint.o d-lang.o d-namespace.o d-valprint.o dbxread.o debug.o demangle.o dfp.o dictionary.o disasm.o disasm-selftests.o doublest.o dummy-frame.o dwarf2-frame.o dwarf2-frame-tailcall.o dwarf2expr.o dwarf2loc.o dwarf2read.o environ.o errors.o eval.o event-loop.o event-top.o exceptions.o exec.o expprint.o extension.o f-lang.o f-typeprint.o f-valprint.o fileio.o filestuff.o filesystem.o findcmd.o findvar.o format.o frame.o frame-base.o frame-unwind.o gcore.o gdb_bfd.o gdb-dlfcn.o gdb_obstack.o gdb_usleep.o gdb_vecs.o gdbarch.o gdbtypes.o gnu-v2-abi.o gnu-v3-abi.o go-lang.o go-typeprint.o go-valprint.o inf-child.o inf-loop.o infcall.o infcmd.o inferior.o infrun.o inline-frame.o interps.o jit.o language.o linespec.o location.o m2-lang.o m2-typeprint.o m2-valprint.o macrocmd.o macroexp.o macroscope.o macrotab.o main.o maint.o mdebugread.o mem-break.o memattr.o memory-map.o memrange.o mi-common.o minidebug.o minsyms.o mipsread.o namespace.o new-op.o objc-lang.o objfiles.o observer.o opencl-lang.o osabi.o osdata.o p-lang.o p-typeprint.o p-valprint.o parse.o print-utils.o printcmd.o probe.o progspace.o prologue-value.o psymtab.o ptid.o record.o record-btrace.o record-full.o regcache.o reggroups.o registry.o reverse.o rsp-low.o run-time-clock.o rust-lang.o selftest.o selftest-arch.o sentinel-frame.o ser-event.o serial.o signals.o signals-state-save-restore.o skip.o solib.o solib-target.o source.o stabsread.o stack.o std-regs.o symfile.o symfile-debug.o symmisc.o symtab.o target.o target-dcache.o target-descriptions.o target-memory.o thread.o thread-fsm.o tid-parse.o top.o trad-frame.o tramp-frame.o typeprint.o ui-file.o ui-out.o user-regs.o utils.o utils-selftests.o valarith.o valops.o valprint.o value.o varobj.o vec.o version.o waitstatus.o xml-builtin.o xml-support.o xml-syscall.o xml-tdesc.o xml-utils.o compile.o compile-c-support.o compile-c-symbols.o compile-c-types.o compile-loc2c.o compile-object-load.o compile-object-run.o inflow.o    init.o \
       ../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a -L./../zlib -lz  ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -ldl -ldl -lm -ldl     ../libiberty/libiberty.a  build-gnulib/import/libgnu.a  -ldl -Wl,--dynamic-list=./proc-service.list
/usr/bin/ld: ../readline/libreadline.a(readline.o): Relocations in generic ELF (EM: 40)
/usr/bin/ld: ../readline/libreadline.a(readline.o): Relocations in generic ELF (EM: 40)
/usr/bin/ld: ../readline/libreadline.a(readline.o): Relocations in generic ELF (EM: 40)
/usr/bin/ld: ../readline/libreadline.a(readline.o): Relocations in generic ELF (EM: 40)
/usr/bin/ld: ../readline/libreadline.a(readline.o): Relocations in generic ELF (EM: 40)
/usr/bin/ld: ../readline/libreadline.a(readline.o): Relocations in generic ELF (EM: 40)
/usr/bin/ld: ../readline/libreadline.a(readline.o): Relocations in generic ELF (EM: 40)
../readline/libreadline.a: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
Makefile:2215: recipe for target 'gdb' failed
make[2]: *** [gdb] Error 1
make[2]: Leaving directory '/home/user/gdb-8.0/gdb'
Makefile:9126: recipe for target 'all-gdb' failed
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory '/home/user/gdb-8.0'
Makefile:849: recipe for target 'all' failed
make: *** [all] Error 2

在联系过程中,系统向我提出了这个错误:

select *
from the_table
order by split_part(file_id, '-', 2)::int;

我试图下载一个新的readline库并将其替换为gdb附带的那个,但它并没有解决我的问题。

有人有线索吗?

谢谢!

2 个答案:

答案 0 :(得分:0)

  

./configure --target=arm-linux-gnueabi ...

您正在尝试在x86计算机上构建ARM二进制文件。您需要一个针对ARM的交叉编译器,但您似乎正在使用 native 编译器(生成x86对象)。

正如费楠所说,你需要:

./configure ... LD=/path/to/arm-XXX-ld CC=/path/to/arm-XXX-gcc CXX=/path/to/arm-XXX-g++

答案 1 :(得分:0)

您的命令看起来正确。它没有按预期工作的原因必须是您的$PATH中没有ARM交叉编译工具链,或者它的前缀不是arm-linux-gnueabi

作为示例假设您下载了gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz工具链并将其解压缩到~/tmp下。以下命令应成功构建gdb

PATH="$PATH:$HOME/tmp/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi/bin"
./configure --host=arm-linux-gnueabi
make

我缩短了./configure次调用,因为默认值足够(TARGET=HOSTBUILD=<automatically guessed>)。

混淆来自于--host=...使configure脚本查找arm-linux-gnueabi-gcc...-ld等),如果它找不到它们gcc,则使用ld假设它们交叉编译为HOST。这种后备行为就是这里发生的事情。

要确保使用正确的工具链,请注意

checking for arm-linux-gnueabi-gcc...  found arm-linux-gnueabi-gcc

输出configure

指定LD=arm-XXX-ld CC=arm-XXX-gcc CXX=arm-XXX-g++正如其他人所建议的那样,--host=选项的目的是为您找到这些东西,您只需要将它们放入$PATH $("#dialog-confirm").dialog({ resizable: false, height: "auto", width: 400, modal: true, autoOpen: false, buttons: { "Delete Student": function(event) { event.preventDefault(); $.ajax({ type: "POST", data: { id: "$(this).data('studentId')", _method: "DELETE", }, url: "{{ route('students.destroy') }}", success: function(result) { alert('ok'); }, error: function(result) { alert('error'); } }); $(this).dialog("close"); }, Cancel: function() { $(this).dialog("close"); } } }); $(".deleteButton").on("click",function() { $("#dialog-confirm").data('studentId',$(this).closest("td").find("input[name='studentId']").val()).dialog("open"); }); 1}}。