gpt4 book ai didi

c - x86_64 va_list结构的格式是什么?

转载 作者:IT王子 更新时间:2023-10-29 00:18:05 26 4
gpt4 key购买 nike

有人知道 x86_64 ABI(在 Linux 上使用的那个)中 va_list 的表示形式吗?我正在尝试调试一些堆栈或参数似乎已损坏的代码,这确实有助于理解我应该看到的内容......

最佳答案

The x86-64 System V ABi doc may help .这是一个引用,尽管很轻。

变量参数列表引用从第 54 页开始,然后继续,第 56-57 页文档 va_list:

The va_list Type

The va_list type is an array containing a single element of one structure containing the necessary information to implement the va_arg macro. The C definition of va_list type is given in figure 3.34.

Figure 3.34: va_list Type Declaration

typedef struct {
unsigned int gp_offset;
unsigned int fp_offset;
void *overflow_arg_area;
void *reg_save_area;
} va_list[1];

The va_start Macro

The va_start macro initializes the structure as follows:

reg_save_area The element points to the start of the register save area.

overflow_arg_area This pointer is used to fetch arguments passed on the stack. It is initialized with the address of the first argument passed on the stack, if any, and then always updated to point to the start of the next argument on the stack.

gp_offset The element holds the offset in bytes from reg_save_area to the place where the next available general purpose argument register is saved. In case all argument registers have been exhausted, it is set to the value 48 (6 * 8).

fp_offset The element holds the offset in bytes from reg_save_area to the place where the next available floating point argument register is saved. In case all argument registers have been exhausted, it is set to the value 304 (6 * 8 + 16 * 16).

关于c - x86_64 va_list结构的格式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4958384/

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