When does __do_copy_data get inserted

Dylan McKay <[email protected]> Fri, 25 Aug 2017 02:24:03 +1200
Newsgroups gmane.comp.hardware.avr.gcc
Message-ID <CAMizNntTofTbev9S9BCxtnMPBBQn85QeMBRyRqOcmYq=1nsvYw@mail.gmail.com>
Hello all,

I maintain the AVR LLVM backend, for which downstream users typically use
avr-gcc to link, so they get the CRT, startup routines, and libgcc.

I've noticed that AVR-GCC does not insert the __do_copy_data function for
LLVM generated executables, but it does for GCC generated ones.

In case reads have not heard of this function, it is one of a few small
routines which copies all variables from the .data, .rodata, and .bss in
program memory into RAM during startup.

When does AVR-GCC insert __do_copy_data? How do I need to tune the output
of LLVM in order to trigger GCC's insertion of this function?

I've looked at the GCC source and as far as I can tell, the logic is based
in 'avr_asm_named_section' in 'gcc/config/avr/avr.c'. The code I can see
just looks at the section names, sees if it can find sections prefixed with
'.rodata', '.data', or '.bss'.

The LLVM backend is correctly placing my global variable into a section
prefixed with '.data', but linking with avr-gcc still does not include
__do_copy_data.

I have attached the output of 'objdump -t' for my reference LLVM and GCC
program. They are not identical, but they both read from a global variable
named 'FOO'.

_______________________________________________
AVR-GCC-list mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
blink.gcc.o.objdump (application/octet-stream, 577 B) - not displayed
blink.llvm.o.objdump (application/octet-stream, 8.8 KB) - not displayed