汇编基础-函数返回值超过8个字节

2021-03-26  本文已影响0人  spyn_n

struct str {     int a;     int b;     int c;     int d;     int f;     int g; };  // 结构体声明

struct str getStr(int a, int b, int c, int d, int f, int g){    // 函数实现

//    //24字节开辟堆空间!

//  struct str * str1 = malloc(24);

    struct str str1;

    str1.a= a;

    str1.b= b;

    str1.c= c;

    str1.d= d;

    str1.f= f;

    str1.g= g;

    returnstr1;

}

调用函数struct str str2 = getStr(1, 2, 3, 4, 5, 6);

x8寄存器指向sp+#0x8的地址,为了给getStr函数操作这个寄存器(夸栈操作)

然后我们可以验证一下我们分析的对不对,我们查看一下X8寄存器的地址x8 = 0x000000016f258ee8,po一下这个地址是6159699688,对应到数据如图,正好跟我们分析的一样,将1,2,3,4,5,6以X8寄存器为基准,每1个字节放数据。

所以我们可以断定X8的地址应该是str2变量指向的地址空间,在getStr函数调用时,完成入栈操作。

以上是个人看法,不对的地方,欢迎大佬指正。

上一篇 下一篇

猜你喜欢

热点阅读