Error[8]: Undefined offset: 10, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述源代码:1 int func() 2 { 3 int a = 0x12345678; 4 int *p = &a; 5 return *p; 6 } 8 int main() 9 { 10 int b = 0x8

源代码:

1       int func()2       {3           int a = 0x12345678;4           int *p = &a;5           return *p;6       }8       int main()9       {10          int b = 0x87654321;11          return b + func();12      }

拆卸:

(gdb) disass mainDump of assembler code for function main():0x0000000000400544 "0x000000000040052c linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64x12345678,-0xc(%rbp)" comes.x10,%rsp0x000000000040054c 0x0000000000400544 #include x10,%rsp   <== ?x87654321,-0x4(%rbp)0x0000000000400553 $gcc -std=c99 -Wall -pedantic -o sample sample.c$./sample84x12345678,-0xc(%rbp)  <=how -0xc comes?0x0000000000400533 

我的问题是后续行中的0xc如何

0x0000000000400528 

我的理解是:0x12345678对于变量a占用4个字节,对于指针p占用4个字节,其余4个字节用于什么?

谢谢.

编辑:

0x000000000040052c 0x0000000000400533 x12345678,-0xc(%rbp)  <=how -0xc comes?+..........+| RET ADDR | (from CALL)+----------+|RBP (high)|+..........||RBP (low) | <== RSP,RBP+----------+|          | <== -0x4(%rbp) -\+..........+                  \__ int *p|          | <== -0x8(%rbp)   /+----------+                -/|0x12345678| <== -0xc(%rbp)       int a+----------+

编辑1 ::
还有一个问题:
以下是什么?

函数main()的汇编代码转储:

[+++]

编辑2:
为什么main()需要与16个字节对齐(“sub $0x10,%rsp”)而func不是(0x0c没有对齐,对吧?)?最佳答案

linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64

… followed by 4 bytes for pointer “p” …

您使用的是64位架构,因此指针占用64位= 8个字节:

[+++]
[+++]

详细的堆栈分析:

当输入func()时,在执行前两条指令后,堆栈看起来像这样(假设每个矩形是4字节的内存):

[+++]

然后,您将值存储到本地变量中:

[+++]

然后,您将64位指针存储到p变量中:

[+++]
总结

以上是内存溢出为你收集整理的如何抵消堆叠?全部内容,希望文章能够帮你解决如何抵消堆叠?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 11, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述源代码:1 int func() 2 { 3 int a = 0x12345678; 4 int *p = &a; 5 return *p; 6 } 8 int main() 9 { 10 int b = 0x8

源代码:

1       int func()2       {3           int a = 0x12345678;4           int *p = &a;5           return *p;6       }8       int main()9       {10          int b = 0x87654321;11          return b + func();12      }

拆卸:

(gdb) disass mainDump of assembler code for function main():0x0000000000400544 "0x000000000040052c linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64x12345678,-0xc(%rbp)" comes.x10,%rsp0x000000000040054c 0x0000000000400544 #include x10,%rsp   <== ?x87654321,-0x4(%rbp)0x0000000000400553 $gcc -std=c99 -Wall -pedantic -o sample sample.c$./sample84x12345678,-0xc(%rbp)  <=how -0xc comes?0x0000000000400533 

我的问题是后续行中的0xc如何

0x0000000000400528 

我的理解是:0x12345678对于变量a占用4个字节,对于指针p占用4个字节,其余4个字节用于什么?

谢谢.

编辑:

0x000000000040052c 0x0000000000400533 x12345678,-0xc(%rbp)  <=how -0xc comes?+..........+| RET ADDR | (from CALL)+----------+|RBP (high)|+..........||RBP (low) | <== RSP,RBP+----------+|          | <== -0x4(%rbp) -\+..........+                  \__ int *p|          | <== -0x8(%rbp)   /+----------+                -/|0x12345678| <== -0xc(%rbp)       int a+----------+

编辑1 ::
还有一个问题:
以下是什么?

函数main()的汇编代码转储:

编辑2:
为什么main()需要与16个字节对齐(“sub $0x10,%rsp”)而func不是(0x0c没有对齐,对吧?)?最佳答案

linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64

… followed by 4 bytes for pointer “p” …

您使用的是64位架构,因此指针占用64位= 8个字节:

[+++]
[+++]

详细的堆栈分析:

当输入func()时,在执行前两条指令后,堆栈看起来像这样(假设每个矩形是4字节的内存):

[+++]

然后,您将值存储到本地变量中:

[+++]

然后,您将64位指针存储到p变量中:

[+++]
总结

以上是内存溢出为你收集整理的如何抵消堆叠?全部内容,希望文章能够帮你解决如何抵消堆叠?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 12, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述源代码:1 int func() 2 { 3 int a = 0x12345678; 4 int *p = &a; 5 return *p; 6 } 8 int main() 9 { 10 int b = 0x8

源代码:

1       int func()2       {3           int a = 0x12345678;4           int *p = &a;5           return *p;6       }8       int main()9       {10          int b = 0x87654321;11          return b + func();12      }

拆卸:

(gdb) disass mainDump of assembler code for function main():0x0000000000400544 "0x000000000040052c linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64x12345678,-0xc(%rbp)" comes.x10,%rsp0x000000000040054c 0x0000000000400544 #include x10,%rsp   <== ?x87654321,-0x4(%rbp)0x0000000000400553 $gcc -std=c99 -Wall -pedantic -o sample sample.c$./sample84x12345678,-0xc(%rbp)  <=how -0xc comes?0x0000000000400533 

我的问题是后续行中的0xc如何

0x0000000000400528 

我的理解是:0x12345678对于变量a占用4个字节,对于指针p占用4个字节,其余4个字节用于什么?

谢谢.

编辑:

0x000000000040052c 0x0000000000400533 x12345678,-0xc(%rbp)  <=how -0xc comes?+..........+| RET ADDR | (from CALL)+----------+|RBP (high)|+..........||RBP (low) | <== RSP,RBP+----------+|          | <== -0x4(%rbp) -\+..........+                  \__ int *p|          | <== -0x8(%rbp)   /+----------+                -/|0x12345678| <== -0xc(%rbp)       int a+----------+

编辑1 ::
还有一个问题:
以下是什么?

函数main()的汇编代码转储:

编辑2:
为什么main()需要与16个字节对齐(“sub $0x10,%rsp”)而func不是(0x0c没有对齐,对吧?)?最佳答案

linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64

… followed by 4 bytes for pointer “p” …

您使用的是64位架构,因此指针占用64位= 8个字节:

[+++]

详细的堆栈分析:

当输入func()时,在执行前两条指令后,堆栈看起来像这样(假设每个矩形是4字节的内存):

[+++]

然后,您将值存储到本地变量中:

[+++]

然后,您将64位指针存储到p变量中:

[+++]
总结

以上是内存溢出为你收集整理的如何抵消堆叠?全部内容,希望文章能够帮你解决如何抵消堆叠?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 13, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述源代码:1 int func() 2 { 3 int a = 0x12345678; 4 int *p = &a; 5 return *p; 6 } 8 int main() 9 { 10 int b = 0x8

源代码:

1       int func()2       {3           int a = 0x12345678;4           int *p = &a;5           return *p;6       }8       int main()9       {10          int b = 0x87654321;11          return b + func();12      }

拆卸:

(gdb) disass mainDump of assembler code for function main():0x0000000000400544 "0x000000000040052c linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64x12345678,-0xc(%rbp)" comes.x10,%rsp0x000000000040054c 0x0000000000400544 #include x10,%rsp   <== ?x87654321,-0x4(%rbp)0x0000000000400553 $gcc -std=c99 -Wall -pedantic -o sample sample.c$./sample84x12345678,-0xc(%rbp)  <=how -0xc comes?0x0000000000400533 

我的问题是后续行中的0xc如何

0x0000000000400528 

我的理解是:0x12345678对于变量a占用4个字节,对于指针p占用4个字节,其余4个字节用于什么?

谢谢.

编辑:

0x000000000040052c 0x0000000000400533 x12345678,-0xc(%rbp)  <=how -0xc comes?+..........+| RET ADDR | (from CALL)+----------+|RBP (high)|+..........||RBP (low) | <== RSP,RBP+----------+|          | <== -0x4(%rbp) -\+..........+                  \__ int *p|          | <== -0x8(%rbp)   /+----------+                -/|0x12345678| <== -0xc(%rbp)       int a+----------+

编辑1 ::
还有一个问题:
以下是什么?

函数main()的汇编代码转储:

编辑2:
为什么main()需要与16个字节对齐(“sub $0x10,%rsp”)而func不是(0x0c没有对齐,对吧?)?最佳答案

linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64

… followed by 4 bytes for pointer “p” …

您使用的是64位架构,因此指针占用64位= 8个字节:

详细的堆栈分析:

当输入func()时,在执行前两条指令后,堆栈看起来像这样(假设每个矩形是4字节的内存):

[+++]

然后,您将值存储到本地变量中:

[+++]

然后,您将64位指针存储到p变量中:

[+++]
总结

以上是内存溢出为你收集整理的如何抵消堆叠?全部内容,希望文章能够帮你解决如何抵消堆叠?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 14, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述源代码:1 int func() 2 { 3 int a = 0x12345678; 4 int *p = &a; 5 return *p; 6 } 8 int main() 9 { 10 int b = 0x8

源代码:

1       int func()2       {3           int a = 0x12345678;4           int *p = &a;5           return *p;6       }8       int main()9       {10          int b = 0x87654321;11          return b + func();12      }

拆卸:

(gdb) disass mainDump of assembler code for function main():0x0000000000400544 "0x000000000040052c linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64x12345678,-0xc(%rbp)" comes.x10,%rsp0x000000000040054c 0x0000000000400544 #include x10,%rsp   <== ?x87654321,-0x4(%rbp)0x0000000000400553 $gcc -std=c99 -Wall -pedantic -o sample sample.c$./sample84x12345678,-0xc(%rbp)  <=how -0xc comes?0x0000000000400533 

我的问题是后续行中的0xc如何

0x0000000000400528 

我的理解是:0x12345678对于变量a占用4个字节,对于指针p占用4个字节,其余4个字节用于什么?

谢谢.

编辑:

0x000000000040052c 0x0000000000400533 x12345678,-0xc(%rbp)  <=how -0xc comes?+..........+| RET ADDR | (from CALL)+----------+|RBP (high)|+..........||RBP (low) | <== RSP,RBP+----------+|          | <== -0x4(%rbp) -\+..........+                  \__ int *p|          | <== -0x8(%rbp)   /+----------+                -/|0x12345678| <== -0xc(%rbp)       int a+----------+

编辑1 ::
还有一个问题:
以下是什么?

函数main()的汇编代码转储:

编辑2:
为什么main()需要与16个字节对齐(“sub $0x10,%rsp”)而func不是(0x0c没有对齐,对吧?)?最佳答案

linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64

… followed by 4 bytes for pointer “p” …

您使用的是64位架构,因此指针占用64位= 8个字节:

详细的堆栈分析:

当输入func()时,在执行前两条指令后,堆栈看起来像这样(假设每个矩形是4字节的内存):

然后,您将值存储到本地变量中:

[+++]

然后,您将64位指针存储到p变量中:

[+++]
总结

以上是内存溢出为你收集整理的如何抵消堆叠?全部内容,希望文章能够帮你解决如何抵消堆叠?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 15, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述源代码:1 int func() 2 { 3 int a = 0x12345678; 4 int *p = &a; 5 return *p; 6 } 8 int main() 9 { 10 int b = 0x8

源代码:

1       int func()2       {3           int a = 0x12345678;4           int *p = &a;5           return *p;6       }8       int main()9       {10          int b = 0x87654321;11          return b + func();12      }

拆卸:

(gdb) disass mainDump of assembler code for function main():0x0000000000400544 "0x000000000040052c linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64x12345678,-0xc(%rbp)" comes.x10,%rsp0x000000000040054c 0x0000000000400544 #include x10,%rsp   <== ?x87654321,-0x4(%rbp)0x0000000000400553 $gcc -std=c99 -Wall -pedantic -o sample sample.c$./sample84x12345678,-0xc(%rbp)  <=how -0xc comes?0x0000000000400533 

我的问题是后续行中的0xc如何

0x0000000000400528 

我的理解是:0x12345678对于变量a占用4个字节,对于指针p占用4个字节,其余4个字节用于什么?

谢谢.

编辑:

0x000000000040052c 0x0000000000400533 x12345678,-0xc(%rbp)  <=how -0xc comes?+..........+| RET ADDR | (from CALL)+----------+|RBP (high)|+..........||RBP (low) | <== RSP,RBP+----------+|          | <== -0x4(%rbp) -\+..........+                  \__ int *p|          | <== -0x8(%rbp)   /+----------+                -/|0x12345678| <== -0xc(%rbp)       int a+----------+

编辑1 ::
还有一个问题:
以下是什么?

函数main()的汇编代码转储:

编辑2:
为什么main()需要与16个字节对齐(“sub $0x10,%rsp”)而func不是(0x0c没有对齐,对吧?)?最佳答案

linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64

… followed by 4 bytes for pointer “p” …

您使用的是64位架构,因此指针占用64位= 8个字节:

详细的堆栈分析:

当输入func()时,在执行前两条指令后,堆栈看起来像这样(假设每个矩形是4字节的内存):

然后,您将值存储到本地变量中:

然后,您将64位指针存储到p变量中:

[+++]
总结

以上是内存溢出为你收集整理的如何抵消堆叠?全部内容,希望文章能够帮你解决如何抵消堆叠?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
如何抵消堆叠?_系统运维_内存溢出

如何抵消堆叠?

如何抵消堆叠?,第1张

概述源代码:1 int func() 2 { 3 int a = 0x12345678; 4 int *p = &a; 5 return *p; 6 } 8 int main() 9 { 10 int b = 0x8

源代码:

1       int func()2       {3           int a = 0x12345678;4           int *p = &a;5           return *p;6       }8       int main()9       {10          int b = 0x87654321;11          return b + func();12      }

拆卸:

(gdb) disass mainDump of assembler code for function main():0x0000000000400544 "0x000000000040052c linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64x12345678,-0xc(%rbp)" comes.x10,%rsp0x000000000040054c 0x0000000000400544 #include x10,%rsp   <== ?x87654321,-0x4(%rbp)0x0000000000400553 $gcc -std=c99 -Wall -pedantic -o sample sample.c$./sample84x12345678,-0xc(%rbp)  <=how -0xc comes?0x0000000000400533 

我的问题是后续行中的0xc如何

0x0000000000400528 

我的理解是:0x12345678对于变量a占用4个字节,对于指针p占用4个字节,其余4个字节用于什么?

谢谢.

编辑:

0x000000000040052c 0x0000000000400533 x12345678,-0xc(%rbp)  <=how -0xc comes?+..........+| RET ADDR | (from CALL)+----------+|RBP (high)|+..........||RBP (low) | <== RSP,RBP+----------+|          | <== -0x4(%rbp) -\+..........+                  \__ int *p|          | <== -0x8(%rbp)   /+----------+                -/|0x12345678| <== -0xc(%rbp)       int a+----------+

编辑1 ::
还有一个问题:
以下是什么?

函数main()的汇编代码转储:

编辑2:
为什么main()需要与16个字节对齐(“sub $0x10,%rsp”)而func不是(0x0c没有对齐,对吧?)?最佳答案

linux 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64

… followed by 4 bytes for pointer “p” …

您使用的是64位架构,因此指针占用64位= 8个字节:

详细的堆栈分析:

当输入func()时,在执行前两条指令后,堆栈看起来像这样(假设每个矩形是4字节的内存):

然后,您将值存储到本地变量中:

然后,您将64位指针存储到p变量中:

          总结       

以上是内存溢出为你收集整理的如何抵消堆叠?全部内容,希望文章能够帮你解决如何抵消堆叠?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1046782.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)