Why does not XORing %eax causes segfault? [duplicate]

别等时光非礼了梦想. 提交于 2020-06-17 13:21:25

问题


.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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!