2

Possible Duplicate:
What is default register state when program launches (asm, linux)?

I know the %esp and %eip should set to proper values by the OS kernel, so that the program can run, but other registers including %ebp,%eax,%ebx,%ecx,%edx,%esi,%edi. Does OS kernel initialize them before a program running? What values should they have?

What's the value should %esp have when a program starts running?

Community
  • 1
  • 1
venus.w
  • 2,171
  • 7
  • 28
  • 42
  • To what would kernel initialize them and why? I guess they are initialized as they are used, according to your source code. – dbrank0 May 15 '12 at 06:42

1 Answers1

1

If you ask about a C program - you can't know, it isn't your business.

For assembly, I also don't think they have meaningful values.
The information needed to execute main - the argument count, argument vector and environment pointer - is all on the stack.

See more info in this Linux Gazette article.

ugoren
  • 16,023
  • 3
  • 35
  • 65
  • I believe the value stored inside should be the values of the last memory page, or the last parallel process executed before the processor swapped to this (new) process, so to speak. It should be possible to read specific run-time-states of other processes on this assumption, but I'm not sure about – clockw0rk Oct 02 '19 at 13:26