[Bug target/98146] [11 Regression] section type conflict when "used" attribute is applied to decl with specific section

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Dec 16 13:43:54 GMT 2020


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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:151d1347c99acfcf0f5bcd8caac36dcc7353816d

commit r11-6142-g151d1347c99acfcf0f5bcd8caac36dcc7353816d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Dec 14 20:10:13 2020 -0800

    Require .init_array/.fini_array support for SHF_GNU_RETAIN

    Since SHF_GNU_RETAIN support doesn't work for crtstuff.c which switches
    the output section directly with asm statement:

    ---
    static void __attribute__((used))
    __do_global_dtors_aux (void)
    {
      static _Bool completed;

      if (__builtin_expect (completed, 0))
        return;
      completed = 1;
    }

    static void __attribute__((__used__))
    call___do_global_dtors_aux (void)
    {
      asm ("\t.section\t.fini");
      __do_global_dtors_aux ();
      asm ("\t.section\t.text");
    }
    ---

    use SHF_GNU_RETAIN only if .init_array/.fini_array section is supported.

    gcc/

            PR target/98146
            * defaults.h (SUPPORTS_SHF_GNU_RETAIN): New.
            * varasm.c (get_section): Replace HAVE_GAS_SHF_GNU_RETAIN with
            SUPPORTS_SHF_GNU_RETAIN.
            (resolve_unique_section): Likewise.
            (get_variable_section): Likewise.
            (switch_to_section): Likewise.

    gcc/testsuite/

            PR target/98146
            * lib/target-supports.exp
            (check_effective_target_R_flag_in_section): Also check
            HAVE_INITFINI_ARRAY_SUPPORT != 0.


More information about the Gcc-bugs mailing list