如何从汇编语言生成可执行文件?(在emacs中)
有人可以告诉我如何从汇编语言生成可执行文件吗? 我的环境是Ubuntu + Emacs + GCC 出于学习目的,我编写了一些 C 代码(hello.c)并将其转换为程序集(hello.s)
,我想从程序集编写的文件创建一个可执行文件。
我尝试
M-x compile
gcc hello.c -S
从 C 代码制作汇编
并
M-x compile
as hello.s
制作可执行文件
,但只有 a.out 文件,并且无法执行,
所以我尝试了
as hello.s -o aaa
,但文件“aaa”不可执行
Could somebody tell me how to make executable from assembly language?
my environment is Ubuntu + Emacs + GCC
for learning purpose, I wrote some C code(hello.c) and convert it to assembly (hello.s)
and I want to make an executable file from an assembly written file.
I tried
M-x compile
gcc hello.c -S
to make assembly from C code
and
M-x compile
as hello.s
to make executable file
but there's only a.out file and it isn't able to execute
so I tried
as hello.s -o aaa
but file "aaa" is not executable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
as
的输出是一个目标文件。要使其可执行,您需要将其与 ld 链接,但您还需要链接它所依赖的任何对象,如果源是从 gcc 生成的,则至少会包含 libc,以及可能还有一些其他目标文件。The output of
as
is an object file. To make it executable you need to link it withld
but you will also need to link in any objects it depends on, which if the source was generated from gcc, will at least include libc, as well as probably some other object files.