Page 1 of 1
creating constant size kernel image
Posted: Thu Nov 25, 2010 1:09 am
by Chandra
Is there any way to create a constant size kernel image. In NASM, the times directive would do the job but how can this be done in C?
Any help would be outstanding.
Best Regards,
Chandra
Re: creating constant size kernel image
Posted: Thu Nov 25, 2010 1:36 am
by gravaera
But somehow I don't think that's what you were looking for
...
Re: creating constant size kernel image
Posted: Thu Nov 25, 2010 3:10 am
by Solar
You cannot do it in "pure" C, because the compiler has no notion of how big the binary will eventually be. (It being created by the backend, after the compiler has finished.)
So you would have to look at the Linker to do this stunt.
Re: creating constant size kernel image
Posted: Thu Nov 25, 2010 5:49 am
by Brendan
Hi,
Chandra wrote:Is there any way to create a constant size kernel image. In NASM, the times directive would do the job but how can this be done in C?
Any help would be outstanding.
It'd help to know why you'd consider wasting (tens, hundreds, thousands, millions) of bytes for the sake of padding. The only reason I can think of is that your boot loader (or your memory management initialisation, or paging initialisation) is broken and will only handle a fixed size kernel, and you couldn't be bothered fixing the real problem.
The only other thing I can think of is that (for some unknown but justifiable reason) you need to align sections (e.g. so that the ".bss" begins on a page boundary), where you don't actually want a fixed size kernel.
Cheers,
Brendan
Re: creating constant size kernel image
Posted: Thu Nov 25, 2010 6:10 am
by Solar
Brendan wrote:The only other thing I can think of is that (for some unknown but justifiable reason) you need to align sections (e.g. so that the ".bss" begins on a page boundary), where you don't actually want a fixed size kernel.
...which the linker can do that for you just fine (ALIGN ...)
Re: creating constant size kernel image
Posted: Thu Nov 25, 2010 11:46 pm
by Chandra
Brendan wrote:Hi,
Chandra wrote:Is there any way to create a constant size kernel image. In NASM, the times directive would do the job but how can this be done in C?
Any help would be outstanding.
It'd help to know why you'd consider wasting (tens, hundreds, thousands, millions) of bytes for the sake of padding. The only reason I can think of is that your boot loader (or your memory management initialisation, or paging initialisation) is broken and will only handle a fixed size kernel, and you couldn't be bothered fixing the real problem.
The only other thing I can think of is that (for some unknown but justifiable reason) you need to align sections (e.g. so that the ".bss" begins on a page boundary), where you don't actually want a fixed size kernel.
Cheers,
Brendan
Unfortunately, you are wrong this time. Please donot expect me to be that kind of person who gives up his work, simply not being able to fix. I don't know how your guess came up. Anyway, the thing is not that major problem has caused me to do so. My Kernel is already 64 Kilobytes long and I have two kernels.
The first one is protected mode kernel and the second one is real mode kernel. The real mode kernel is for debugging and remote session only.My bootloader has to load both the kernels in the memory at different locations and I'm encountering problem due to number of sectors read, as the sectors consumed by the protected mode kernel goes on increasing as the development process continues.I am using custom Filesystem (TMFS) with 16 bytes entry which is encountering problems when the secotors of the kernel varies. So I just wondered if I could make the protected mode kernel fixed size(approx, 96 KB) and then continue to work on real mode kernel.
Re: creating constant size kernel image
Posted: Fri Nov 26, 2010 1:44 am
by Combuster
I am using custom Filesystem (TMFS) with 16 bytes entry which is encountering problems when the secotors of the kernel varies.
So you are working around bugs by making bloatware. And then saying you are not "that kind of person who gives up his work, simply not being able to fix.". Man, you are really late for halloween.
This is exactly what Brendan's question was about - to find out if you are doing weird things that are completely unnecessary and can be solved more effectively. I would have asked the same thing.