James Molloy's Tutorial Known Bugs: Difference between revisions

Jump to navigation Jump to search
m
Minor spell check
[unchecked revision][unchecked revision]
(Created page with "Several sources - including this Wiki - point to [http://www.jamesmolloy.co.uk/tutorial_html/ James Molloy's Roll your own toy UNIX-clone OS] Tutorial as a starting point. Thi...")
 
m (Minor spell check)
Line 13:
== Problem: __cdecl calling convention ==
 
The tutorial states that the <tt>__cdecl</tt> calling convention is used. This is, however, a Windows term and your cross-compiler uses a similar calling convention but it is called the System V ABI for i386. It is advisable to understand this calling convention in depth, especially parts about how the parameters on the stack are clobbered and how structure parameters are passed. This will be very useful later and will help you avoid a later subtle bug. The function call example in 2.3 forgetsneglects to add 12 to esp following the call instruction and the three parameters are never thus popped.
 
== Problem: CFLAGS ==
 
The tutorial recommends using these compilation options <tt>-nostdlib -nostdinc -fno-builtin -fno-stack-protector</tt>, but this is not the recommended practice. The tutorial forgetsneglects to pass the important <tt>-ffreestading</tt> option. See [[Bare Bones]] on how to correctly compile C kernel files and how to correctly link the kernel.
 
== Problem: Not using libgcc ==
Line 23:
{{Main|libgcc}}
 
The tutorial disables libc and [[libgcc]] through the <tt>-nodefaultlibs</tt> option (implied by <tt>-nostdlib</tt>) but forgetsneglects to add back libgcc during the link.
 
== Problem: Not setting a stack ==
 
The tutorial forgetsneglects to set a stack in the initial boot file and relies on the bootloader using an appropriate stack. You should instead declare your own stack as an array and use that instead, such that you have control of the situation.
 
== Problem: main function ==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu