Section 4.13. Launching the Kernel


4.13. Launching the Kernel

In Chapter 5, we will discuss system startup from the point where the kernel begins to execute. Let us briefly examine the kernel binary to determine the starting point of the kernelthat is, the point at which BootX transfers control.

The Mac OS X kernel is a Mach-O executable. Recall from Chapter 2 that we can use the otool command-line program to view a Mach-O executable's header and load commands.

$ file /mach_kernel /mach_kernel: Mach-O executable ppc $ otool -hv /mach_kernel /mach_kernel: Mach header       magic cputype cpusubtype   filetype ncmds sizeofcmds      flags    MH_MAGIC     PPC        ALL    EXECUTE     9       2360   NOUNDEFS $ otool -l /mach_kernel /mach_kernel: Load command 0       cmd LC_SEGMENT   cmdsize 532   segname __TEXT    vmaddr 0x0000e000    vmsize 0x0034f000 ... Load command 2       cmd LC_SEGMENT   cmdsize 124   segname __VECTORS    vmaddr 0x00000000    vmsize 0x00007000   fileoff 3624960  filesize 28672   maxprot 0x00000007  initprot 0x00000003    nsects 1     flags 0x0 Section   sectname __interrupts    segname __VECTORS       addr 0x00000000       size 0x00007000     offset 3624960      align 2^12 (4096)     reloff 0     nreloc 0      flags 0x00000000  reserved1 0  reserved2 0 ... Load command 8         cmd LC_UNIXTHREAD     cmdsize 176      flavor PPC_THREAD_STATE       count PPC_THREAD_STATE_COUNT ... srr0 0x00092340 srr1 0x00000000


The SRR0 register contains the value 0x00092340 in the initial thread state of this particular kernel. The code at this address is the entry point of the kernel. We can use nm to determine the symbol, if any, that has this address.

$ nm /mach_kernel | grep 00092340 00092340 T __start





Mac OS X Internals. A Systems Approach
Mac OS X Internals: A Systems Approach
ISBN: 0321278542
EAN: 2147483647
Year: 2006
Pages: 161
Authors: Amit Singh

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net