Data segments and how they appear in the GRUB memory map

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
CocaCola
Member
Member
Posts: 36
Joined: Fri Sep 07, 2012 9:11 am

Data segments and how they appear in the GRUB memory map

Post by CocaCola »

Hello.
To my understanding uninitialized global variables are "stored" in the BSS, as entries without values.
Obviously the things in the BSS will get allocated on RAM during runtime, just like DATA and RODATA.

My question is: does the memory map provided by GRUB show the RAM associated with the segments as "Available" or "Reserved"?

Thanks.
bemk
Posts: 8
Joined: Sun Oct 02, 2011 2:50 pm

Re: Data segments and how they appear in the GRUB memory map

Post by bemk »

I don't believe that the memory map shows your kernel at all. (Could be wrong there).

At any rate it should be easy enough to test. Simply dump the memory map to screen, and compare the regions with those in your symbol table. Don't know where the .bss ends? Simply add a symbol at the end called .end or something (which is what my kernel looks for anyway).
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Data segments and how they appear in the GRUB memory map

Post by dozniak »

The memory map does not reflect this. In case of GRUB it is a straight dump of bios e820h memory map.

You should iterate the multuboot modules list and subtract that memory from the memory map yourself.
Learn to read.
User avatar
CocaCola
Member
Member
Posts: 36
Joined: Fri Sep 07, 2012 9:11 am

Re: Data segments and how they appear in the GRUB memory map

Post by CocaCola »

dozniak wrote:You should iterate the multuboot modules list and subtract that memory from the memory map yourself.
My kernel is a single executable. Please elaborate what the module list represents in this case, because I'm a bit confused.

For reference, the paragraph about modules in the Multiboot specification seems to not apply for my kernel:
http://www.gnu.org/software/grub/manual ... ot-modules
Multiboot specification wrote:Many modern operating system kernels, such as Mach and the microkernel in VSTa, do not by themselves contain enough mechanism to get the system fully operational: they require the presence of additional software modules at boot time in order to access devices, mount file systems, etc.
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Data segments and how they appear in the GRUB memory map

Post by dozniak »

Just define linker symbols start and end and use them in this case to amend the memory map.
Learn to read.
User avatar
CocaCola
Member
Member
Posts: 36
Joined: Fri Sep 07, 2012 9:11 am

Re: Data segments and how they appear in the GRUB memory map

Post by CocaCola »

dozniak wrote:Just define linker symbols start and end and use them in this case to amend the memory map.
Thank you.

To complete this thread I'll post links to the relevant Wiki pages:
http://wiki.osdev.org/Linker_Scripts
http://wiki.osdev.org/Using_Linker_Script_Values
Post Reply