Compiler construction 如何在Linux和Windows编译器以及ELF/EXE中实现内联汇编程序?

Compiler construction 如何在Linux和Windows编译器以及ELF/EXE中实现内联汇编程序?,compiler-construction,inline-assembly,abi,Compiler Construction,Inline Assembly,Abi,汇编程序是否已经在可执行文件中转换为ABI二进制文件,还是由操作系统完成 请给我GCC或任何其他编译器源代码的链接,它们将x86-64内联asm转换为ABI二进制 澄清我不知道,如果我知道这些权利: x86-64 ASCII指令按1:1转换为二进制块。语法无关紧要 它根据ABI规范进行转换 因此,我想知道它是由编译器还是由操作系统在可执行程序处理过程中转换的。对于gcc,从例如C源代码生成可执行程序是一个多步骤的过程。我们可以观察到: $ gcc -v -save-temps -o t t.c

汇编程序是否已经在可执行文件中转换为ABI二进制文件,还是由操作系统完成

请给我GCC或任何其他编译器源代码的链接,它们将x86-64内联asm转换为ABI二进制

澄清我不知道,如果我知道这些权利:

x86-64 ASCII指令按1:1转换为二进制块。语法无关紧要 它根据ABI规范进行转换 因此,我想知道它是由编译器还是由操作系统在可执行程序处理过程中转换的。

对于gcc,从例如C源代码生成可执行程序是一个多步骤的过程。我们可以观察到:

$ gcc -v -save-temps -o t t.c -lm Reading specs from ..../lib/gcc/..../specs Configured with: ./configure [ .... ] Thread model: posix gcc version .... .../cc1 -E -quiet -v -iprefix ..../lib/gcc/..../ t.c ... -o t.i [ output of the C preprocessor ... ] ..../gcc/.../libexec/gcc/..../cc1 -fpreprocessed t.i -quiet -dumpbase t.c ... -auxbase t -O8 -version -o t.s [ output of the C compiler - which operates on the preprocessed source ... ] .../binutils/.../bin/as -V -Qy -o t.o t.s [ output of the GNU assembler - using the assembly created by the compiler ... ] ..../gcc/.../libexec/gcc/..../collect2 -rpath [ ... ] -L [ ... ] --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o t /usr/lib64/crt1.o /usr/lib64/crti.o ..../gcc/.../lib/gcc/.../crtbegin.o -L[ ... quite a few more ... ] t.o -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed .../gcc/..../lib/gcc/..../crtend.o /usr/lib64/crtn.o [ output by the linker - using the object file created by the assembler ... ] 结果是: t.s: Assembler messages: t.s:147: Error: no such instruction: `scream loudly!'
因为编译器只是。。。不在乎。

gcc不会将内联程序集转换为二进制。除了替换输入/输出操作数和/或添加语句以设置输入/检索asm语句中的输出外,它实际上还嵌入了汇编源文件——通常情况下,汇编源文件会从GNU binutils传递给实际的汇编程序。这就是目标代码生成的地方。我发现它使用小型C编译器来处理这一部分。 t.s: Assembler messages: t.s:147: Error: no such instruction: `scream loudly!'