Chapter 3 Algorithms | 3.9
Example
#include<stdio.h>
#include<stdlib.h>
#define PI 3.141 /*rodata*/
int a; /*bss section*/
int b=10; /*data section*/
static int c=20;/*data section*/
int main()
{
char name[10];/*stack*/
cout<<”%d %d”<<b<<c;/*rodata*/
}
Sections
Idx Name Size VMA LMA File off Algn
0 .text 0000003e 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .data 00000008 00000000 00000000 00000074 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000004 00000000 00000000 0000007c 2**2
ALLOC
3 .rodata 00000006 00000000 00000000 0000007c 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
Data space
size (data) + size (rodata) + size (bss) = 8 + 6 + 4 = 18 bytes
Instruction space
(3e)
16
= 62 bytes
Stack space
4 Bytes Frame P ...