程序集文件:.a .s .asm之间的区别 [英] Assembly Files: Difference between .a .s .asm

查看:1750
本文介绍了程序集文件:.a .s .asm之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MIPS模拟器"QTSpim"中,接受三种类型的文件:

In the MIPS simulator "QTSpim", three types of files are accepted:

  • .a
  • .s
  • .asm
  • .a
  • .s
  • .asm

这些文件类型之间是否有区别,如果是,区别是什么?

Is there a difference between those filetypes, and if yes, what is the difference?

推荐答案

在Unix/Linux系统中:

In Unix/Linux systems:

  • .a是静态库(也就是使用ar(1)制作的多个.o文件的存档)的常用扩展名.动态库(也称为共享库)使用.so.
  • .s用于asm编译器输出. (gcc -S foo.c生成asm输出,默认文件名为foo.s)
  • .S用于手写的asm源文件. gcc -c foo.S通过C预处理程序运行它(因此您可以使用#include<>#if#define和C样式注释.)某些C头文件(例如asm/unistd.h)仅具有#define,依此类推.可以包含在.S中,以获取诸如__NR_write系统调用号之类的定义.
  • .a is the usual extension for static libraries (aka Archives of multiple .o files, made with ar(1)). Dynamic libraries, aka Shared Objects, use .so.
  • .s is used for asm compiler output. (gcc -S foo.c produces asm output, with a default filename of foo.s)
  • .S is used for hand-written asm source files. gcc -c foo.S runs it through the C preprocessor (so you can use #include<>, #if, #define, and C-style comments.) Some C headers, like asm/unistd.h only have #defines, and so can be included in a .S to get definitions like __NR_write system call numbers, for example.

在x86中,有两种不同版本的asm语法:AT& T(由gcc之类的Unix编译器使用)和Intel/NASM(有两种方言,如MASM与NASM本身).

In x86, there are two separate versions of asm syntax: AT&T (used by Unix compilers like gcc), and Intel/NASM (with a couple dialects, like MASM vs. NASM itself).

.S适用于GNU as语法中的asm,无论是否使用任何C预处理器功能.

.S is appropriate for asm in GNU as syntax, whether you use any C preprocessor features or not.

在x86中,.asm通常与Intel语法NASM/YASM或MASM源代码关联.在x86之外,如果它使用

In x86, .asm is more often associated with Intel-syntax NASM/YASM, or MASM, source code. Outside of x86, it's probably a good choice for asm source files that could be assembled by the platform-specific assembler, if it uses different directives than GNU as.

glibc源树对所有asm使用.S源文件.

具有gcc背景的人们可能会将其MIPS组件放入.S.s文件中,而具有更多NASM/YASM经验(或Windows)的人可能会选择.asm.

People with a gcc background might put their MIPS asm into .S or .s files, while people with more NASM/YASM experience (or Windows), might go for .asm.

我建议不要使用.s文件,因为很容易被gcc -S foo.c意外覆盖.

I'd recommend against .s files, because it's easy to accidentally overwrite with gcc -S foo.c.

这篇关于程序集文件:.a .s .asm之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆