手臂.从超级用户模式访问用户 R13 和 R14 [英] ARM. Access user R13 and R14 from Supervisor mode

查看:17
本文介绍了手臂.从超级用户模式访问用户 R13 和 R14的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何访问进入管理员模式时保存的用户 R13 和 R14?我正在使用 ARM7TDMI.

How do I access the user R13 and R14 which are saved when supervisor mode is entered? I am using an ARM7TDMI.

I.E.我不想访问现在包含用户模式返回地址的主管 R14,而是想要用户模式链接寄存器的值.这是我正在编写的调试器的一部分.

I.E. I do not want to access supervisor R14 which now contains the return address to user mode, instead want the value of user mode's link register. This is part of a debugger I am writing.

这些寄存器有特殊的别名吗?

Are there special aliases for these registers?

谢谢

推荐答案

我会针对您的具体问题描述答案,但同样的方法也适用于其他模式.

I'll describe the answer for your specific question but the same approach applies to other modes as well.

您需要通过将 CPSR 中的模式位更改为系统模式来更改处理器模式.这将使您能够访问用户模式的 SP/LR (R13 & R14).请记住,系统模式是特权模式,但其 R13 和 R14 与用户模式的 R13 和 R14 相同.

You'll need to change the processor mode by changing the mode bits in the CPSR to system mode. This will give you access to user mode's SP/LR (R13 & R14). Remember that system mode is privileged, but its R13 and R14 are the same as user mode's R13 and R14.

进入系统模式后,阅读 R13 和 R14 并将它们放在您想要的位置.然后只需将模式位切换回之前的模式(我相信在您的示例中是主管模式),您就可以开始了.

Once you're in system mode, read R13 and R14 and put them where you want. Then just switch the mode bits back to your previous mode (I believe that was supervisor mode in your example) and you're good to go.

请注意,我们没有从主管模式切换到用户模式.如果您从主管模式切换到用户模式,您将无法返回主管模式.(否则将无法保护用户代码提升权限).这就是我们使用系统模式的原因——系统模式是特权模式,但寄存器与用户模式相同.

Note that we did not switch from supervisor to user mode. If you switched from supervisor to user, you couldn't get back to supervisor mode. (Otherwise there would be no protection from user code escalating privilege). That's why we used system mode -- system mode is privileged, but the registers are the same as user mode.

您可以通过操作 CPSR 中的模式位随意在任何特权模式之间切换.我认为它们是低 5 位?我在路上&没有我指尖的信息.否则我会为您提供我上面描述的汇编代码.实际上,如果你想在你的胸前留一些头发,就拿我上面给你的东西,实施它,测试它,然后把它贴回这里.:-D

You can switch between any of the privileged modes at will by manipulating the mode bits in the CPSR. I think they're the lower 5 bits? I'm on the road & don't have the info at my fingertips. Otherwise I would have provided you with the assembly code for what I've described above. Actually, if you want to put some hair on your chest, take what I've given you above, implement it, test it, and post it back here. :-D

(我应该为一般情况"添加一件事(您的情况非常具体)——您可以检查 SPSR 以查看您来自哪里"——并使用它来确定您需要切换到哪种模式.)

(One thing I should add for the "general case" (yours is very specific) -- you can examine the SPSR to see "where you came from" -- and use that to determine which mode you need to switch to.)

顺便说一句,我最近刚为我的一位客户做过这件事......我猜是小世界.

By the way, I just did this recently for one of my customers.... small world, I guess.

这篇关于手臂.从超级用户模式访问用户 R13 和 R14的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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