https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122516

--- Comment #15 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #14)
> INIT_ARRAY was added to gABI more than 20 years ago.  Why can't it added to
> the avr target?
One reason is poor documentation what the stuff actually does. I found an entry
on stackoverflow that doesn't add much to understanding it.

In the case it's about execution of static constructors and destructors,
__do_global_c/dtors is implemented in asm, since it needs code that is not
expressible in C (24-bit addresses, special instructions, etc).  And GCC has
the tendancy to generate scrap... so I don't see real benefit in replacing
optimal asm with C from crtstuff.c since open coded C doesn't work to begin
with.

The avr backend doesn't even use crtstuff.c, it has in avr/elf.h

#undef INIT_SECTION_ASM_OP
#undef FINI_SECTION_ASM_OP

and only uses this in avr.cc:

/* Worker function for `TARGET_ASM_CONSTRUCTOR'.  */

static void
avr_asm_out_ctor (rtx symbol, int priority)
{
  fputs ("\t.global __do_global_ctors\n", asm_out_file);
  default_ctor_section_asm_out_constructor (symbol, priority);
}

Reply via email to