【问题标题】:Executable Segfaults and GDB gives "not in executable format: File truncated"Executable Segfaults 和 GDB 给出“不是可执行格式:文件被截断”
【发布时间】:2022-01-23 06:46:43
【问题描述】:

我正在开发一个应用程序,做了一些更改,现在它甚至不再运行了。我已经恢复了更改,重建了整个应用程序,但仍然没有运气。我不明白这个错误是怎么出现的?我删除了 .o 文件并进行了全新的构建,但它仍然无法正常工作。我没有更改构建设置,我只是修改了一些 .cpp 文件。

如何解决我的可执行文件不再可执行的问题?

ls -l
-rwx--x--x    1 root     root       6344081 Sep 16 23:35 z*

gdb 输出

[root@ipfrmk /]# gdb z
GNU gdb (GDB) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-buildroot-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
"/z": not in executable format: File truncated
(gdb) run z
Starting program:  z
No executable file specified.
Use the "file" or "exec-file" command.

This 与我的问题无关,因为我没有从任何类型的 32 位更改为 64 位,反之亦然

我看到的大多数问题是“文件格式无法识别”或某种被截断的核心文件问题,这些不适用于我不相信的问题...

文件输出

[root@ipfrmk /]# file z
z: ERROR: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, interpreter lib/ld-linux-armhf.so.3 error reading (Invalid argument)

有大量可用的文件系统空间(应用程序大约 63kb)

Filesystem                Size      Used Available Use% Mounted on
/dev/root               487.8M    189.9M    272.9M  41% /

我检查了构建机器和设备上的 md5sum 匹配

构建虚拟机

# md5sum /app/z
e901ef35e43d91545fb9d968c078dce2  /app/z

设备机器

[root@ipfrmk /]# md5sum z
e901ef35e43d91545fb9d968c078dce2  z

【问题讨论】:

  • 只是一个随机名称,我尝试了各种名称较长的其他名称,但没有任何效果,它们都给出相同的错误
  • 命令file z 输出什么?你为什么要以 root 身份运行?
  • @Kevin 用文件输出更新了问题
  • 您的文件系统空间不足吗? (在 Linux 上,请查看 df -h .

标签: c++ gdb executable


【解决方案1】:

更新:

先前的嫌疑人已被排除:文件系统有足够的空间并且md5sum在构建主机和目标主机之间匹配。

这只留下了一种可能的可能性:构建工具链以某种方式损坏,并生成损坏的二进制文件。

特别是我错过了这部分输出:

z: ERROR: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), \ statically linked, interpreter lib/ld-linux-armhf.so.3 error reading (Invalid argument)

二进制文件不能同时是 statically linkedld/ld-linux-armhf.so.3 解释器。并且解释器应该是绝对路径。


上一个答案:

我看到的大多数问题是“文件格式无法识别”或某种被截断的核心文件问题,这些不适用于我不相信的问题...

这个错误的两个非常常见的原因:

  • 目标文件系统空间不足,因此从构建主机到目标主机的复制仅部分成功
  • 文件以 ASCII 模式通过ftp 传输,导致文件损坏。

验证,例如构建主机上的md5sum 和目标匹配将消除这两种可能性。

【讨论】:

  • 我正在使用 make shift ftp 方法将文件传输到我的设备。它一直工作到现在......我相信你是正确的,这是我如何传输文件的问题,但我没有看到文件是如何损坏的...... md5sum 为我提供了两个文件的相同值在两台机器上。
  • @RAZ_Muh_Taz 另一个猜测:构建主机文件系统空间不足,截断发生在 build 时间。
  • 我在构建主机文件系统上有 15GB 可用空间
  • @RAZ_Muh_Taz 我已经更新了答案。
  • 找到 . -name "*.o" -type f|xargs rm -f
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-05-18
  • 1970-01-01
  • 1970-01-01
  • 2016-01-09
  • 2013-01-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多