将堆栈指针引用到syscall的登记册-gnu gas at& t语法

发布于 2025-02-03 04:00:10 字数 1441 浏览 1 评论 0 原文

我正在尝试将我的堆栈指针引用到%rsi 寄存器中,以便SYSCALL将从i的第二个参数中获取结构。

这是代码:

01: mov $0x2a, %al
02 : mov $3, %rdi
03 : push $0x02
04 : push $0x0068
05 : push $0x5c11
06 : push $0xa8c0
07 : push $0x1401
08 : mov (%rsp), %r13
09 : mov %r13, %rsi # this is where I get lost
10 : mov $0x10, %dl
11 : syscall

strace ./helloworld给我这个:

connect(3, 0x5c11, 16)
exit(0)

我的问题是:我如何将堆栈上的结构传递给RSI寄存器(通过堆栈的指针)

到目前为止尝试的内容:

  • 读取有关GNU语法
  • 直接传递参考而无需中间寄存器的 有关GNU语法
      08:#MOV(%RSP),%R13
    09:MOV%RSI,(%RSP)
     
  • 使用指针拆卸
      03:MOV $ 0x02(%RSP)
    04:MOVW $ 0x0068 2(%RSP)
    05:MOVW $ 0x5C11 4(%RSP)
    06:MOVW $ 0XA8C0 6(%RSP)
    07:MOVW $ 0x1401 8(%RSP)
    08:#mov(%RSP),%R13
    09:MOV(%RSP),%RSI
    
    strace ./hellowworld:
    ...
    连接(3,0xA8C05C1100680002,16)
    ...
     

我在第二个论点中每次都有的是寄存器或堆栈的价值,而不是指针。

使用NASM语法,一切都可以。

我正在使用这些资源:

I'm trying to put a reference to my stack pointer into the %rsi register so that the syscall will get the struct from i's second parameter.

here is the code :

01: mov $0x2a, %al
02 : mov $3, %rdi
03 : push $0x02
04 : push $0x0068
05 : push $0x5c11
06 : push $0xa8c0
07 : push $0x1401
08 : mov (%rsp), %r13
09 : mov %r13, %rsi # this is where I get lost
10 : mov $0x10, %dl
11 : syscall

strace ./helloWorld give me this :

connect(3, 0x5c11, 16)
exit(0)

My question is : how can I pass a struct that I have put on the stack to the rsi register (by passing the pointer of the stack)

What I have tryied so far :

  • Reading about GNU syntax
  • passing the reference directly without intermediate register
    08 : #mov (%rsp), %r13
    09 : mov %rsi, (%rsp)
    
  • using pointer deplacement
    03 : mov $0x02 (%rsp)
    04 : movw $0x0068 2(%rsp)
    05 : movw $0x5c11 4(%rsp)
    06 : movw $0xa8c0 6(%rsp)
    07 : movw $0x1401 8(%rsp)
    08 : # mov (%rsp), %r13
    09 : mov (%rsp), %rsi
    
    strace ./hellowWorld:
    ...
    connect(3, 0xa8c05c1100680002, 16)
    ...
    

Every time I have in the second argument is the value of the registers or the stacks, not a pointer.

Using NASM syntax, Everything is ok.

I am using theses resources :

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文