This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PowerPC [target/17828] -O2 -fPIC doesn't work with switches in linkonce functions and new binutils


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]