0

Hy guys, a long time ago I learned about the Linux memory layout of C Programs like it is explained here http://www.geeksforgeeks.org/memory-layout-of-c-program/

Linux Memory Layout

I was wondering, when I am writing an assembly program it is necessary to define the sections .text, .data and .bss. Does it mean, that data defined in these sections are the same as in the figure above? For instance when I define a byte within the .data section like

section .data
    var db "a"

it would be mapped in the place called "initialized data".

And

section .bss
    var: resb 4

would be mapped in the place called "uninitialized data (bss)"?

Dennis
  • 965
  • 1
  • 9
  • 17
  • 1
    Yes, to all your questions. Linux does leave gaps between the text, data, and bss so that running off the end of an array leads to a segfault instead of reading bogus data, but that diagram is still more or less accurate. [My edit to the first half of this answer](http://askubuntu.com/a/814304/116941) explains how execve results in an executable being mapped into virtual memory. – Peter Cordes Aug 22 '16 at 20:38
  • See also the linked duplicate for more details, e.g. what these addresses normally are (for 32-bit processes). – Peter Cordes Aug 22 '16 at 20:43

0 Answers0