是否可以将堆栈上的元素克隆到X86_64 Linux组装中的堆栈上?

发布于 2025-02-11 16:22:23 字数 402 浏览 1 评论 0原文

基本上您可以“删除”元素 通过添加到rsp注册来从堆栈中 n * 8,但是如果您尝试对面(rsp-(n * 8)) 它不起作用,这似乎很明显,但是

如果我使用按下这样的堆栈,

push 10
push 20

那么堆栈基本上是(20; 10),如何怎么办我做到了 (20; 10; 20; 10)无需使用寄存器(因为您有限) 或需要重复push

但是如果不可能,最好将其用作替代方案, 重复push或使用pop使用寄存器,然后按 他们回来了?

Basically you can 'remove' elements
from the stack by adding to rsp register
n * 8, but if you try the opposite (rsp - (n * 8))
it doesn't work, which seems obvious but still

So if I push to the stack using push like this:

push 10
push 20

So the stack is basically (20; 10), how could I make it
(20; 10; 20; 10) without needing to use registers (Because you're limited)
or needing to repeat the push

But if it's not possible which is better to use as an alternative,
repeating the push or using registers using pop and then pushing
them back?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心如狂蝶 2025-02-18 16:22:23

假设npush ed值是恒定的:

  • 您的问题用 x86-64 ,因此我认为默认操作数尺寸当前设置为64位。
    您的推动IMM8正在推动签名扩展的四字。
    除非您确实在堆栈上需要四字,否则如何将8  nbsp; nbsp; byte值放在堆栈上:

      push((10 * 0x100 + 20) * 0x100 + 10) * 0x100 + 20
    mov [rsp + 4],dword((10 * 0x100 + 20) * 0x100 + 10) * 0x100 + 20
     

    NB:
    在远程模式下,不可能仅按IMM32,因此rsp  nbsp; rsp  -   4,因此mov

  • 如果您只想避免一遍又一遍地拥有相同的常数:
     按1234
    推5678
    ;第一个副本
    推q字[RSP + 8]
    推q字[RSP + 8]
    ;第二份副本
    推q字[RSP + 8]
    推q字[RSP + 8]
     
  • 对于推动IMM8 s,但是,我只选择汇编器的扩展功能:
     重复3
        推10
        推20
    结束重复
     

Assuming n and the pushed values are constant:

  • Your question is tagged with , so I presume the default operand size is currently set to 64 bits.
    Your push imm8 is pushing sign-extended quadwords.
    Unless you really need quadwords on the stack, how about putting 8 individual Byte values on the stack:

    push ((10 * 0x100 + 20) * 0x100 + 10) * 0x100 + 20
    mov [rsp + 4], dword ((10 * 0x100 + 20) * 0x100 + 10) * 0x100 + 20
    

    NB:
    In long mode it is not possible to just push imm32 so that rsp ≔ rsp − 4, hence the mov.

  • If you just want to avoid having the same constants over and over again:
    push 1234
    push 5678
    ; first copy
    push qword [rsp + 8]
    push qword [rsp + 8]
    ; second copy
    push qword [rsp + 8]
    push qword [rsp + 8]
    
  • For push imm8s, however, I would simply opt for the assembler’s expansion capability:
    repeat 3
        push 10
        push 20
    end repeat
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文