linux – 汇编:为什么跳转到通过ret返回的标签会导致分段错误?

linux – 汇编:为什么跳转到通过ret返回的标签会导致分段错误?,第1张

概述Linux Assembly Tutorial州: there is one very important thing to remember: If you are planning to return from a procedure (with the RET instruction), don’t jump to it! As in “never!” Doing that will cau Linux Assembly Tutorial州:

there is one very important thing to remember: If you are planning to return from a procedure (with the RET instruction),don’t jump to it! As in “never!” Doing that will cause a segmentation fault on linux (which is OK – all your program does is terminate),but in DOS it may blow up in your face with varIoUs degrees of terribleness.

但我无法理解为什么它会导致分段错误.听起来就像从函数返回一样.

我有一种情况需要实现逻辑“如果X发生,调用程序A.否则,调用程序B.”除了袋鼠编织意大利面条代码之外还有其他方式吗?

解决方法 因为CALL将当前指令地址压入堆栈,并且RET将其拉出以便返回到调用站点. JMP(和相关指令)不会将任何内容压入堆栈. 总结

以上是内存溢出为你收集整理的linux – 汇编:为什么跳转到通过ret返回的标签会导致分段错误?全部内容,希望文章能够帮你解决linux – 汇编:为什么跳转到通过ret返回的标签会导致分段错误?所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存