The Memory Layout of a C Program | Data Structures in Embedded Systems

preview_player
ะŸะพะบะฐะทะฐั‚ัŒ ะพะฟะธัะฐะฝะธะต

๐— ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜† ๐—Ÿ๐—ฎ๐˜†๐—ผ๐˜‚๐˜ ๐—ผ๐—ณ ๐—ฎ ๐—– ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ
In this comprehensive video, We delve into the intricacies of the memory layout of a C program.
Gain a clear understanding of the various segments that comprise a C program's memory space, including:
1. Text Segment
2. Uninitialised data segment (BSS)
3. Initialised data segment
4. Heap
5. Stack

๐—™๐˜‚๐—น๐—น ๐—ฃ๐—น๐—ฎ๐˜†๐—น๐—ถ๐˜€๐˜:

๐—˜๐—บ๐—ฏ๐—ฒ๐—ฑ๐—ฑ๐—ฒ๐—ฑ ๐—ฆ๐˜†๐˜€๐˜๐—ฒ๐—บ ๐—ฃ๐—ผ๐—ฑ๐—ฐ๐—ฎ๐˜€๐˜ ๐—ฃ๐—น๐—ฎ๐˜†๐—น๐—ถ๐˜€๐˜:

๐—˜๐—บ๐—ฏ๐—ฒ๐—ฑ๐—ฑ๐—ฒ๐—ฑ ๐—ฆ๐˜†๐˜€๐˜๐—ฒ๐—บ๐˜€ ๐Ÿญ๐Ÿฌ๐Ÿญ: ๐—– ๐—ก๐—ถ๐—ป๐—ท๐—ฎ, ๐—ถ๐—ป ๐—ฃ๐˜†๐—ท๐—ฎ๐—บ๐—ฎ! ๐—ง๐—ต๐—ฒ ๐—ฟ๐—ถ๐—ด๐—ต๐˜ ๐˜„๐—ฎ๐˜† ๐˜๐—ผ ๐—น๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—–... ๐—ฃ๐—น๐—ฎ๐˜†๐—น๐—ถ๐˜€๐˜:

๐—–๐—ต๐—ฎ๐—ฝ๐˜๐—ฒ๐—ฟ๐˜€:
00:00 C Program and its Compilation
01:00 Load executable binary into RAM
01:23 Memory segments
02:04 Text Segment
03:26 Data Segment
03:40 Uninitialized data segment
04:25 Initialized data segment
04:53 Heap segment: Dynamic Memory Allocation
05:36 Stack segment
07:02 Segmentation Fault
07:53 A C Program to understand different memory segments
- - - - - - - - - - - -

๐™ˆ๐™š๐™ข๐™š๐™—๐™š๐™ง๐™จ:

#inpyjama #cninja #embeddedsystems #embedded #clanguage #memory #datastructures
ะ ะตะบะพะผะตะฝะดะฐั†ะธะธ ะฟะพ ั‚ะตะผะต
ะšะพะผะผะตะฝั‚ะฐั€ะธะธ
ะะฒั‚ะพั€

Isn't Stack memory of a fixed size? At 7:40 when describing Segmentation Fault, shouldn't that arise the moment the threshold of Stack Memory is crossed instead of the Stack Memory + Unallocated Memory region?

ammartirmizi
ะะฒั‚ะพั€

Nice information
Congratulations and heartful appreciation for "Embedded in pyjama" team for the efforts to create content on Embedded systems.

koppakabhagavan
ะะฒั‚ะพั€

Detailed and clear explanation ๐Ÿ™Œ๐Ÿ‘
Looking forward for all the upcoming advanced topics :)

KarunaRudresh
ะะฒั‚ะพั€

Hi dev.. Nice explanation . Will be good if you cover some more advanced topics like read only data segment and how string litrals(char *) and const var are stored and these memory freed

mohansaini
ะะฒั‚ะพั€

Thank you sir, this is very clear explanation

sangeethagowda
ะะฒั‚ะพั€

Thank you, one query. Does the executable binary file contain (in addition to the code) instructions for segregating the allocated memory in to 5 sections? Otherwise, whose responsibility is it to segregate the allocated memory in to 5 sections?

donythomas
ะะฒั‚ะพั€

Thank you. One question. In a memory debugger, IDRA, X64 how can I individuate the heap and the stack

giovanniguarino
ะะฒั‚ะพั€

Please note as mentioned below user...when GLOBAL /STATIC Variables which are initialised to ZERO it will sit inside BSS (because it was initialized to 0). Other than 0 mean Initialized Data segment

arvindsorab
ะะฒั‚ะพั€

Great explanation ๐——๐—ฒ๐˜ƒ, cleanly explained with example
At some point in the series could you kindly explain about ELF format details (covering File, Program, Section - header(s), DWARF)

Sai-Akula
ะะฒั‚ะพั€

Hello, I have a doubt regarding the address that all the sections of an executable is assigned. Let say the all the segments of the binary gets the address by the linker but how does it know that the assigned address is not being used by some other process already, does it do some kind of preemption when the process is loaded or there is something else I am missing??

SudhirPatel
ะะฒั‚ะพั€

hello sir, I have a doubt regarding c/c++, I am into embedded system so how can I fine tune my c skill at this point of time I am struggling in c ( runs on mcu) as there are not much scope to practice ..for example :- I wrote a control algorithm for xyz things now I need data logging feature so now I got stuck into fatfs things like is it normal to struggle this much in new things? and tell me something to fine tune my emb c skills

deveshshevde-cpxq
ะะฒั‚ะพั€

@13:49 Aren't global/static variables that are explicitly initialized to 0 (like the variables c and r in your example) stored in the bss segment? Please correct me if I am wrong

nitpal
ะะฒั‚ะพั€

Awesome, it would be much better if you shared with us the pdf to be as a revision โค

MAShams
ะะฒั‚ะพั€

Volume is very much low in the video not able to hear with earphones as well.

suffiyanshaikh
ะะฒั‚ะพั€

I thought return address was in a register

Brad_Script
visit shbcf.ru