问题
.text
having this:
str:
.string "string"
.globl main
main:
xor %eax, %eax #is commented causes segfault
leaq str(%rip), %rdi
call printf
xorq %rdi, %rdi
call exit
Does printf uses %rax
? or is the segfault caused by str(%rip)
? As how i understand in -> leaq str(%rip)
uses address at register %rip
+str. But str is address, not value (like +4,8 or 16...), then what does the leaq str(%rip)
gain?
Compiled as $cc foo.s
.
来源:https://stackoverflow.com/questions/62196157/why-does-not-xoring-eax-causes-segfault