gpt4 book ai didi

c - 在哪里可以找到有关此 .s 文件中的代码的文档?

转载 作者:行者123 更新时间:2023-11-30 16:13:12 24 4
gpt4 key购买 nike

我通过运行生成了下面的汇编程序

clang -s hello.c

其中 hello.c 是以下内容的文件名:

#include <stdio.h>

main() {

printf("Hello\n");

}

汇编器位于hello.s中:

  .section  __TEXT,__text,regular,pure_instructions
.build_version macos, 10, 14 sdk_version 10, 14
.globl _main ## -- Begin function main
.p2align 4, 0x90
_main: ## @main
.cfi_startproc
## %bb.0:
pushq %rbp
...

最佳答案

您可以在 GAS 手册中找到文档(clang/LLVM 使用相同的语法,包括指令)。 https://sourceware.org/binutils/docs/as/

另请参阅 https://stackoverflow.com/tags/x86/info 中的链接和 https://stackoverflow.com/tags/att/info有关 x86-64 AT&T 语法的更多信息。

Clang/LLVM 可以使用 Intel 语法,就像 GCC 一样,但指令不会改变。 clang --x86-asm-syntax=intel,或者可能是 -masm=intel 以与 GCC 兼容。

clang 或 LLVM 手册中可能也有一些内容。 (但不要将其与 LLVM-IR assembly language 混淆:LLVM 内部表示的 asm 语法。)通过快速搜索,我没有找到任何有关 clang 如何处理 GAS 指令的 LLVM 文档。

<小时/>

.globl _main 不是标签本身。请注意,它位于对齐填充之前。它只是符号_main的属性修饰符。

_main: 是输出文件中应用标签的位置。

要了解说明,请参阅 How to remove "noise" from GCC/clang assembly output?了解如何删除不相关的指令。

关于c - 在哪里可以找到有关此 .s 文件中的代码的文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58109163/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com