- 论坛徽章:
- 1
|
本帖最后由 asker160 于 2016-09-23 12:22 编辑
我用ubuntu1604的64位版本,我在当前目录下编译简单的c文件,可以直接a.out或者./a.out都没有问题。
我尝试从AT&T汇编里面来调用c运行时库的printf函数,打印一个hello world,如下所示:
$ cat i.s
- .code32
- .section .data
- firststring:
- .ascii "Hello!d\n\0"
- .section .text
- .globl _start
- _start:
- pushl $firststring
- call printf
- pushl $0
- call exit
复制代码 我编译并链接这个文件:
- $ as i.s && ld a.out -lc -o alc
- $ alc
- bash: ./alc: No such file or directory
复制代码 可是明明就在当前目录下,而且PATH里面有"." gcc生成的c程序的a.out是可以执行的。难道是我的链接选项有错误?
我尝试指定链接器:
- $ as i.s && ld a.out -lc -dynamic-linker /lib/ld-linux.so.2 -o adynlc
- $ adynlc
- bash: ./adynlc: Trying to visit a corrupted library
复制代码 这到底是怎么回事呢?
1. 为什么我两次得到的程序都不能运行?
2. 为什么指定链接器,得到的错误信息还不一样?
|
|