avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] data segment init code & .data size calculations


From: Bernard Fouché
Subject: [avr-gcc-list] data segment init code & .data size calculations
Date: Thu, 9 Sep 2004 22:02:17 +0200

I'm compiling a program made of a dozen files, I'm looking everywhere for
the places where I could have a static or global initialized at a value
different of zero and I find none at the moment. But the final result
reports 4 bytes for the size of the .data segment. So I'm looking at the
.sym file and I read:

...[snip]...
00003dea T __epilogue_restores__
00003e20 A __data_load_start
00003e20 T _etext
00003e24 A __data_load_end
00800100 D __data_start
00800104 B __bss_start
00800104 D __data_end
00800104 D _edata
...[snip]...

(target is atmega162)

If I insert a global in one the files with a value different of zero, say
'int foo=12;' just before the main function, I have:

...[snip]...
00003e20 A __data_load_start
00003e20 T _etext
00003e26 A __data_load_end
00800100 D __data_start
00800100 D foo
00800106 B __bss_start
00800106 D __data_end
00800106 D _edata

And main.elf reports still 4 bytes of .data, so I'm a bit confused.

Now, while investigating about this, I found that compiling a fascinating
program like:

main(){}

and then looking at the compilation result, the .data segment is zero in
size but __do_copy_data, __do_copy_data_loop, etc. are still embedded in the
final object.

The point is that if a program does not set any global or static at a value
different of zero, the .data init code could be spared. (the same for .bss:
if a program is working only with locals: the .bss init code is still
bundled however I think that this case would be very rare!)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]