XNU

From OSx86
Jump to: navigation, search

XNU is the Darwin kernel. XNU stands for X is Not Unix.

XNU in 10.4 provides the kernel_task, and kernel features. It is a hybrid Mach (developed at Carnegie-Mellon) and BSD (Utilities and various kernel code) kernel, incorporating both microkernel code and the userland services traditionally associated with one into a single kernel.

Contents

[edit] Compiling XNU

[edit] Download

To build the latest XNU you must download a few files from Apple's Darwin (Open Source) page

Click on the latest release source code, or the one that you wish to compile. You will need an Apple Developer Connection ID, and you can get a regular one for free, just by registering.

We need to get:

IOKitUser-277.6 Libstreams-24.1 boostrap_cmds-49 cctools-590 xnu-792.6.22 and kext_tools-59

  • Note you must be logged in to receive those files.

[edit] Build others

Once you obtain them, load up your Darwin installation. Copy these files (via ftp, flash drive, HDD, CDROM whatever to your hard drive. I assume you know how to do this.)

I would make a folder called XNU in /usr/local/bin

mkdir /usr/local/bin/XNU

Now once your sources are in there, you have to untar the bootstrap files.

Please use su (or su - to preserve .bash* files and your profile.. but if you don't care, or have everything in $PATH, then don't worry.) and become root.

tar -xvzf bootstrap_cmds-49.tar.gz

now do the following:

cd bootstrap_cmds-49/relpath.tproj make

make install

cd ..

If that works, bootstrap_cmds-49 are now installed!

Next untar Libstreams.

tar -xvzf Libstreams-24.1.tar.gz

And do the following:

cd Libstreams-24.1/

make

make install

cd ..

Now onto cctools. This is possibly the most daunting one, because you must use a dreaded text editor. ;)

tar -xvzf cctools-590.tar.gz

Now do this:

cd cctools-590/

cp /usr/include/sys/unistd.h /System/Library/Frameworks/Kernel.framework/Headers/sys

vi Makefile

Hit the letter i in vi.

Go down to COMMON_SUBDIRS. Hit the hash sign. `#' It should look like #COMMON_SUBDIRS now. Do it again to the line below. That comments those lines out.

Go down a line, and hit enter to make yourself a newline. type this:

COMMON_SUBDIRS = libstuff libmacho misc

Hit esc , type the colon `:' hit `w' and then `!'

Hit enter, and then hit `:' `q' and you are done editing Makefile. It should look like this:

#COMMON_SUBDIRS = libstuff as gprof misc libmacho ld dyld libdyld \

#mkshlib otool profileServer RelNotes man cbtlibs

COMMON_SUBDIRS = libstuff libmacho misc

If so, then type this:

make RC_OS=macos

cp misc/seg_hack.NEW /usr/bin/seg_hack

chmod 775 /usr/bin/seg_hack

cd ld

cp static_kld/libkld.a /usr/lib

ranlib /usr/lib/liblkd.a

cd ../..

What this does, is compiles a seg_hack binary, and kernel link loader library file for us.

NOTE: It is important, that if XNU errors out because of a seg_hack complaint, MAKE SURE it's permissions are correct! It MUST be 775.

Now we must compile the kextsymboltool, but first some IOKit procedures.

tar -xvzf IOKitUser-277.6.tar.gz

And do the following:

mv IOKitUser-277.6/ IOKit/

mv IOKit/ /usr/include

mv /usr/include/IOKit/kext.subproj /usr/include/IOKit/kext

cp -fpr cctools-590/include/mach-o /usr/include

cp -fpr cctools-590/include/mach/* /usr/include/mach

Now:

tar -xvzf kext_tools-59.tar.gz

and then:

cd kext_tools-59/

gcc kextsymboltool.c -o kextsymboltool

cp kextsymboltool /usr/bin

chmod 775 /usr/bin/kextsymboltool

NOW! What you have ALL been waiting for:

tar -xvzf xnu-792.6.22.tar.gz

and now:

[edit] Build XNU

cd xnu-792.6.22/

make exporthdrs

make all

cp /mach_kernel /mach_kernel.old

cp BUILD/obj/RELEASE_I386/mach_kernel /mach_kernel

chmod 644 /mach_kernel

chown root /mach_kernel

Note, only cp if your kernel builds. :P

It will give you no errors, and probably won't say your kernel is built, but it works, and you have to copy it from RELEASE_I386.

Now one more thing:

reboot

or

shutdown -r now

Happy rebooting!


This page was last modified on 13 May 2012, at 21:24.
This page has been accessed 21,666 times.
Powered by MediaWiki © 2015 OSx86 Project  |   InsanelyMac  |   Forum  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain   |   Privacy policy   |   About OSx86   |   Disclaimers