Hello everybody.
I know about the "address space" and how not every address belongs to RAM.
I also know that GRUB can prepare a memory map to show what is RAM, and what isn't.
My question is: all the global variables, and the local variables, and the constants, will they be stored in RAM?
And if so, will following GRUB's memory map make me overwrite them?
Then how can I discern which area is safe to use and which isn't?
Are variables put in RAM?
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: Are variables put in RAM?
Yo:
Your kernel executable image is "built" by a series of programs which assemble it into a file of organized data and code. A bootloader loads this file into memory and passes execution control to it. The file has information on your "variables" and their offsets within the kernel image.
For more information, consider writing some basic programs and analysing them using programs like objdump. You might also want to consider other hobbies, depending on how much time you really have to spend in this field
--Peace out,
gravaera
Your kernel executable image is "built" by a series of programs which assemble it into a file of organized data and code. A bootloader loads this file into memory and passes execution control to it. The file has information on your "variables" and their offsets within the kernel image.
For more information, consider writing some basic programs and analysing them using programs like objdump. You might also want to consider other hobbies, depending on how much time you really have to spend in this field
--Peace out,
gravaera
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Re: Are variables put in RAM?
Could you elaborate, please? (Or link to a relevant Wiki article.)gravaera wrote:The file has information on your "variables" and their offsets within the kernel image.
My main concern is that I can overwrite RAM that is used by variables.
I'll try that, thanks.gravaera wrote:For more information, consider writing some basic programs and analysing them using programs like objdump.
Re: Are variables put in RAM?
Hi,CocaCola wrote:Could you elaborate, please? (Or link to a relevant Wiki article.)gravaera wrote:The file has information on your "variables" and their offsets within the kernel image.
My main concern is that I can overwrite RAM that is used by variables.
I'll try that, thanks.gravaera wrote:For more information, consider writing some basic programs and analysing them using programs like objdump.
You've exposed a gap in your knowledge at an alarmingly basic level. I suggest you try something more basic to get the hang of how a computer program actually works, before trying operating system development.
Cheers,
James
Re: Are variables put in RAM?
I've seen that objdump can show the sections of a program and their contents.
And that's useful. But it still doesn't answer my question: how can I be sure I don't overwrite memory in use?
When the kernel image is loaded onto memory, does the GRUB memory map mark it as "reserved"?
And that's useful. But it still doesn't answer my question: how can I be sure I don't overwrite memory in use?
When the kernel image is loaded onto memory, does the GRUB memory map mark it as "reserved"?
Re: Are variables put in RAM?
Hi,
The normal work-around for this is to reserve space in your ".bss" for anything you may need during early initialisation (space you can use safely before you've got your own physical memory management working).
Cheers,
Brendan
No. Sadly the memory map provided by GRUB only says what the firmware told GRUB, and doesn't include areas that GRUB has used for your kernel or extra modules or the multiboot information; and because of this it's a pain in the neck to avoid trashing important things during early initialisation code (especially if you comply with the multi-boot specification and don't make "GRUB specific" assumptions about where things like the multiboot information or extra modules may have been left).CocaCola wrote:When the kernel image is loaded onto memory, does the GRUB memory map mark it as "reserved"?
The normal work-around for this is to reserve space in your ".bss" for anything you may need during early initialisation (space you can use safely before you've got your own physical memory management working).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Are variables put in RAM?
Thanks to all who posted.
For anyone interested, I found these:
http://duartes.org/gustavo/blog/post/mo ... memory-map
http://duartes.org/gustavo/blog/post/ho ... rs-boot-up
http://duartes.org/gustavo/blog/post/ke ... ot-process
http://www.intel.com/content/www/us/en/ ... nuals.html
If anyone has more useful links to contribute, please do so.
Otherwise, see you in a bit: I've some reading to do.
For anyone interested, I found these:
http://duartes.org/gustavo/blog/post/mo ... memory-map
http://duartes.org/gustavo/blog/post/ho ... rs-boot-up
http://duartes.org/gustavo/blog/post/ke ... ot-process
http://www.intel.com/content/www/us/en/ ... nuals.html
If anyone has more useful links to contribute, please do so.
Otherwise, see you in a bit: I've some reading to do.