CPSC 355 Lecture Notes - Lecture 25: .Bss, Global Variable, Segmentation Fault
Document Summary
Cpsc 355 - lecture 25 nov 14th. Global variables: scope: global (from declaration onwards, lifetime: life of program, are stored in a separate section of ram, eg: // global variable int val; main( ) { int f( ) { val = 3; int a; a = val; Static global variables: scope: local to file (from declaration onwards, lifetime: life of program, stored in a separate section of ram, eg: // global static variable static int val main( ) { val = 3; Programs may allocate 3 sections of memory: text. Attempts to write to this memory causes segmentation fault: data. Is read/write memory: bss (block starting symbol) These sections are located in low memory, just after the section reserved for the os kernel: low. Pseudo-ops are used to indicate that what follows goes into a particular section: . text. Is the default section when assembling: . data, . bss.