https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97771
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- What you are doing is certainly wrong. .init_array section needs to be @init_array, there is no way to create initialized variables in anything but @progbits. The section attribute doesn't have any list of magic sections that should be treated differently from anything else. constructor attribute indeed is only allowed on file-scope functions. Why don't you use inline asm? I'd suggest __asm (".section .init_array, \"aw\",%%init_array; .balign %P0; .%P0byte %P1; .previous" : : "i" (sizeof (void *)), "g" ((void *)&Local::init)); instead of your initp declaration.