Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


into smaller subintervals to control what can be removed and what cannot, but this is not of
importance for our purposes now.

Although the variables used to define section bounds are defined in the kernel source code
(arch/x86/kernel/setup_32.c), no values are assigned to them at this point. This is simply not
possible. How can the compiler know at compilation time how large the kernel will be? The exact value is
only established when the object files are linked, and it is then patched into the binary file. This action is
controlled byarch/arch/vmlinux.ld.S(for IA-32, the file isarch/x86/vmlinux_32.ld.S), where
the kernel memory layout is also defined.

The exact value varies according to kernel configuration as each configuration has text and data sections
of different sizes — depending on which parts of the kernel are enabled and which are not used. Only
the start address (_text)isalwaysthesame.


Each time the kernel is compiled, a file namedSystem.mapis generated and stored in the source base
directory. Besides the addresses of all other (global) variables, procedures, and functions defined in the
kernel, this file also includes the values of the constants shown in Figure 3-11,


wolfgang@meitner>cat System.map
...
c0100000 A _text
...
c0381ecd A _etext
...
c04704e0 A _edata
...
c04c3f44 A _end
...

All values have the offset0xC0000000, which is the start address of the kernel
segment if the standard 3 : 1 split between user and kernel address space is chosen.
The addresses are virtual addresses because RAM memory is mapped into the
virtual address space as a linear mapping starting at this address. The correspond-
ing physical addresses are obtained by subtraction from0xC0000000.

/proc/iomemalso provides information on the sections into which RAM memory is divided.


wolfgang@meitner>cat /proc/iomem
00000000-0009e7ff : System RAM
0009e800-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000f0000-000fffff : System ROM
00100000-17ceffff : System RAM
00100000-00381ecc : Kernel code
00381ecd-004704df : Kernel data
...

The kernel image begins above the first megabyte (0x00100000). The size of the code is approximately
2.5 MiB, and the data section accounts for about 0.9 MiB.

Free download pdf