Page 1 of 1

linking a pei-i386 kernel file problems

Posted: Tue Feb 18, 2020 8:43 am
by zecarlos
Greetings everyone.
I am trying to compile and test a pm32 bit operating system on VirtualBox. The tutorial I chose is loaded by GRUB in ELF format. My development environment is on Windows7 with the Mingw32-gcc compiler. The format of my OS files is PE.
My adventure has barely started and I already have my head spinning, with the first problem. It seems to me that something is not right with linking the "ld" the data that some fields present does not seem correct, among them AddressEntryPoint, BaseCode, BaseData, SizeImage and VirtualAddress of all sections.
I did two different tests, the first:
After forming an executable file in the PE format I used ("objcopy -O binary krnl32.exe krnl32.sys") in this test everything works fine until an interruption occurs that causes a jump to the address 0xffffff0.
In the second test I use the PEI-i386 format which, in addition to the mentioned defect, now happens even without triggering an interrupt, and the data segment descriptor is pointing to .bss and not to .data,

I attached the memory map of the link, the executable file and the floppy image that can run on VirtualBox or Bochs.
Maybe someone can help me, because I don't know how to explain it better.