char fred __attribute__((section(".noinit")));
.file "noinit.c" __SP_H__ = 0x3e __SP_L__ = 0x3d __SREG__ = 0x3f __tmp_reg__ = 0 __zero_reg__ = 1 .global fred .section .noinit,"aw",@nobits .type fred, @object .size fred, 1 fred: .zero 1 .ident "GCC: (AVR_8_bit_GNU_Toolchain_3.6.1_1750) 5.4.0"
Given the purpose of the .noinit section,
clearly no zeros will be headed fred's way.
Given the way data is initialized on AVRs,
I'm not surprised it works.
'Tain't obvious that combining @nobits and .zero is valid.
I've been looking for a convenient way to specify
"empty" flash sections that will not add to the .hex file.
Should something similar work?
I'm thinking of something like this:
.global greg .section sectionstarttarget,"a",@nobits .type greg, @object .size greg, 2560 greg: .zero 2560 .section code, "ax",@progbits ldi r16, 0
The "empty" sections will be targets of SPM instructions.
I want the sections to ensure that if I mess up locating them,
the linker will tell me about section overlaps.
They will also serve somewhat as documentation.
Experiment suggests that the above will do what I want,
even though it's telling the toolchain to put zeros in a place with no bits.
Is it a fluke?
Is it something that should be relied on to work in the future?
So far, I've not found an explicit statement that combining
@nobits and data-generating instructions is even valid.