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]

[PATCH] Fix .lbss handling on x86-64 (PR target/58218)


Hi!

On the following testcase we generate
.section        .lbss,"aw",@progbits
which causes assembler warning, it is supposed to be
.section        .lbss,"aw",@nobits
instead.  The following patch fixes that.  I went through all of
default_section_type_flags and looked for which sections the default
decision is based on section name and which sections have large data
counterparts on x86-64 and I hope I've caught up all of them.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8?

2013-08-23  Jakub Jelinek  <jakub@redhat.com>

	PR target/58218
	* config/i386/x86-64.h (TARGET_SECTION_TYPE_FLAGS): Define.
	* config/i386/i386.c (x86_64_elf_section_type_flags): New function.

	* gcc.target/i386/pr58218.c: New test.

--- gcc/config/i386/x86-64.h.jj	2013-04-25 23:47:56.000000000 +0200
+++ gcc/config/i386/x86-64.h	2013-08-22 20:15:12.197344591 +0200
@@ -103,3 +103,6 @@ see the files COPYING3 and COPYING.RUNTI
 
 #undef TARGET_ASM_UNIQUE_SECTION
 #define TARGET_ASM_UNIQUE_SECTION  x86_64_elf_unique_section
+
+#undef TARGET_SECTION_TYPE_FLAGS
+#define TARGET_SECTION_TYPE_FLAGS  x86_64_elf_section_type_flags
--- gcc/config/i386/i386.c.jj	2013-08-22 20:30:09.206333231 +0200
+++ gcc/config/i386/i386.c	2013-08-22 22:25:53.249919215 +0200
@@ -4912,6 +4912,31 @@ x86_64_elf_select_section (tree decl, in
   return default_elf_select_section (decl, reloc, align);
 }
 
+/* Select a set of attributes for section NAME based on the properties
+   of DECL and whether or not RELOC indicates that DECL's initializer
+   might contain runtime relocations.  */
+
+static unsigned int x86_64_elf_section_type_flags (tree, const char *, int)
+	ATTRIBUTE_UNUSED;
+
+static unsigned int
+x86_64_elf_section_type_flags (tree decl, const char *name, int reloc)
+{
+  unsigned int flags = default_section_type_flags (decl, name, reloc);
+
+  if (decl == NULL_TREE
+      && (strcmp (name, ".ldata.rel.ro") == 0
+	  || strcmp (name, ".ldata.rel.ro.local") == 0))
+    flags |= SECTION_RELRO;
+
+  if (strcmp (name, ".lbss") == 0
+      || strncmp (name, ".lbss.", 5) == 0
+      || strncmp (name, ".gnu.linkonce.lb.", 16) == 0)
+    flags |= SECTION_BSS;
+
+  return flags;
+}
+
 /* Build up a unique section name, expressed as a
    STRING_CST node, and assign it to DECL_SECTION_NAME (decl).
    RELOC indicates whether the initial value of EXP requires
--- gcc/testsuite/gcc.target/i386/pr58218.c.jj	2013-08-22 20:26:56.827563563 +0200
+++ gcc/testsuite/gcc.target/i386/pr58218.c	2013-08-22 20:26:48.000000000 +0200
@@ -0,0 +1,5 @@
+/* PR target/58218 */
+/* { dg-do assemble { target lp64 } } */
+/* { dg-options "-mcmodel=medium" } */
+
+struct { float x[16385]; } a = { { 0.f, } };

	Jakub


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