Page 1 of 1

Making a kernel compiled by FPC Win32 bootable

Posted: Fri Aug 14, 2009 11:44 am
by erich
Hello,
I'm trying to get Wiki's pascal barebone to work. I'm using windows, I've done everything on wiki, then I downloaded grub&mkisofs and set up folders then made an ISO too. But when I try to run it I'm getting `invalid or unsupported executable format` error by grub. I've tried adding -b elf32-i386 option to linker but it gave `PE operations on NON-PE file` exception. But in fpc's parameters it's already specified to compile kernel.pas and others in ELF format... Any ideas?

Re: Making a kernel compiled by FPC Win32 bootable

Posted: Fri Aug 14, 2009 2:54 pm
by egos
Try to add multiboot header into your executable module.

Re: Making a kernel compiled by FPC Win32 bootable

Posted: Fri Aug 14, 2009 3:35 pm
by f2
erich wrote:Hello,
I'm trying to get Wiki's pascal barebone to work. I'm using windows, I've done everything on wiki, then I downloaded grub&mkisofs and set up folders then made an ISO too. But when I try to run it I'm getting `invalid or unsupported executable format` error by grub. I've tried adding -b elf32-i386 option to linker but it gave `PE operations on NON-PE file` exception. But in fpc's parameters it's already specified to compile kernel.pas and others in ELF format... Any ideas?
FPC uses GCC as a backend, and the MinGW version of GCC is unable to create elf32 executables.
Try to compile your own GCC for generating elf32 executables.

Re: Making a kernel compiled by FPC Win32 bootable

Posted: Sat Aug 15, 2009 5:35 am
by erich
Thanks for replies. Now, is there any easy to use bootloader that can handle my PE file?

Re: Making a kernel compiled by FPC Win32 bootable

Posted: Sat Aug 15, 2009 12:54 pm
by Craze Frog
Tommy wrote:
erich wrote:Hello,
I'm trying to get Wiki's pascal barebone to work. I'm using windows, I've done everything on wiki, then I downloaded grub&mkisofs and set up folders then made an ISO too. But when I try to run it I'm getting `invalid or unsupported executable format` error by grub. I've tried adding -b elf32-i386 option to linker but it gave `PE operations on NON-PE file` exception. But in fpc's parameters it's already specified to compile kernel.pas and others in ELF format... Any ideas?
FPC uses GCC as a backend, and the MinGW version of GCC is unable to create elf32 executables.
Try to compile your own GCC for generating elf32 executables.
That is totally nonsense. FPC does not use GCC.

You need a new linker. The linker is not part of GCC, but rather binutils. See the wiki on how to build a cross toolchain (http://wiki.osdev.org/GCC_Cross-Compiler). Build and install binutils only (not GCC). This will give you a working GNU ld.

Re: Making a kernel compiled by FPC Win32 bootable

Posted: Sat Aug 15, 2009 1:58 pm
by f2
Craze Frog wrote:
Tommy wrote:
erich wrote:Hello,
I'm trying to get Wiki's pascal barebone to work. I'm using windows, I've done everything on wiki, then I downloaded grub&mkisofs and set up folders then made an ISO too. But when I try to run it I'm getting `invalid or unsupported executable format` error by grub. I've tried adding -b elf32-i386 option to linker but it gave `PE operations on NON-PE file` exception. But in fpc's parameters it's already specified to compile kernel.pas and others in ELF format... Any ideas?
FPC uses GCC as a backend, and the MinGW version of GCC is unable to create elf32 executables.
Try to compile your own GCC for generating elf32 executables.
That is totally nonsense. FPC does not use GCC.

You need a new linker. The linker is not part of GCC, but rather binutils. See the wiki on how to build a cross toolchain (http://wiki.osdev.org/GCC_Cross-Compiler). Build and install binutils only (not GCC). This will give you a working GNU ld.
Oops! :? Once again, I was pressed, and I've written anything!
I wanted to say "LD" instead of GCC. Sorry again!

Re: Making a kernel compiled by FPC Win32 bootable

Posted: Sat Aug 15, 2009 2:53 pm
by Kevin
erich wrote:Thanks for replies. Now, is there any easy to use bootloader that can handle my PE file?
You should be able to use GRUB if you put the a.out kludge into your multiboot header. This means you need to add a few more fields like the entry point as GRUB cannot extract them from a binary format it doesn't know.