This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ll _exit /* returns control to OS */ /* control never reaches here */ Figure 7.14: Pseudo-code for the crt1.o startup routine in every C program. Note: The code that pushes the arguments for each function is not shown. 374 CHAPTER 7. LINKING
Aside: How do loaders really work? Our description of loading is conceptually correct, but intentionally not entirely accurate. To understand how loading really works, you must understand concepts of processes, virtual memory, and memory mapping that we haven’t discussed yet. As we encounter these concepts later in Chapters 8 and 10, we will revisit loading and gradually reveal the mystery to you. For the impatient reader, here is a preview of how loading really works: Each program in a Unix system runs in the context of a process with its own virtual address space. When the shell runs a program, the parent shell process forks a child process that is a duplicate of the parent. The child process invokes the loader via the execve system call. The l...
View Full Document