0

I have written a small syscall function in NASM that works so far.

global _start
section .text
_start:
  mov rcx, text
  mov rdx, 7
  mov rbx, 1
  mov rax, 4
  int 0x80
  mov rax, 1
  mov rbx, 0
  int 0x80
  text:
  db "ABCDEFG",0x0a

This give me the output : ABCDEFG

When i use this way:

global _start
section .text
_start:
  mov rcx, 0x0a47464544434241
  push rcx
  mov rcx, rsp
  mov rdx, 7
  mov rbx, 1
  mov rax, 4
  int 0x80
  mov rax, 1
  mov rbx, 0
  int 0x80

This version prints nothing :( Can anyone tell me exactly why this is? I have already spent a few hours in the debugger but without success.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • I hope you got as far in the debugger or `strace` as noticing that your system calls returned `-EFAULT` (bad pointer), when you passed a 64-bit (stack) pointer to the 32-bit ABI. – Peter Cordes Nov 15 '21 at 16:43
  • Hi, exactly this "EFAULT" error I get :/ Can you tell me exactly how to work around this or why this problem occurs exactly? I am still a bit new in the field. Thanks a lot – 0ok3rn3lp4n1co0 Nov 15 '21 at 16:52
  • 1
    Look at the "duplicate" link at the top of this page. I already wrote a whole giant answer about exactly what's going on here. – Peter Cordes Nov 15 '21 at 16:59

0 Answers0