加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

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

发布时间:2020-12-13 23:50:38 所属栏目:Linux 来源:网络整理
导读: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 (w
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(和相关指令)不会将任何内容压入堆栈.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读