Menu

#1 Win32 build

open
nobody
None
5
2012-07-18
2010-10-30
bobsobol
No

I recreated the bash build script as an NT .cmd script:-
[code]@echo off
echo compiling kernel...
fbc -r main.bas
echo .globl fb_ctor__main > main2.asm
copy main2.asm + main.asm main3.asm > NUL:
del main.asm
del main2.asm
ren main3.asm main.asm
as -o main.o main.asm

echo compiling Multiboot-Header part...
fbc -c mb.bas

echo linking kernel...
ld --enable-stdcall-fixup -Ttext=0x100000 mb.o main.o -b elf_i386 -o frost.krn
echo "done."[/code]
This seems to come close, but doesn't produce a working kernel and falls out with an ld error:-
[code]compiling kernel...
compiling Multiboot-Header part...
linking kernel...
ld: warning: cannot find entry symbol _mainCRTStartup; defaulting to 00100000
mb.o:fake:(.text+0x5): undefined reference to `fb_ctor__main'
"done."[/code]

Even though you can see I've added "--enable-stdcall-fixup". As far as I can tell, the result of the .cmd should be the same as the .sh but it doesn't work.

I've not tried in a win32 version of bash yet, but suspect this is due to differences in the versions of the build tools in the Win32 release of freeBASIC. Any ideas? I think this would be a good option to have and encourage more developers from more diverse backgrounds, as is intended by freeBASIC.

Discussion

  • bobsobol

    bobsobol - 2010-11-09

    I've now looked at the .asm and .o files and I'm not sure why ld is having so much difficulty.

    I can find the `fb_ctor__main' in both of them.

    BTW, the "--enable-stdcal-fixup" just avoids a shed load of warnings about as marking routines with mangled names "Warning: resolving _fb_Out@8 by linking to _fb_Out" etc. it matches them up fine, but just warns about them.

     
  • bobsobol

    bobsobol - 2010-11-09

    Confirmation and 1 remaining problem:-

    @echo off
    echo compiling kernel...
    fbc -r main.bas
    echo .globl fb_ctor__main > main2.asm
    echo fb_ctor__main: >> main2.asm
    copy main2.asm + main.asm main3.asm > NUL:
    del main.asm
    del main2.asm
    ren main3.asm main.asm
    as -o main.o main.asm

    echo compiling Multiboot-Header part...
    fbc -c mb.bas

    echo linking kernel...
    ld --oformat elf32-i386 --enable-stdcall-fixup -Ttext=0x100000 mb.o main.o -o frost.krn
    echo "done."
    pause

    This works, except that all the Win32 binary versions of GNU ld will only produce PE files, they cannot cross-compile (or in this instance cross link) to an ELF32-i386 properly. :(

     
  • darkinsanity

    darkinsanity - 2010-11-27

    Sorry, I wasn´t online for a long time...
    Hm, I have no experience in building kernels under Windows. I´ve used Linux for that all the time, because I can use GRUB easily there and I had to use a SVN version of fbc back then. And I just think Linux is better for what I do everyday ;)
    For the PE-problem: I guess you have to build you some kind of a cross-compiler. I have no experience in doing this, and I guess it would be a lot easier to just use VirtualBox with a Linux, but thats probably not what you want. But maybe this can help you: http://wiki.osdev.org/GCC_Cross-Compiler
    Sadly, I don´t have time to work on FROST, so I had to stop development. As far as I can see, FROST is still the most advanced kernel in FreeBASIC, but there are many things that I would to differently today, and I just don´t have the time to do it.
    I hope that other people can learn from it (although you shouldn´t copy it - some lines aren´t done well ^^), and if I have time someday I´ll work on FROST again.

    I hope you can get it to work. If you find the solution, feel free to post it here. Good luck :)

     

Anonymous
Anonymous

Add attachments
Cancel





Monday.com Logo