我对bash并不陌生,但这是我第一次见到这种情况。
[OP@localhost linking]$ ls
helloworld-lib.o helloworld-lib.s helloworld_s
[OP@localhost linking]$ ./helloworld_s
bash: ./helloworld_s: No such file or directory
在测试链接器
ld
时,我遇到了这个错误。 helloworld-lib.s
的内容如下:[OP@localhost linking]$ cat helloworld-lib.s
.section .data
helloworld:
.ascii "Hello, world!\n\0"
.section .text
.globl _start
_start:
mov $helloworld, %rdi
call printf
mov $0, %rdi
call exit
这个文件 helloworld_s
是如下产生的。
[OP@localhost linking]$ as helloworld-lib.s -o helloworld-lib.o
[OP@localhost linking]$ ld -lc helloworld-lib.o -o helloworld_s
我不知道这些信息是否相关。顺便说一下,如果我尝试运行其他文件,我只会得到一个权限被拒绝的错误(正如所预期的那样)。有什么想法吗?
编辑:如建议所示,这是 ls -l
的输出:
[OP@localhost linking]$ ls -l
total 88
-rw-rw-r--. 1 OP OP 968 Mar 23 18:40 helloworld-lib.o
-rw-rw-r--. 1 OP OP 159 Mar 23 18:40 helloworld-lib.s
-rwxrwxr-x. 1 OP OP 14384 Mar 23 18:41 helloworld_s
以下是
id
命令的输出结果:[OP@localhost linking]$ id
uid=1000(OP) gid=1000(OP) groups=1000(OP),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
编辑:有关答案,请参见评论。 在此处查看
cat
命令读取这个文件。而且用basename
命令也无法发现这个文件名有什么异常之处。 - extremeaxe5ls -l
和id
的输出。 - Cyrusldd
命令会告诉你它正在寻找类似于/lib/ld64.so.1
的文件,但实际上这个文件并不存在。 - David Schwartzreadelf -l helloworld_s
告诉我该程序请求解释器为“/lib/ld64.so.1”,正如你所说,它并不存在。所以很明显有问题。当我明确指定解释器为“/usr/lib64/ld-linux-x86-64.so.2”时,一切都正常。首先,您能否将此发布为答案?但是,如果是这种情况,我为什么会得到这个错误?另外,为什么GNU链接器默认请求一个不存在的程序解释器? - extremeaxe5