mulatrix wrote:But what is wrong: the code or commands? I liked this tutorial because it is exactly what I want. Enable A20 Gate, entering the protected mode and call the kernel in C.
Both the code and commands are wrong.
There are a number of problems with the tutorial that you followed:
- The tutorial is marked as deprecated.
- It is marked as under construction and notes issues with the code.
- It is from 2008, last edited in 2010. This means it does not contain any recommendations from the last 4-6 years.
- The author recommends people use other tutorials in the comments.
- The comments are filled with people having lots of trouble.
- The tutorial is not community edited,
- It is hosted on google code, the fact people use that as opposed to superior sites like github, is a point against it in my book.
- The tutorial was probably written by a newbie (at least at that time).
And all that was without even looking at the code. When you look at the tutorial itself, there are more issues:
- The code doesn't use size_t and other unsigned variables where they should be used.
- The putc function is obviously really broken. The pos variable isn't calculated correctly. It also isn't being incremented/used correctly. The x variable measures in bytes, not characters, and y is just entirely broken.
- The tutorial makes a nonsense remark about operating systems not being able to escape a main function.
- The kernel entry doesn't set a stack (and thus doesn't ensure it is properly alignment). (Well, the bootloader does do it)
- It recommends using djgpp, an ancient compiler for DOS, or whatever. (I never looked into it.)
- A cross-compiler isn't used. (This gets even more troublesome when it recommends using a non-cross gcc on windows.)
- -nostdlib is passed when compiling the kernel, but it is a link time option to gcc.
- The ancient a.out format is the output format of nasm for no good reason. Your ld doesn't even accept it.
- 0x1000 is an awfully low place to load the kernel.
- The output format of ld is ill-defined and depends on what ld you are using. It is not a flat binary, as the bootloader thinks it is.
- A linker script is not used.
- Code generated by gcc is used, but libgcc is not linked with.
- (There are probably issues with the bootloader, but I never wrote one (I just use an existing one), so I can't tell)
- The bootloader is too simple to be even remotely useful for anything but a bad hello world kernel.
In short, it's an awful tutorial and a worse base. You should be able to realize this yourself.
If you want to write an operating system, don't write your own bootloader. Use an existing one such as GRUB. Then you can easily write a C kernel, compile it with your cross-compiler, and get to actual work. We already documented this well at the
Bare Bones tutorial. It's verified and gives you an actual environment that doesn't blow up when you do anything more sophisticated.
As for your original question:
Code: Select all
loader.o: file not recognized: File format not recognized
This means that loader.o is in the a.out format and your ld doesn't support it.
You say it enables the A20 line. I don't see that.
It appears that you post from the same IP as
dromenox. Are you that person?