Segfault when loading from [esp] in 64-bit code

后端 未结 1 1231
别跟我提以往
别跟我提以往 2020-12-21 20:16

I\'m quite new to x86 assembly, and I\'m trying to build off a hello world program. I\'m trying to make a subroutine, that writes a single byte to stdout, but i\'ve hit a pr

相关标签:
1条回答
  • 2020-12-21 20:44

    I'm in x64 mode, and like a bunch of people suggested in the comments using mov ebx, [rsp+8] worked, because esp are just the 4 lower bytes of the register. The stack is outside the low 4 GiB of virtual address space, so ESP != RSP and [esp] will be an unmapped page.

    Note that x86-64 calling conventions pass the first few args in register, not on the stack, so you normally don't want to do this at all (unless your function has lots of args).

    0 讨论(0)
提交回复
热议问题