如何在Linux上安装和使用GAS(GNU编译器)?
我正在使用 Ubuntu,我正在寻找 Linux 的汇编编译器,我找到了 GAS。
我正在尝试安装并运行它,但不能。
I'm using Ubuntu, and I was looking for an assembler compiler for Linux, and I found GAS.
I'm trying to install it and run it, but I can't.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
as
是 GNU 汇编器。它可以在binutils
中找到,但如果您执行以下操作:sudo apt-get install build-essential
您将获得
gas
以及gcc (默认使用
gas
在后端进行组装)。有关使用
gas
的“教程”,您可能需要阅读编程From the Ground Up,它使用它。要从
.s
文件构建静态可执行文件,如果您想链接库,通常最简单的方法是让 gcc 使用
as
和的正确命令行选项>ld
从 asm 源文件构建可执行文件时。如果您的
foo.s
定义了main
函数,则gcc foo.s -o foo
将起作用。另相关:在 a 上组装 32 位二进制文件64 位系统(GNU 工具链)(如果您在 x86-64 系统上编写 32 位程序)。
as
is the GNU Assembler. It's found inbinutils
but if you do:sudo apt-get install build-essential
You will get
gas
along withgcc
(which default usesgas
for assembling on the back end).For a 'tutorial' about using
gas
, you probably want to read Programming From the Ground Up, which uses it.To build a static executable from a
.s
file,If you want to link with libraries, it's normally easiest to let gcc use the right command line options for
as
andld
when building an executable from an asm source file.gcc foo.s -o foo
will work if yourfoo.s
defines amain
function.Also related: Assembling 32-bit binaries on a 64-bit system (GNU toolchain) if you're writing 32-bit programs on an x86-64 system.
它位于
binutils
包中。It's in the
binutils
package.启动 Synaptic 并在快速搜索栏中输入“gnu assembler”。很明显,
binutils
是所需的包。您可能会发现它已经安装了。我的
binutils 2.20.1-3ubuntu7
已经安装,并且我有一个相当普通的设置。从终端窗口输入
as --version
会让您知道:Fire up Synaptic and enter "gnu assembler" into the quick search bar. It's immediately obvious that
binutils
is the required package.And you may well find it's already installed. My
binutils 2.20.1-3ubuntu7
is already installed and I have a fairly vanilla set-up.Entering
as --version
from a terminal window will let you know:你读过 http://www.faqs.org/docs/Linux- HOWTO/Assembly-HOWTO.html? Debian GAS 上包含在软件包中
所以
$man as
Have you read http://www.faqs.org/docs/Linux-HOWTO/Assembly-HOWTO.html? on Debian GAS is contained in the package
so
$man as
从源代码构建并使用它
GitHub 上游< /a>.
TODO:如何配置
为
特定选项?我们使用了binutils-gdb
顶层的./configure
,但它包含来自多个项目的选项,例如gdb
我相信,而不是作为
特定的?在 Ubuntu 18.04 上测试。
Build from source and use it
GitHub upstream.
TODO: how to configure
as
specific options? We have used the./configure
from thebinutils-gdb
top-level, but that contains options from multiple projects such asgdb
I believe, and notas
specific ones?Tested on Ubuntu 18.04.