public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix a .data.rel.ro{,.local} section conflict issue (PR middle-end/47610)
@ 2011-02-05 17:04 Jakub Jelinek
  2011-02-05 17:27 ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2011-02-05 17:04 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches

Hi!

My recent PR31490 patch caused a regression on ppc and pa at least,
where gcc started complaining about section type conflicts on
.data.rel.ro{,.local} sections.
The problem is if get_section is called both from
default_elf_select_rtx_section where it is called with
.data.rel.ro{,.local} section but NULL decl, and with a decl
that belongs into the same section.  default_section_type_flags
would set SECTION_RELRO only if decl was non-NULL.

Fixed by oring in SECTION_RELRO for those two explicit sections too.

Bootstrapped/regtested on x86_64-linux and i686-linux, tested with a cross
on the pa testcase.

Ok for trunk?

2011-02-05  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/47610
	* varasm.c (default_section_type_flags): If decl is NULL,
	and name is .data.rel.ro or .data.rel.ro.local, set SECTION_RELRO
	bit.

--- gcc/varasm.c.jj	2011-02-03 20:09:38.000000000 +0100
+++ gcc/varasm.c	2011-02-05 00:01:59.911796344 +0100
@@ -6060,7 +6060,12 @@ default_section_type_flags (tree decl, c
 	flags = SECTION_WRITE;
     }
   else
-    flags = SECTION_WRITE;
+    {
+      flags = SECTION_WRITE;
+      if (strcmp (name, ".data.rel.ro") == 0
+	  || strcmp (name, ".data.rel.ro.local") == 0)
+	flags |= SECTION_RELRO;
+    }
 
   if (decl && DECL_ONE_ONLY (decl))
     flags |= SECTION_LINKONCE;

	Jakub

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix a .data.rel.ro{,.local} section conflict issue (PR middle-end/47610)
  2011-02-05 17:04 [PATCH] Fix a .data.rel.ro{,.local} section conflict issue (PR middle-end/47610) Jakub Jelinek
@ 2011-02-05 17:27 ` Jakub Jelinek
  2011-02-05 20:32   ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2011-02-05 17:27 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches

On Sat, Feb 05, 2011 at 06:04:24PM +0100, Jakub Jelinek wrote:
> My recent PR31490 patch caused a regression on ppc and pa at least,
> where gcc started complaining about section type conflicts on
> .data.rel.ro{,.local} sections.
> The problem is if get_section is called both from
> default_elf_select_rtx_section where it is called with
> .data.rel.ro{,.local} section but NULL decl, and with a decl
> that belongs into the same section.  default_section_type_flags
> would set SECTION_RELRO only if decl was non-NULL.
> 
> Fixed by oring in SECTION_RELRO for those two explicit sections too.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, tested with a cross
> on the pa testcase.

And this time with the testcase (while it was a bootstrap failure there,
it perhaps doesn't hurt to include it):

2011-02-05  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/47610
	* varasm.c (default_section_type_flags): If decl is NULL,
	and name is .data.rel.ro or .data.rel.ro.local, set SECTION_RELRO
	bit.

	* gcc.dg/pr47610.c: New test.

--- gcc/varasm.c.jj	2011-02-03 20:09:38.000000000 +0100
+++ gcc/varasm.c	2011-02-05 00:01:59.911796344 +0100
@@ -6060,7 +6060,12 @@ default_section_type_flags (tree decl, c
 	flags = SECTION_WRITE;
     }
   else
-    flags = SECTION_WRITE;
+    {
+      flags = SECTION_WRITE;
+      if (strcmp (name, ".data.rel.ro") == 0
+	  || strcmp (name, ".data.rel.ro.local") == 0)
+	flags |= SECTION_RELRO;
+    }
 
   if (decl && DECL_ONE_ONLY (decl))
     flags |= SECTION_LINKONCE;
--- gcc/testsuite/gcc.dg/pr47610.c.jj	2011-01-16 05:42:39.626675592 +0100
+++ gcc/testsuite/gcc.dg/pr47610.c	2011-02-05 18:21:14.971808340 +0100
@@ -0,0 +1,8 @@
+/* PR middle-end/47610 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fpic" { target fpic } } */
+struct S { const char *s; };
+const struct S s[] = { "s" };
+extern void foo (void (*) (void));
+static void bar (void) {}
+void baz () { foo (bar); }

	Jakub

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix a .data.rel.ro{,.local} section conflict issue (PR middle-end/47610)
  2011-02-05 17:27 ` Jakub Jelinek
@ 2011-02-05 20:32   ` Richard Henderson
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2011-02-05 20:32 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On 02/05/2011 09:27 AM, Jakub Jelinek wrote:
> 	PR middle-end/47610
> 	* varasm.c (default_section_type_flags): If decl is NULL,
> 	and name is .data.rel.ro or .data.rel.ro.local, set SECTION_RELRO
> 	bit.
> 
> 	* gcc.dg/pr47610.c: New test.


Ok.


r~

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-05 20:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-05 17:04 [PATCH] Fix a .data.rel.ro{,.local} section conflict issue (PR middle-end/47610) Jakub Jelinek
2011-02-05 17:27 ` Jakub Jelinek
2011-02-05 20:32   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).