This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PowerPC [target/17828] -O2 -fPIC doesn't work with switches in linkonce functions and new binutils
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 27 Jul 2005 03:15:11 -0400
- Subject: Re: PowerPC [target/17828] -O2 -fPIC doesn't work with switches in linkonce functions and new binutils
- References: <20050727022115.GB21279@bubble.grove.modra.org>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Jul 27, 2005 at 11:51:15AM +0930, Alan Modra wrote:
> +#if HAVE_LD_MULT_GOT2 && HAVE_COMDAT_GROUP
> +/* If function text will be placed in separate sections, then place
> + toc entries for the function in separate sections too. */
> +#undef TOC_PER_FUNCTION
> +#define TOC_PER_FUNCTION \
> + (TARGET_ELF \
> + && DEFAULT_ABI == ABI_V4 \
> + && flag_pic == 2 \
> + && cfun != NULL \
> + && cfun->decl != NULL \
> + && (DECL_ONE_ONLY (cfun->decl) \
> + || (flag_function_sections && flag_data_sections)))
> +#endif
Couldn't we have a definition also for
!HAVE_LD_MULT_GOT2 && HAVE_COMDAT_GROUP? In that case it couldn't
handle (flag_function_sections && flag_data_sections), just DECL_ONE_ONLY
(cfun->decl), by using .section .got2,"awG",[comdat_group],comdat.
> +
> #define SDATA_SECTION_ASM_OP "\t.section\t\".sdata\",\"aw\""
> #define SDATA2_SECTION_ASM_OP "\t.section\t\".sdata2\",\"a\""
> #define SBSS_SECTION_ASM_OP "\t.section\t\".sbss\",\"aw\",@nobits"
> @@ -378,7 +392,38 @@ do { \
> void \
> toc_section (void) \
> { \
> - if (in_section != in_toc) \
> + if (TOC_PER_FUNCTION) \
> + { \
> + if (in_section != in_toc \
> + || toc_initialized != current_function_funcdef_no + 2) \
Isn't using just one global toc_initialized and not
cfun->machine->toc_initialized instead here too risky? It relies e.g.
on all non-TOC_PER_FUNCTION functions to be emitted first and then
TOC_PER_FUNCTION ones (otherwise e.g. DECL_ONE_ONLY's toc_section
would set toc_initialized to its number + 2 and later on when
!TOC_PER_FUNCTION, we would see toc_initialized != 0 and assume
the non-COMDAT .got2 doesn't have to be set up).
> + s = TREE_STRING_POINTER (DECL_SECTION_NAME (cfun->decl)); \
> + s = strchr (s + 1, '.'); \
> + if (s == NULL) \
> + s = ""; \
Can't we unconditionally use "" for DECL_ONE_ONLY functions (as COMDAT
will take care of its uniqueness)?
Jakub