小编Eri*_*ric的帖子

如何获取有关不会执行的二进制文件的信息?

当我运行名为“myfile”的用户应用程序之一时。

$ ./myfile
Run Code Online (Sandbox Code Playgroud)

我收到以下输出

bash: ./myfile: cannot execute binary file
Run Code Online (Sandbox Code Playgroud)

我的用户希望运行二进制文件。我认为这是一个编译错误,但无法确认。我运行了文件命令

$ file myfile
myfile: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
Run Code Online (Sandbox Code Playgroud)

我的 RHEL6 操作系统是 64 位

$ uname -p -o
x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

所以在我看来,它符合正确的架构。我不明白“可重定位”在文件命令的输出中是什么意思,并且无法从手册页中获得解释。

为了更好的衡量,我检查了共享库依赖项

$ ldd myfile 
not a dynamic executable
Run Code Online (Sandbox Code Playgroud)

有什么方法可以让我运行这个文件,或者给我的用户一些关于它为什么不运行的建设性信息(比如他需要使用 x 重新编译)?

斯特雷斯

$ strace ./myfile
execve("./myfile", ["./myfile"], [/* 22 vars */]) = -1 ENOEXEC (Exec format error)
dup(2)                                  = 3
fcntl(3, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0 …
Run Code Online (Sandbox Code Playgroud)

linux executable binary gcc

10
推荐指数
1
解决办法
3万
查看次数

标签 统计

binary ×1

executable ×1

gcc ×1

linux ×1