> 文章列表 > GCC-march -mabi

GCC-march -mabi

GCC-march -mabi

GCC编译器

常用选项
​​-E​​:只进行预处理,不编译
​​-S​​:只编译,不汇编
​​-c​​:只编译、汇编,不链接
​-g​​:包含调试信息
​​-I​​:指定include包含文件的搜索目录
​​-o​​:输出成指定文件名

GCC参数详解

RISC-V基本介绍

https://blog.csdn.net/lijianyi0219/article/details/122634356

RISCV 入门

RISC-V数据模型,-mabi

https://blog.51cto.com/zoomdy/5871699
RISC-V GCC 使用手册对​​-mabi​​选项的说明:
-mabi=ABI-string
.
Specify integer and floating-point calling convention. ABI-string contains two parts: the size of integer types and the registers used for floating-point types. For example -march=rv64ifd -mabi=lp64d means that long and pointers are 64-bit (implicitly defining int to be 32-bit), and that floating-point values up to 64 bits wide are passed in F registers. Contrast this with -march=rv64ifd -mabi=lp64f, which still allows the compiler to generate code that uses the F and D extensions but only allows floating-point values up to 32 bits long to be passed in registers; or -march=rv64ifd -mabi=lp64, in which no floating-point arguments will be passed in registers.

指定整数和浮点调用约定。ABI字符串包含两部分:整数类型的大小和用于浮点类型的寄存器。例如,-march=rv64ifd-mabi=lp64d意味着long和指针是64位的(隐式地将int定义为32位),并且在F寄存器中传递高达64位宽的浮点值。
与之形成对比的是 -march=rv64ifd-mabi=lp64f,它仍然允许编译器生成使用F和D扩展的代码,但只允许在寄存器中传递长达32位的浮点值;或-march=rv64ifd-mabi=lp64,其中不会在寄存器中传递浮点参数。
.
The default for this argument is system dependent, users who want a specific calling convention should specify one explicitly. The valid calling conventions are: ilp32, ilp32f, ilp32d, lp64, lp64f, and lp64d. Some calling conventions are impossible to implement on some ISAs: for example, -march=rv32if -mabi=ilp32d is invalid because the ABI requires 64-bit values be passed in F registers, but F registers are only 32 bits wide.
此参数的默认值取决于系统,需要特定调用约定的用户应明确指定一个。有效的调用约定有:ilp32、ilp32f、ilp32d、lp64、lp64f和lp64d。有些调用约定无法在某些ISAs上实现:例如,-march=rv32if-mabi=ilp32d无效,因为ABI要求在F寄存器中传递64位值,但F寄存器只有32位宽。


ABI协议规定了寄存器、堆栈的使用规则以及参数传递规则。用于约束硬件与系统之间的通信协议。编译器必须按照ABI给出的寄存器功能定义,将C程序转为汇编程序。
寄存器是唯一能被被所有函数共享的资源。因此,在函数中调用其它函数时,需要考虑到数据的保存与覆盖问题(即防止被调函数直接修改寄存器导致主调函数的数据被覆盖)。

IA32采用了统一的寄存器使用约定,所有函数必须遵守。

C语言函数调用底层实现原理

参数的传递规则