Page 3 of 3
Re: Write to 0xB8000 does't work
Posted: Thu Mar 12, 2009 6:36 pm
by spiner900
Oup sorry i would said 4kb. Ok if i understand, ALIGN 4096 it a good think only if i use the paging system in pMode. If i dontuse it i can use a différent number and more that number is smal better is the memory speed. When I said ELF is the same as PE I would say if ELF is a executable as PE and not if ELF is 100% like PE. And if I was under Window, canI use ELF to build my kernel ?
Re: Write to 0xB8000 does't work
Posted: Thu Mar 12, 2009 6:51 pm
by gzaloprgm
spiner900 wrote:If i dontuse it i can use a différent number and more that number is smal better is the memory speed.
You can just eliminate the align line if you don't plan using paging / mapping kernel sections as RO, etc. If you delete it it wont be faster, the kernel will be smaller (in size).
When I said ELF is the same as PE I would say if ELF is a executable as PE and not if ELF is 100% like PE. And if I was under Window, canI use ELF to build my kernel ?
ELF in a kernel is only useful if you are using a bootloader which supports it (ie: GRUB) or when you want your OS to load applications, in which you can compile them as ELF and load them.
If you want to use ELF to build your kernel, you will probably need to make a cross-compiler (Check the wiki for more info).
Cheers,
gzaloprgm
Re: Write to 0xB8000 does't work
Posted: Thu Mar 12, 2009 7:00 pm
by spiner900
Ok but now I want my kernel in a plain binary file, but i have to use ELF object to get it in 32 bit. Is there a other way ?
Re: Write to 0xB8000 does't work
Posted: Thu Mar 12, 2009 7:10 pm
by gzaloprgm
Yes, you can try compiling as a 32 bit COFF and then using a tool such as objdump to convert it to a plain binary file.
Re: Write to 0xB8000 does't work
Posted: Thu Mar 12, 2009 7:11 pm
by spiner900
ok thanks !
Re: Write to 0xB8000 does't work
Posted: Thu Mar 12, 2009 7:42 pm
by JohnnyTheDon
gzaloprgm wrote:Yes, you can try compiling as a 32 bit COFF and then using a tool such as objdump to convert it to a plain binary file.
Or you could take the normal elf32 and use objcopy. And if I remember correctly, COFF is a relocatable object format and not a finished excecutable format.
If i dontuse it i can use a différent number and more that number is smal better is the memory speed.
Smaller isn't better, more aligned is better. Accessing a multibyte variable is faster on boundaries evenly divisible by the size of the value. So 32-bit variables should be aligned to 4 bytes, 64-bit to 8 bytes, 128-bit to 16, etc. I said 16 because thats typically the biggest data size you will see.
Re: Write to 0xB8000 does't work
Posted: Thu Mar 12, 2009 8:31 pm
by quok
JohnnyTheDon wrote:gzaloprgm wrote:Yes, you can try compiling as a 32 bit COFF and then using a tool such as objdump to convert it to a plain binary file.
Or you could take the normal elf32 and use objcopy. And if I remember correctly, COFF is a relocatable object format and not a finished excecutable format.
I really don't see what's wrong with letting LD do the conversion to a flat binary for you. Something like the following should work fine, and I find it just as easy (if not easier, since it requires less steps) than using objcopy.
Code: Select all
ld --oformat binary -Ttext 0x0 -o kernel.bin kernel.o startup.o ...
Re: Write to 0xB8000 does't work
Posted: Thu Mar 12, 2009 10:48 pm
by neon
Only question I have is why one would want a plain binary kernel anyways. I do not see any benefit of it.
Re: Write to 0xB8000 does't work
Posted: Fri Mar 13, 2009 4:42 am
by Combuster
neon wrote:Only question I have is why one would want a plain binary kernel anyways. I do not see any benefit of it.
Much easier to load by a custom bootloader
Re: Write to 0xB8000 does't work
Posted: Fri Mar 13, 2009 7:07 pm
by neon
Much easier to load by a custom bootloader
True. Easier is not always better though.