[Top][All Lists]

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

Re: [avr-gcc-list] When does __do_copy_data get inserted

From: Dylan McKay
Subject: Re: [avr-gcc-list] When does __do_copy_data get inserted
Date: Mon, 11 Sep 2017 21:28:51 +1200

I've figured it out, thanks for all the help guys!

On Sat, Sep 2, 2017 at 7:15 PM, Senthil Kumar <address@hidden> wrote:

  The part you're missing is the avr_need_copy_data_p global. It's set to false by default, and is set to true inside hooks that gcc calls whenever it needs to put something in data related sections. The avr_file_end hook function checks the variable and emits a reference to a global "__do_copy_data" only if avr_need_copy_data_p is true. The reference then causes the linker to pull in the implementation of __do_coy_data from libgcc.a(_copy_data.o).

  The compiler uses the same trick to decide whether to pull in code to clear bss or not - see avr_need_clear_bss_p.

  In both cases, the idea is to avoid linking in the copy/clearing code if it's unnecessary (no initialized/zero initialized globals).

  Hope this helps.


On Thu, Aug 24, 2017 at 7:54 PM, Dylan McKay <address@hidden> wrote:
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

reply via email to

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