0
votes

Linux translates flat virtual address to physical address by MMU. In the virtual address space of Linux, there are many types of segments:

  • Kernel space
  • User stack
  • Memory mapping region
  • User heap
  • Bss segment
  • Data segment
  • Text segment

How does Linux maintain these segments (aka sections)? Where are the base addresses and sizes of these segments stored? Registers, GDT/LDT, mm_struct or other data structures in kernel?

Appreciate any help.

1
The important thing is to avoid confusing x86 segments with ELF-segments, these are two entirely separate conceptsMike76

1 Answers

2
votes

GDT/LDT is x86 family feature. Kernel space translated via kernel part of page tables, userspace via userspace part. Page tables are in main memory, mm_struct is a structure used in Linux kernel to describe memory layout. It is per-process

User stack
User heap
Bss segment
Data segment
Text segment

This layout described in mm_struct. Also mm_struct contains ->pgd field which is a root page table pointer (loaded to ttrb0/ttrb1 on ARM)