972
edits
[unchecked revision] | [unchecked revision] |
No edit summary |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 9:
=== stub.asm ===
<
;/////////////////////////////////////////////////////////
;// //
Line 89:
KERNEL_STACK:
resb KERNEL_STACKSIZE
</syntaxhighlight>
=== kernel.pas ===
<
{
/////////////////////////////////////////////////////////
Line 163:
end.
</syntaxhighlight>
=== console.pas ===
<
{
/////////////////////////////////////////////////////////
Line 314:
end.
</syntaxhighlight>
=== multiboot.pas ===
<
unit multiboot;
Line 373:
end.
</syntaxhighlight>
=== system.pas ===
Since fpc-3.2.0 there was added necessary parts (in code block that part was highlighted by comment lines), because without them developer could met error like:
<syntaxhighlight lang="bash">
system.pas(18,1) (system) Parsing implementation of SYSTEM
system.pas(18,1) Fatal: Internal type "TEXCEPTADDR" was not found. Check if you use the correct run time library.
Fatal: Compilation aborted
</syntaxhighlight>
Valid version of '''system.pas''' on 2022/12/29:
<
unit system;
Line 458:
);
end;
{ --- End of nessesary part --- }
implementation
end.
</syntaxhighlight>
=== Linker script ===
linker.script
<
ENTRY(kstart)
SECTIONS
Line 515 ⟶ 500:
end = .; _end = .; __end = .;
}
</syntaxhighlight>
=== Compiling and Linking the modules ===
Assemble stub.asm with:
<
* -f elf32 - needed ''exact'' under x86_64 systems to make correct object file
The Pascal modules with:
<
* -Aelf - instructs the internal fpc assembler to output an ELF object.;
Line 541 ⟶ 526:
Then link the whole thing with:
<
* --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:
<
'''Special sutuation''': last time after building '''binutils''' I've got error
<syntaxhighlight lang="bash">
i386-linux-ld --gc-sections -s -Tlinker.script -o kernel.obj stub.o kernel.o multiboot.o console.o system.o
ld: i386 architecture of input file `stub.o' is incompatible with i386:x86-64 output
Line 557 ⟶ 542:
ld: i386 architecture of input file `system.o' is incompatible with i386:x86-64 output
make: *** [Makefile:27: _LD] Error 1
</syntaxhighlight>
That type of error can encounter if ''i386-linux-ld'' have wrong content. In my situation file content edited to:
<
#!/bin/bash
/full/path/to/compiled/cross/binutils/ld-new -A elf32-i386 $@
</syntaxhighlight>
=== makeiso.sh ===
Also a good option is create a bootable ISO file to make run it with VirtualBox or qemu:
<
#!/bin/sh
TMPISO=iso
Line 587 ⟶ 572:
grub-mkrescue --output=pascal-kernel.iso iso
rm -rf $TMPISO
</syntaxhighlight>
And simple run:
<
=== Alternative compiling: Makefile ===
Accumulating the lines from previous part we can make a '''Makefile''':
<
# Freepascal BareboneOS
# Makefile
Line 646 ⟶ 631:
rm -f *.ppu
</syntaxhighlight>
==Further Steps==
|