This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: default_elf_select_section
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org, Richard Henderson <rth at redhat dot com>
- Date: Mon, 29 Nov 2004 21:30:44 +1030
- Subject: Re: default_elf_select_section
- References: <20041128035022.GB20149@bubble.modra.org> <20041128075844.GA16073@redhat.com> <20041128225103.GA20620@bubble.modra.org> <je653pndqr.fsf@sykes.suse.de>
On Mon, Nov 29, 2004 at 11:36:28AM +0100, Andreas Schwab wrote:
> Alan Modra <amodra@bigpond.net.au> writes:
>
> > This fixes the assembler complaint in pr9571 by giving
> > targetm.section_type_flags the decl that it needs. See
> > default_section_type_flags_1. No problems fould with powerpc-linux
> > and powerpc64-linux bootstraps and regression tests.
> >
> > PR target/9571
> > * varasm.c (default_elf_select_section_1): Pass decl to named_section.
>
> Breaks libgfortran on ia64.
>
> ../../../libgfortran/generated/product_c4.c: In function '__product_c4':
> ../../../libgfortran/generated/product_c4.c:143: internal compiler error: in named_section, at varasm.c:451
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL:http://gcc.gnu.org/bugs.html> for instructions.
>
> The decl is actually a COMPLEX_CST, i.e. not a DECL_P.
Ugh. So we've found why the decl isn't passed..
This should fix it.
* varasm.c (default_elf_select_section_1): Only pass DECL_P decl
to named_section.
Index: gcc/varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.461
diff -u -p -r1.461 varasm.c
--- gcc/varasm.c 19 Nov 2004 13:12:38 -0000 1.461
+++ gcc/varasm.c 29 Nov 2004 10:57:36 -0000
@@ -4897,6 +4897,7 @@ void
default_elf_select_section_1 (tree decl, int reloc,
unsigned HOST_WIDE_INT align, int shlib)
{
+ const char *sname;
switch (categorize_decl_for_section (decl, reloc, shlib))
{
case SECCAT_TEXT:
@@ -4904,56 +4905,61 @@ default_elf_select_section_1 (tree decl,
abort ();
case SECCAT_RODATA:
readonly_data_section ();
- break;
+ return;
case SECCAT_RODATA_MERGE_STR:
mergeable_string_section (decl, align, 0);
- break;
+ return;
case SECCAT_RODATA_MERGE_STR_INIT:
mergeable_string_section (DECL_INITIAL (decl), align, 0);
- break;
+ return;
case SECCAT_RODATA_MERGE_CONST:
mergeable_constant_section (DECL_MODE (decl), align, 0);
- break;
+ return;
case SECCAT_SRODATA:
- named_section (NULL_TREE, ".sdata2", reloc);
+ sname = ".sdata2";
break;
case SECCAT_DATA:
data_section ();
- break;
+ return;
case SECCAT_DATA_REL:
- named_section (NULL_TREE, ".data.rel", reloc);
+ sname = ".data.rel";
break;
case SECCAT_DATA_REL_LOCAL:
- named_section (NULL_TREE, ".data.rel.local", reloc);
+ sname = ".data.rel.local";
break;
case SECCAT_DATA_REL_RO:
- named_section (NULL_TREE, ".data.rel.ro", reloc);
+ sname = ".data.rel.ro";
break;
case SECCAT_DATA_REL_RO_LOCAL:
- named_section (NULL_TREE, ".data.rel.ro.local", reloc);
+ sname = ".data.rel.ro.local";
break;
case SECCAT_SDATA:
- named_section (NULL_TREE, ".sdata", reloc);
+ sname = ".sdata";
break;
case SECCAT_TDATA:
- named_section (NULL_TREE, ".tdata", reloc);
+ sname = ".tdata";
break;
case SECCAT_BSS:
#ifdef BSS_SECTION_ASM_OP
bss_section ();
+ return;
#else
- named_section (NULL_TREE, ".bss", reloc);
-#endif
+ sname = ".bss";
break;
+#endif
case SECCAT_SBSS:
- named_section (NULL_TREE, ".sbss", reloc);
+ sname = ".sbss";
break;
case SECCAT_TBSS:
- named_section (NULL_TREE, ".tbss", reloc);
+ sname = ".tbss";
break;
default:
abort ();
}
+
+ if (!DECL_P (decl))
+ decl = NULL_TREE;
+ named_section (decl, sname, reloc);
}
/* Construct a unique section name based on the decl name and the
--
Alan Modra
IBM OzLabs - Linux Technology Centre