All these are talking about ELF details. On Wed, Mar 12, 2008 at 3:14 PM, srimugunthan dhandapani <muggy.mit@xxxxxxxxx> wrote: > Hi all, > Can anybody explain what is the advantage of using a separate segment(Bss) > for uninitialised variables and a seperate segment(data) for initialised > variables.Why not have a single segment? > same question as asking why there exists exists data + text + bss segment. 1 possible reason is because u would like to to have data as data, and not some executable codes inside there. in buffer overflow or shellcode execution (trojan) scenario, the data can be executed by the CPU. if u have such enforcement then this scenario will not happened. (btw....x86 does not OBEY the enforcement, ie, as below, sections marked as "readonly", can still be executed by the CPU. Sections: Idx Name Size VMA LMA File off Algn 0 .interp 00000013 08048134 08048134 00000134 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 1 .note.ABI-tag 00000020 08048148 08048148 00000148 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 2 .gnu.hash 000000bc 08048168 08048168 00000168 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .dynsym 00000880 08048224 08048224 00000224 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 4 .dynstr 00000efe 08048aa4 08048aa4 00000aa4 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 5 .gnu.version 00000110 080499a2 080499a2 000019a2 2**1 CONTENTS, ALLOC, LOAD, READONLY, D 23 .data 00000034 080792d4 080792d4 000312d4 2**2 CONTENTS, ALLOC, LOAD, DATA 24 .bss 00010234 08079320 08079320 00031308 2**5 ALLOC 25 .comment 00000142 00000000 00000000 00031308 2**0 CONTENTS, READONLY > I learnt from the web that "The advantage in using the bss segment for > storage that > starts off empty is that the initialization information need > not be stored in the output file." what is means is that if u declare a global variable in your program, or "static" as well it will goes into BSS segment, and u initilized it, then it will be set to the initial values -> inside the ELF (binary executeable) file. but if u don't initialized it, no physical space will be taken up by the ELF for it ---> essentially space saving for the physical file. when the loader load the executeable, memory still will be allocated to it. > > But i dont understand to which output file they are talking about , and the > initialisation information is written to. > Can anybody explain it further ? > Thanks, > Mugunthan > -- Regards, Peter Teoh -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ