Pascal Bare Bones: Difference between revisions

Jump to navigation Jump to search
no edit summary
[unchecked revision][unchecked revision]
No edit summary
No edit summary
Line 432:
=== Compiling and Linking the modules ===
Assemble stub.asm with:
<source lang="bash">nasm -f elfelf32 stub.asm -o stub.o</source>
 
* -f elf32 - needed ''exact'' under x86_64 systems to make correct object file
 
The Pascal modules with:
<source lang="bash">fpc -Aelf -n -O3 -Op3 -Si -Sc -Sg -Xd -CX -XXs -Pi386 -Rintel -Tlinux kernel.pas</source>
 
* -Aelf - instructs the internal fpc assembler to output an ELF object.;
Line 447 ⟶ 449:
* -CX - tells the compiler to create smartlinkable units
* -XXs - tells the compiler to do smartlinking (-XX) and debugging symbols stripping (-Xs)
* -Pi386 - tells the compiler to force i386 mode (actual for x86_64 host systems)
* -Rintel - sets the inline assembly syntax to intel style;
* -Tlinux - specifies that the target operating system is Linux. (Don't even ask!)
Line 454 ⟶ 457:
 
* --gc-sections -s, in combination with -CX -XXs above, eliminates RTTI symbols from resulting binary
 
In case of trouble linking under x86_64 system try this line:
<source lang="bash">i686-elf-ld -A elf-386 --gc-sections -s -Tlinker.script -o kernel.obj stub.o kernel.o multiboot.o system.o console.o</source>
 
=== makeiso.sh ===
Also a good option is create a bootable ISO file to make run it with VirtualBox or qemu:
 
<source lang="bash">
#!/bin/sh
TMPISO=iso
TMPBOOT=${TMPISO}/boot
TMPGRUB=${TMPBOOT}/grub
TMPCFG=${TMPGRUB}/grub.cfg
 
mkdir $TMPISO
mkdir $TMPBOOT
mkdir $TMPGRUB
cp kernel.obj $TMPBOOT/kernel.obj
echo 'set timeout=0' > $TMPCFG
echo 'set default =0' >> $TMPCFG
echo '' >> $TMPCFG
echo 'menuentry "Pascal bare" {' >> $TMPCFG
echo ' multiboot /boot/kernel.obj' >> $TMPCFG
echo ' boot' >> $TMPCFG
echo '}' >> $TMPCFG
grub-mkrescue --output=pascal-kernel.iso iso
rm -rf $TMPISO
</source>
 
And simple run:
<source lang="bash">qemu-system-i386 pascal-kernel.iso</source>
 
 
[[Category:Bare bones tutorials]]
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu