Hi,
I have already a working boot sector that reads from my fs, a boot loader that loads the kernel to RM memory, setup GDT, enter PM, copy the kernel from RM to PM and jump to it. I use DJGPP for compiling the kernel.
(Oh, and I made a GUI program to generate GDT descriptors, if anybody wants a copy, please email me).
The problem is I must link all kernel objects and set the code start to 0x0000 (with -Ttext). And what about data, how should I prepare the a GDT descriptor for it without knowing where the data is located in the memory? Do I have to recompile the bootloader each time?
I know ld have scripts, if it whould be possible to write bytes to the output file from that script, it whould be easy to create a simple format like (signature, code start, data start => code, data)
Kernel EXE format
RE:Kernel EXE format
You can't really append bytes to the output file through LD, per se... but you can create symbols to reference the start of the code and data segments, like so:
.text 0x00000000 :{
textStart = .;
*(.text)
*(.text.*)
*(.rodata)
}
textEnd = .;
And likewise for your .data and .bss segments
And then in your C code, you can reference those as regular symbols:
extern long textStart;
location of .text is then &textStart
Hope that helps,
Jeff
.text 0x00000000 :{
textStart = .;
*(.text)
*(.text.*)
*(.rodata)
}
textEnd = .;
And likewise for your .data and .bss segments
And then in your C code, you can reference those as regular symbols:
extern long textStart;
location of .text is then &textStart
Hope that helps,
Jeff
RE:Kernel EXE format - YES I CAN
BYTE(0x45);
BYTE(0x45);
BYTE(0x46);
BYTE(eef_version);
BYTE(eef_release);
LONG(SIZEOF(.header));
LONG(SIZEOF(.text));
LONG(main);
LONG(SIZEOF(.data));
LONG(__data_start);
LONG(SIZEOF(.bss));
LONG(__bss_start);
LONG(stack_size);
LONG(__exit_addr);
I found that example!
BYTE(0x45);
BYTE(0x46);
BYTE(eef_version);
BYTE(eef_release);
LONG(SIZEOF(.header));
LONG(SIZEOF(.text));
LONG(main);
LONG(SIZEOF(.data));
LONG(__data_start);
LONG(SIZEOF(.bss));
LONG(__bss_start);
LONG(stack_size);
LONG(__exit_addr);
I found that example!