什么是x86_64的va_list的结构的格式? [英] What is the format of the x86_64 va_list structure?

查看:406
本文介绍了什么是x86_64的va_list的结构的格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人有在x86_64的为的va_list 重新presentation引用ABI(在Linux上使用的)?我试图调试一些code其中栈或论点似乎损坏,这将真正有助于了解我的应该的要看到...


解决方案

我做了我的意见变成一个答案。

这可能有助于。这是一个参考,虽然轻便。

变量参数列表参考第50页开始,那么它的推移,页52-53证件的va_list


  

所使用的va_list类型


  
  

所使用的va_list类型是数组
  含有一个单一元件
  含有必要的结构
  信息来实现的va_arg
  宏。 va_list的的C-德网络nition
  类型在网络古尔给出3.34


  //图3.34
typedef结构{
   无符号整型gp_offset;
   无符号整型fp_offset;
   无效* overflow_arg_area;
   无效* reg_save_area;
} va_list的[1];


  

va_start宏


  
  

va_start宏初始化
  结构如下:


  
  

reg_save_area 元素点
  该寄存器的起始保存区。


  
  

在佛罗里达州ow_arg_area 此指针用于
  获取上传递的参数
  堆叠。它与初始化
  在第一个参数的地址传递
  栈中,如果有的话,然后总是
  更新为指向的开始
  在栈上一个参数。


  
  

gp_offset 元素持有偏移
  从reg_save_area到字节
  放置在所述下一个可用一般
  目的参数寄存器进行设置。在
  情况下,所有参数寄存器已
  耗尽,它被设置为值48
  (6 * 8)


  
  

fp_offset 元素持有偏移
  从reg_save_area到字节
  把下一个可用的浮动哪里
  点参数寄存器进行设置。在
  情况下,所有参数寄存器已
  耗尽,它被设置为值304
  (6 * 8 + 16 * 16)。


Anyone have a reference for the representation of va_list in the x86_64 ABI (the one used on Linux)? I'm trying to debug some code where the stack or arguments seem corrupt and it would really help to understand what I'm supposed to be seeing...

解决方案

I made my comment into an answer.

This may help. It's a reference, albeit lightweight.

The Variable Argument List reference starts on page 50, then it goes on, page 52-53 documents 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
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).

这篇关于什么是x86_64的va_list的结构的格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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