2 years ago

#29212

test-img

xperious

why call glibc function crash without xor %rax, %rax?

i call glibc function, for example, printf:

mov $some_string, %rdi
call printf   //<----crash

in some cases, such a call will crash. I add xor %rax, %rax this solves the problem.

I have two questions:

  1. Why, in some cases, calling printf without xor %rax leads to a crash, and in some it does not?

  2. Somewhere I saw such a call printf:

    lea  some_string(%rip), %rdi
    xor %eax, %eax
    call printf
    

Why this used rip register and how is this passing of an argument different from the usual?

assembly

x86-64

calling-convention

0 Answers

Your Answer

Accepted video resources