This preview shows page 1. Sign up to view the full content.
Unformatted text preview: The startup code sets up the stack and passes control to the main routine of the new program, which has a prototype of the form
int main(int argc, char **argv, char **envp); or equivalently 416
envp envp envp envp ... envp[n-1] NULL CHAPTER 8. EXCEPTIONAL CONTROL FLOW "PWD=/usr/droh" "PRINTER=iron" "USER=droh" Figure 8.18: Organization of an environment variable list.
int main(int argc, char *argv, char *envp); When main begins executing on a Linux system, the user stack has the organization shown in Figure 8.19. Let’s work our way from the bottom of the stack (the highest address) to the top (the lowest address). First
0xbfffffff null-terminated environment variable strings null-terminated command-line arg strings (unused) envp[n] == NULL envp[n-1] bottom of stack ...
envp argv[argc] = NULL argv[argc-1] environ ...
argv (dynamic linker variables) envp argv argc
0xbffffa7c stack frame for main top of stack Figure 8.19: Typical organization of the user stack when a ne...
View Full Document
This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.
- Spring '10
- The American