[patch mingw/cygwin]: Allow relocated const data to be put in read-only section by default

Kai Tietz ktietz70@googlemail.com
Sat Mar 3 09:32:00 GMT 2012


Hi,

this patch allows that relocated const data is placed into .rdata.  To provide
old behavior for older runtimes not supporting pseudo-relocation operating on
read-only sections, the option -fwritable-relocated-rdata can be used.

ChangeLog

2012-03-03  Kai Tietz  <ktietz@redhat.com>

	* doc/invoke.texi (fwritable-relocated-rdata): Document
	new Cygwin/MinGW target option.
	* config/i386/winnt.c (i386_pe_unique_section): Ignore
	reloc if flag -fwritable-relocated-rdata is not set.
	(i386_pe_section_type_flags): Likewise.
	* config/i386/cygming.opt (fwritable-relocated-rdata):
	Add new flag variable flag_writable_rel_rdata.

Tested for i686-w64-mingw32, x86_64-w64-mingw32, and i686-pc-cygwin.
Ok for apply?

Regards,
Kai

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 184760)
+++ doc/invoke.texi	(working copy)
@@ -13826,6 +13826,13 @@
 Windows, as there the user32 API, which is used to set executable
 privileges, isn't available.

+@item -fwritable-relocated-rdata
+@opindex fno-writable-relocated-rdata
+This option is available for MinGW and Cygwin targets.  It specifies
+that relocated-data in read-only section is put into .data
+section.  This is a necessary for older runtimes not supporting
+modification of .rdata sections for pseudo-relocation.
+
 @item -mpe-aligned-commons
 @opindex mpe-aligned-commons
 This option is available for Cygwin and MinGW targets.  It
Index: config/i386/winnt.c
===================================================================
--- config/i386/winnt.c	(revision 184760)
+++ config/i386/winnt.c	(working copy)
@@ -395,6 +395,10 @@
   const char *name, *prefix;
   char *string;

+  /* Ignore RELOC, if we are allowed to put relocated
+     const data into read-only section.  */
+  if (!flag_writable_rel_rdata)
+    reloc = 0;
   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
   name = i386_pe_strip_name_encoding_full (name);

@@ -441,6 +445,10 @@
   unsigned int flags;
   unsigned int **slot;

+  /* Ignore RELOC, if we are allowed to put relocated
+     const data into read-only section.  */
+  if (!flag_writable_rel_rdata)
+    reloc = 0;
   /* The names we put in the hashtable will always be the unique
      versions given to us by the stringtable, so we can just use
      their addresses as the keys.  */
Index: config/i386/cygming.opt
===================================================================
--- config/i386/cygming.opt	(revision 184760)
+++ config/i386/cygming.opt	(working copy)
@@ -53,4 +53,8 @@
 posix
 Driver

+fwritable-relocated-rdata
+Common Report Var(flag_writable_rel_rdata) Init(0)
+Put relocated read-only data into .data section.
+
 ; Retain blank line above



More information about the Gcc-patches mailing list