public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* support for MSVC-style sub-section merging
@ 2004-07-07 11:50 Jan Beulich
  2004-07-07 12:04 ` Joseph S. Myers
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2004-07-07 11:50 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2261 bytes --]

For targets with linkers that support MSVC/COFF (I'm unsure of exactly
what
origin this is) style section merging, this adds respective support.
The soon
to be submitted NetWare target patch will make use of this.

2004-07-07 Jan Beulich <jbeulich@novell.com>

	* varasm.c (MERGE_SECTIOHN_SEPARATOR): Default to '.'. Use for
	.rodata, .dtors, and .ctors sub-sections.

---
/home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/varasm.c	2004-07-02
15:14:19.000000000 +0200
+++ 2004-07-05.10.09/gcc/varasm.c	2004-07-06 08:39:39.686007968
+0200
@@ -61,6 +61,10 @@
 #define ASM_STABS_OP "\t.stabs\t"
 #endif
 
+#ifndef MERGE_SECTION_SEPARATOR
+#define MERGE_SECTION_SEPARATOR "."
+#endif
+
 /* The (assembler) name of the first globally-visible object output. 
*/
 const char *first_global_object_name;
 const char *weak_global_object_name;
@@ -595,7 +599,7 @@
 	    }
 	  if (i == len - unit)
 	    {
-	      sprintf (name, ".rodata.str%d.%d", modesize / 8,
+	      sprintf (name, ".rodata"MERGE_SECTION_SEPARATOR"str%d.%d",
modesize / 8,
 		       (int) (align / 8));
 	      flags |= (modesize / 8) | SECTION_MERGE |
SECTION_STRINGS;
 	      if (!i && modesize < align)
@@ -645,7 +649,7 @@
     {
       char name[24];
 
-      sprintf (name, ".rodata.cst%d", (int) (align / 8));
+      sprintf (name, ".rodata"MERGE_SECTION_SEPARATOR"cst%d", (int)
(align / 8));
       flags |= (align / 8) | SECTION_MERGE;
       named_section_flags (name, flags);
       return;
@@ -940,7 +944,7 @@
   /* ??? This only works reliably with the GNU linker.  */
   if (priority != DEFAULT_INIT_PRIORITY)
     {
-      sprintf (buf, ".dtors.%.5u",
+      sprintf (buf, ".dtors"MERGE_SECTION_SEPARATOR"%.5u",
 	       /* Invert the numbering so the linker puts us in the
proper
 		  order; constructors are run from right to left, and
the
 		  linker sorts in increasing order.  */
@@ -997,7 +1001,7 @@
   /* ??? This only works reliably with the GNU linker.  */
   if (priority != DEFAULT_INIT_PRIORITY)
     {
-      sprintf (buf, ".ctors.%.5u",
+      sprintf (buf, ".ctors"MERGE_SECTION_SEPARATOR"%.5u",
 	       /* Invert the numbering so the linker puts us in the
proper
 		  order; constructors are run from right to left, and
the
 		  linker sorts in increasing order.  */


[-- Attachment #2: gcc-mainline-merge-section-separator.patch --]
[-- Type: application/octet-stream, Size: 2260 bytes --]

For targets with linkers that support MSVC/COFF (I'm unsure of exactly what
origin this is) style section merging, this adds respective support. The soon
to be submitted NetWare target patch will make use of this.

2004-07-07 Jan Beulich <jbeulich@novell.com>

	* varasm.c (MERGE_SECTIOHN_SEPARATOR): Default to '.'. Use for
	.rodata, .dtors, and .ctors sub-sections.

--- /home/jbeulich/src/gcc/mainline/2004-07-05.10.09/gcc/varasm.c	2004-07-02 15:14:19.000000000 +0200
+++ 2004-07-05.10.09/gcc/varasm.c	2004-07-06 08:39:39.686007968 +0200
@@ -61,6 +61,10 @@
 #define ASM_STABS_OP "\t.stabs\t"
 #endif
 
+#ifndef MERGE_SECTION_SEPARATOR
+#define MERGE_SECTION_SEPARATOR "."
+#endif
+
 /* The (assembler) name of the first globally-visible object output.  */
 const char *first_global_object_name;
 const char *weak_global_object_name;
@@ -595,7 +599,7 @@
 	    }
 	  if (i == len - unit)
 	    {
-	      sprintf (name, ".rodata.str%d.%d", modesize / 8,
+	      sprintf (name, ".rodata"MERGE_SECTION_SEPARATOR"str%d.%d", modesize / 8,
 		       (int) (align / 8));
 	      flags |= (modesize / 8) | SECTION_MERGE | SECTION_STRINGS;
 	      if (!i && modesize < align)
@@ -645,7 +649,7 @@
     {
       char name[24];
 
-      sprintf (name, ".rodata.cst%d", (int) (align / 8));
+      sprintf (name, ".rodata"MERGE_SECTION_SEPARATOR"cst%d", (int) (align / 8));
       flags |= (align / 8) | SECTION_MERGE;
       named_section_flags (name, flags);
       return;
@@ -940,7 +944,7 @@
   /* ??? This only works reliably with the GNU linker.  */
   if (priority != DEFAULT_INIT_PRIORITY)
     {
-      sprintf (buf, ".dtors.%.5u",
+      sprintf (buf, ".dtors"MERGE_SECTION_SEPARATOR"%.5u",
 	       /* Invert the numbering so the linker puts us in the proper
 		  order; constructors are run from right to left, and the
 		  linker sorts in increasing order.  */
@@ -997,7 +1001,7 @@
   /* ??? This only works reliably with the GNU linker.  */
   if (priority != DEFAULT_INIT_PRIORITY)
     {
-      sprintf (buf, ".ctors.%.5u",
+      sprintf (buf, ".ctors"MERGE_SECTION_SEPARATOR"%.5u",
 	       /* Invert the numbering so the linker puts us in the proper
 		  order; constructors are run from right to left, and the
 		  linker sorts in increasing order.  */

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

* Re: support for MSVC-style sub-section merging
  2004-07-07 11:50 support for MSVC-style sub-section merging Jan Beulich
@ 2004-07-07 12:04 ` Joseph S. Myers
  0 siblings, 0 replies; 5+ messages in thread
From: Joseph S. Myers @ 2004-07-07 12:04 UTC (permalink / raw)
  To: Jan Beulich; +Cc: gcc-patches

On Wed, 7 Jul 2004, Jan Beulich wrote:

> 2004-07-07 Jan Beulich <jbeulich@novell.com>
> 
> 	* varasm.c (MERGE_SECTIOHN_SEPARATOR): Default to '.'. Use for
                                ^typo                     ^^^ you mean "."

> 	.rodata, .dtors, and .ctors sub-sections.

All target macros must be documented in tm.texi, as explained in
codingconventions.html.  The preference is for target hooks rather than
target macros unless there's a plausible case for any performance impact
from using a hook, which I don't think there is here.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

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

* Re: support for MSVC-style sub-section merging
@ 2004-07-12 11:05 Jan Beulich
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2004-07-12 11:05 UTC (permalink / raw)
  To: jsm; +Cc: gcc-patches

>> Second try. It still had to become atarget macro, in order to be able
to
>> concatenate it with other string constants. Bootstrapped and tested
on
>> i686-pc-linux-gnu. Jan
>
>It doesn't need concatenating, it could be included in the output
strings
>using %s in the printf formats, but I'll leave it to whoever reviews
this
>patch to decide what they think on the matter.

Only for the uses you see in that patch. The NetWare patch, however,
also tags this to ".eh_frame", which is only a string literal.

Jan

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

* Re: support for MSVC-style sub-section merging
  2004-07-12  8:24 Jan Beulich
@ 2004-07-12  9:21 ` Joseph S. Myers
  0 siblings, 0 replies; 5+ messages in thread
From: Joseph S. Myers @ 2004-07-12  9:21 UTC (permalink / raw)
  To: Jan Beulich; +Cc: gcc-patches

On Mon, 12 Jul 2004, Jan Beulich wrote:

> Second try. It still had to become atarget macro, in order to be able to
> concatenate it with other string constants. Bootstrapped and tested on
> i686-pc-linux-gnu. Jan

It doesn't need concatenating, it could be included in the output strings
using %s in the printf formats, but I'll leave it to whoever reviews this
patch to decide what they think on the matter.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

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

* Re: support for MSVC-style sub-section merging
@ 2004-07-12  8:24 Jan Beulich
  2004-07-12  9:21 ` Joseph S. Myers
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2004-07-12  8:24 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 944 bytes --]

Second try. It still had to become atarget macro, in order to be able to
concatenate it with other string constants. Bootstrapped and tested on
i686-pc-linux-gnu. Jan

>>> "Joseph S. Myers" <jsm@polyomino.org.uk> 07.07.04 13:51:53 >>>
On Wed, 7 Jul 2004, Jan Beulich wrote:

> 2004-07-07 Jan Beulich <jbeulich@novell.com>
> 
> 	* varasm.c (MERGE_SECTIOHN_SEPARATOR): Default to '.'. Use for
                                ^typo                     ^^^ you mean
"."

> 	.rodata, .dtors, and .ctors sub-sections.

All target macros must be documented in tm.texi, as explained in
codingconventions.html.  The preference is for target hooks rather
than
target macros unless there's a plausible case for any performance
impact
from using a hook, which I don't think there is here.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/ 
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

[-- Attachment #2: gcc-mainline-sub-section-separator.patch --]
[-- Type: application/octet-stream, Size: 3550 bytes --]

For targets with linkers that support MSVC/COFF (I'm unsure of exactly what
origin this is) style section merging, this adds respective support. The soon
to be submitted NetWare target patch will make use of this.

2004-07-07 Jan Beulich <jbeulich@novell.com>

	* defaults.h (TARGET_SUB_SECTION_SEPARATOR): Provide default of ".".
	* varasm.c (mergeable_string_section, mergeable_constant_section,
	default_named_section_asm_out_destructor,
	default_named_section_asm_out_constructor): Use
	TARGET_SUB_SECTION_SEPARATOR.
	* doc/tm.texi: Document TARGET_SUB_SECTION_SEPARATOR.

diff -Naur 2004-07-09.12.23/gcc/defaults.h sub-section/gcc/defaults.h
--- 2004-07-09.12.23/gcc/defaults.h	2004-06-07 11:55:52.000000000 +0200
+++ sub-section/gcc/defaults.h	2004-07-09 15:00:42.885883808 +0200
@@ -328,6 +328,10 @@
 #endif
 #endif
 
+#ifndef TARGET_SUB_SECTION_SEPARATOR
+#define TARGET_SUB_SECTION_SEPARATOR "."
+#endif
+
 /* By default, we generate a label at the beginning and end of the
    text section, and compute the size of the text section by
    subtracting the two.  However, on some platforms that doesn't 
diff -Naur 2004-07-09.12.23/gcc/doc/tm.texi sub-section/gcc/doc/tm.texi
--- 2004-07-09.12.23/gcc/doc/tm.texi	2004-07-07 15:59:38.000000000 +0200
+++ sub-section/gcc/doc/tm.texi	2004-07-08 16:35:55.000000000 +0200
@@ -7626,6 +7626,12 @@
 directive followed by a synthetic label.
 @end deftypefn
 
+@deftypevr {Target Hook} {const char *} TARGET_SUB_SECTION_SEPARATOR
+If defined, a C string constant for the separator character(s) necessary
+between the base section name and the sub-section identifier.  If not
+defined, GCC will provide a default definition of ".".
+@end deftypevr
+
 @deftypevar {Target Hook} bool TARGET_TERMINATE_DW2_EH_FRAME_INFO
 Contains the value true if the target should add a zero word onto the
 end of a Dwarf-2 frame info section when used for exception handling.
diff -Naur 2004-07-09.12.23/gcc/varasm.c sub-section/gcc/varasm.c
--- 2004-07-09.12.23/gcc/varasm.c	2004-07-09 12:17:14.000000000 +0200
+++ sub-section/gcc/varasm.c	2004-07-09 12:48:00.741313768 +0200
@@ -595,7 +595,7 @@
 	    }
 	  if (i == len - unit)
 	    {
-	      sprintf (name, ".rodata.str%d.%d", modesize / 8,
+	      sprintf (name, ".rodata"TARGET_SUB_SECTION_SEPARATOR"str%d.%d", modesize / 8,
 		       (int) (align / 8));
 	      flags |= (modesize / 8) | SECTION_MERGE | SECTION_STRINGS;
 	      if (!i && modesize < align)
@@ -645,7 +645,7 @@
     {
       char name[24];
 
-      sprintf (name, ".rodata.cst%d", (int) (align / 8));
+      sprintf (name, ".rodata"TARGET_SUB_SECTION_SEPARATOR"cst%d", (int) (align / 8));
       flags |= (align / 8) | SECTION_MERGE;
       named_section_flags (name, flags);
       return;
@@ -940,7 +940,7 @@
   /* ??? This only works reliably with the GNU linker.  */
   if (priority != DEFAULT_INIT_PRIORITY)
     {
-      sprintf (buf, ".dtors.%.5u",
+      sprintf (buf, ".dtors"TARGET_SUB_SECTION_SEPARATOR"%.5u",
 	       /* Invert the numbering so the linker puts us in the proper
 		  order; constructors are run from right to left, and the
 		  linker sorts in increasing order.  */
@@ -997,7 +997,7 @@
   /* ??? This only works reliably with the GNU linker.  */
   if (priority != DEFAULT_INIT_PRIORITY)
     {
-      sprintf (buf, ".ctors.%.5u",
+      sprintf (buf, ".ctors"TARGET_SUB_SECTION_SEPARATOR"%.5u",
 	       /* Invert the numbering so the linker puts us in the proper
 		  order; constructors are run from right to left, and the
 		  linker sorts in increasing order.  */

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

end of thread, other threads:[~2004-07-12  8:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-07 11:50 support for MSVC-style sub-section merging Jan Beulich
2004-07-07 12:04 ` Joseph S. Myers
2004-07-12  8:24 Jan Beulich
2004-07-12  9:21 ` Joseph S. Myers
2004-07-12 11:05 Jan Beulich

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).