user123
user123

Reputation: 2884

Does the stack pointer contain a virtual address or a physical address once long mode and paging is enabled on x86-64

I'm writing a minimal OS from scratch. I enabled paging and long mode but when I want to set up the stack I have a few questions.

  1. Does the stack pointer contain a virtual address automatically translated to physical address by the MMU when using PUSH, POP instructions?

  2. Is the position of the stack mentionned in and ELF file?

Upvotes: 1

Views: 652

Answers (1)

Florian Weimer
Florian Weimer

Reputation: 33704

The stack pointer must be a virtual address once paging is enabled.

The standard x86-64 psABI does not specify the initial value for the stack pointer, so it does not show up in ELF files. The most common program loader (Linux) randomizes the stack address by default.

Upvotes: 2

Related Questions