C++ 如何在 Intel 语法中使用 clang 生成汇编代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10990018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to generate assembly code with clang in Intel syntax?
提问by Jesse Good
As this questionshows, with g++, I can do g++ -S -masm=intel test.cpp
.
Also, with clang, I can do clang++ -S test.cpp
, but -masm=intel
is not supported by clang (warning argument unused during compilation: -masm=intel
). How do I get intel syntax with clang?
正如这个问题所示,使用 g++,我可以做到g++ -S -masm=intel test.cpp
. 另外,使用 clang,我可以做clang++ -S test.cpp
,但-masm=intel
不支持 clang ( warning argument unused during compilation: -masm=intel
)。如何使用 clang 获得英特尔语法?
回答by dcoles
As noted below by @thakis, newer versions of Clang (3.5+) accept the -masm=intel
argument.
正如下面@thakis所指出的,较新版本的 Clang (3.5+) 接受该-masm=intel
参数。
For older versions, this should get clang to emit assembly code with Intel syntax:
对于旧版本,这应该让 clang 使用 Intel 语法发出汇编代码:
clang++ -S -mllvm --x86-asm-syntax=intel test.cpp
You can use -mllvm <arg>
to pass in llvm options from the clang command line. Sadly this option doesn't appear to be well documented, and thus I only found it by browsing through the llvm mailing lists.
您可以使用-mllvm <arg>
从 clang 命令行传入 llvm 选项。遗憾的是,这个选项似乎没有很好的文档记录,因此我只能通过浏览 llvm 邮件列表找到它。