bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gettext patches for cygwin #1: rdata


From: Charles Wilson
Subject: gettext patches for cygwin #1: rdata
Date: Sat, 19 Nov 2005 23:23:59 -0500
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

If gettext is compiled with gcc of 3.3 or later vintage, many of the application programs can not be executed. This problem is described here:

"Problem running xgettext after compiling gettext 0.14.1 with gcc 3.3.3"
http://www.cygwin.com/ml/cygwin/2005-02/msg00741.html

And the problem is diagnosed here:

"cygwin, libtool, dlpreopen, and .rdata"
http://sourceware.org/ml/cygwin/2004-09/msg01101.html

Basically, const structs are placed in .rdata by recent gcc's. Unfortunately, on cygwin the address fixups for complex data structures can't be performed on objects in .rdata -- so if the struct contains a reference to another variable (e.g. a long_option struct with the address of a target variable in its 'int *flag' field), then the application cannot be initialized.

At present, the only solution is to NOT declare such structures const. The attached patch defines these structs const only for platforms other than Win32 and Cygwin.

2005-11-19  Charles Wilson  <address@hidden>

        *  gettext-runtime/configure.ac: add definition for
        CONST_PROBLEMATIC_WIN32.
        * gettext-runtime/src/envsubst.c: use it instead of 'const'
        in long_options declaration.
        * gettext-runtime/src/gettext.c: ditto
        * gettext-runtime/src/ngettext.c: ditto
        * gettext-tools/configure.ac: add definition for
        CONST_PROBLEMATIC_WIN32
        * gettext-tools/src/hostname.c: use it instead of 'const'
        in long_options declaration.
        * gettext-tools/src/msgattrib.c: ditto
        * gettext-tools/src/msgcat.c: ditto
        * gettext-tools/src/msgcmp.c: ditto
        * gettext-tools/src/msgcomm.c: ditto
        * gettext-tools/src/msgconv.c: ditto
        * gettext-tools/src/msgen.c: ditto
        * gettext-tools/src/msgexec.c: ditto
        * gettext-tools/src/msgfilter.c: ditto
        * gettext-tools/src/msgfmt.c: ditto
        * gettext-tools/src/msggrep.c: ditto
        * gettext-tools/src/msginit.c: ditto
        * gettext-tools/src/msgmerge.c: ditto
        * gettext-tools/src/msgunfmt.c: ditto
        * gettext-tools/src/msguniq.c: ditto
        * gettext-tools/src/urlget.c: ditto
        * gettext-tools/src/xgettext.c: ditto
        * gettext-tools/tests/tstgettext.c: ditto
        * gettext-tools/tests/tstngettext.c: ditto

--
Chuck

diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/hostname.c 
gettext-0.14.5/gettext-tools/src/hostname.c
--- gettext-0.14.5-orig/gettext-tools/src/hostname.c    2005-05-20 
16:40:02.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/hostname.c 2005-11-11 11:02:07.203125000 
-0500
@@ -99,7 +99,7 @@
 static enum { default_format, short_format, long_format, ip_format } format;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "fqdn", no_argument, NULL, 'f' },
   { "help", no_argument, NULL, 'h' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgattrib.c 
gettext-0.14.5/gettext-tools/src/msgattrib.c
--- gettext-0.14.5-orig/gettext-tools/src/msgattrib.c   2005-05-20 
16:40:15.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgattrib.c        2005-11-11 
11:01:39.484375000 -0500
@@ -69,7 +69,7 @@
 static int to_change;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "add-location", no_argument, &line_comment, 1 },
   { "clear-fuzzy", no_argument, NULL, CHAR_MAX + 8 },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgcat.c 
gettext-0.14.5/gettext-tools/src/msgcat.c
--- gettext-0.14.5-orig/gettext-tools/src/msgcat.c      2005-05-20 
16:40:19.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgcat.c   2005-11-11 11:02:33.109375000 
-0500
@@ -53,7 +53,7 @@
 static const char *to_code;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "add-location", no_argument, &line_comment, 1 },
   { "directory", required_argument, NULL, 'D' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgcmp.c 
gettext-0.14.5/gettext-tools/src/msgcmp.c
--- gettext-0.14.5-orig/gettext-tools/src/msgcmp.c      2005-05-20 
16:40:23.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgcmp.c   2005-11-11 11:02:51.906250000 
-0500
@@ -49,7 +49,7 @@
 static bool multi_domain_mode = false;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "directory", required_argument, NULL, 'D' },
   { "help", no_argument, NULL, 'h' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgcomm.c 
gettext-0.14.5/gettext-tools/src/msgcomm.c
--- gettext-0.14.5-orig/gettext-tools/src/msgcomm.c     2005-05-20 
16:40:27.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgcomm.c  2005-11-11 11:03:09.406250000 
-0500
@@ -55,7 +55,7 @@
 static const char *to_code;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "add-location", no_argument, &line_comment, 1 },
   { "directory", required_argument, NULL, 'D' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgconv.c 
gettext-0.14.5/gettext-tools/src/msgconv.c
--- gettext-0.14.5-orig/gettext-tools/src/msgconv.c     2005-05-20 
16:40:31.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgconv.c  2005-11-11 11:03:21.671875000 
-0500
@@ -52,7 +52,7 @@
 static const char *to_code;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "add-location", no_argument, &line_comment, 1 },
   { "directory", required_argument, NULL, 'D' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgen.c 
gettext-0.14.5/gettext-tools/src/msgen.c
--- gettext-0.14.5-orig/gettext-tools/src/msgen.c       2005-05-20 
16:40:35.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgen.c    2005-11-11 11:03:54.531250000 
-0500
@@ -48,7 +48,7 @@
 static int force_po;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "add-location", no_argument, &line_comment, 1 },
   { "directory", required_argument, NULL, 'D' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgexec.c 
gettext-0.14.5/gettext-tools/src/msgexec.c
--- gettext-0.14.5-orig/gettext-tools/src/msgexec.c     2005-05-20 
16:40:40.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgexec.c  2005-11-11 11:04:07.546875000 
-0500
@@ -74,7 +74,7 @@
 static int exitcode;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "directory", required_argument, NULL, 'D' },
   { "help", no_argument, NULL, 'h' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgfilter.c 
gettext-0.14.5/gettext-tools/src/msgfilter.c
--- gettext-0.14.5-orig/gettext-tools/src/msgfilter.c   2005-05-20 
16:40:44.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgfilter.c        2005-11-11 
11:04:19.062500000 -0500
@@ -97,7 +97,7 @@
 static int sub_argc;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "add-location", no_argument, &line_comment, 1 },
   { "directory", required_argument, NULL, 'D' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgfmt.c 
gettext-0.14.5/gettext-tools/src/msgfmt.c
--- gettext-0.14.5-orig/gettext-tools/src/msgfmt.c      2005-11-11 
00:58:30.000000000 -0500
+++ gettext-0.14.5/gettext-tools/src/msgfmt.c   2005-11-11 11:04:30.546875000 
-0500
@@ -163,7 +163,7 @@
 static int do_statistics;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "alignment", required_argument, NULL, 'a' },
   { "check", no_argument, NULL, 'c' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msggrep.c 
gettext-0.14.5/gettext-tools/src/msggrep.c
--- gettext-0.14.5-orig/gettext-tools/src/msggrep.c     2005-05-20 
16:41:05.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msggrep.c  2005-11-11 11:03:39.796875000 
-0500
@@ -81,7 +81,7 @@
 static struct grep_task grep_task[3];
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "add-location", no_argument, &line_comment, 1 },
   { "comment", no_argument, NULL, 'C' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msginit.c 
gettext-0.14.5/gettext-tools/src/msginit.c
--- gettext-0.14.5-orig/gettext-tools/src/msginit.c     2005-11-11 
00:59:01.000000000 -0500
+++ gettext-0.14.5/gettext-tools/src/msginit.c  2005-11-11 11:04:42.078125000 
-0500
@@ -125,7 +125,7 @@
 static bool no_translator;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "help", no_argument, NULL, 'h' },
   { "input", required_argument, NULL, 'i' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgmerge.c 
gettext-0.14.5/gettext-tools/src/msgmerge.c
--- gettext-0.14.5-orig/gettext-tools/src/msgmerge.c    2005-05-20 
16:42:09.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgmerge.c 2005-11-11 11:04:51.328125000 
-0500
@@ -84,7 +84,7 @@
 static const char *backup_suffix_string;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "add-location", no_argument, &line_comment, 1 },
   { "backup", required_argument, NULL, CHAR_MAX + 1 },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msgunfmt.c 
gettext-0.14.5/gettext-tools/src/msgunfmt.c
--- gettext-0.14.5-orig/gettext-tools/src/msgunfmt.c    2005-05-20 
16:42:11.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msgunfmt.c 2005-11-11 11:05:45.718750000 
-0500
@@ -73,7 +73,7 @@
 static int force_po;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "csharp", no_argument, NULL, CHAR_MAX + 4 },
   { "csharp-resources", no_argument, NULL, CHAR_MAX + 5 },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/msguniq.c 
gettext-0.14.5/gettext-tools/src/msguniq.c
--- gettext-0.14.5-orig/gettext-tools/src/msguniq.c     2005-05-20 
16:42:23.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/msguniq.c  2005-11-11 11:05:57.968750000 
-0500
@@ -52,7 +52,7 @@
 static const char *to_code;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "add-location", no_argument, &line_comment, 1 },
   { "directory", required_argument, NULL, 'D' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/urlget.c 
gettext-0.14.5/gettext-tools/src/urlget.c
--- gettext-0.14.5-orig/gettext-tools/src/urlget.c      2005-05-20 
16:44:41.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/urlget.c   2005-11-11 11:06:10.968750000 
-0500
@@ -65,7 +65,7 @@
 
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "help", no_argument, NULL, 'h' },
   { "version", no_argument, NULL, 'V' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/src/xgettext.c 
gettext-0.14.5/gettext-tools/src/xgettext.c
--- gettext-0.14.5-orig/gettext-tools/src/xgettext.c    2005-05-20 
16:47:42.000000000 -0400
+++ gettext-0.14.5/gettext-tools/src/xgettext.c 2005-11-11 11:06:25.406250000 
-0500
@@ -176,7 +176,7 @@
 #endif
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "add-comments", optional_argument, NULL, 'c' },
   { "add-location", no_argument, &line_comment, 1 },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/tests/tstgettext.c 
gettext-0.14.5/gettext-tools/tests/tstgettext.c
--- gettext-0.14.5-orig/gettext-tools/tests/tstgettext.c        2005-05-20 
16:48:17.000000000 -0400
+++ gettext-0.14.5/gettext-tools/tests/tstgettext.c     2005-11-11 
11:10:29.046875000 -0500
@@ -52,7 +52,7 @@
 static bool do_expand;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "domain", required_argument, NULL, 'd' },
   { "env", required_argument, NULL, '=' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/tests/tstngettext.c 
gettext-0.14.5/gettext-tools/tests/tstngettext.c
--- gettext-0.14.5-orig/gettext-tools/tests/tstngettext.c       2005-05-20 
16:48:20.000000000 -0400
+++ gettext-0.14.5/gettext-tools/tests/tstngettext.c    2005-11-11 
11:10:39.875000000 -0500
@@ -42,7 +42,7 @@
 #define _(str) gettext (str)
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "domain", required_argument, NULL, 'd' },
   { "env", required_argument, NULL, '=' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-runtime/configure.ac 
gettext-0.14.5/gettext-runtime/configure.ac
--- gettext-0.14.5-orig/gettext-runtime/configure.ac    2005-11-11 
00:04:26.000000000 -0500
+++ gettext-0.14.5/gettext-runtime/configure.ac 2005-11-11 11:34:46.687500000 
-0500
@@ -111,6 +111,28 @@
 #endif
 ])
 
+dnl Since gcc-3.3.3, const variables are placed in .rdata section
+dnl On windows (cygwin, mingw) this is a problem if the variable
+dnl is a composite containing references to other variables, because
+dnl the runtime relocation machinery can't fixup the address.  Thus
+dnl these composite vars must NOT be declared const.  This typically
+dnl occurs in long_options structs, containing references to variables
+dnl that are the targets of an option flag.
+case "$host_os" in
+  *cygwin* | *mingw* )
+    AC_DEFINE([CONST_IS_PROBLEMATIC_WIN32], 1,
+    [Define to 1 if structs-containing-references must not be declared const])
+    ;;
+esac
+AH_VERBATIM([DEF_CONST_PROBLEMATIC_WIN32],
+[/* On some platforms, structs-containing-references must not be declared 
const */
+#if defined CONST_IS_PROBLEMATIC_WIN32
+# define CONST_PROBLEMATIC_WIN32
+#else
+# define CONST_PROBLEMATIC_WIN32 const
+#endif
+])
+
 AH_VERBATIM([DEF_OS2],
 [/* Extra OS/2 (emx+gcc) defines.  */
 #ifdef __EMX__
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-tools/configure.ac 
gettext-0.14.5/gettext-tools/configure.ac
--- gettext-0.14.5-orig/gettext-tools/configure.ac      2005-11-11 
00:26:09.000000000 -0500
+++ gettext-0.14.5/gettext-tools/configure.ac   2005-11-11 11:34:03.140625000 
-0500
@@ -214,6 +214,28 @@
 #endif
 ])
 
+dnl Since gcc-3.3.3, const variables are placed in .rdata section
+dnl On windows (cygwin, mingw) this is a problem if the variable
+dnl is a composite containing references to other variables, because
+dnl the runtime relocation machinery can't fixup the address.  Thus
+dnl these composite vars must NOT be declared const.  This typically
+dnl occurs in long_options structs, containing references to variables
+dnl that are the targets of an option flag.
+case "$host_os" in
+  *cygwin* | *mingw* )
+    AC_DEFINE([CONST_IS_PROBLEMATIC_WIN32], 1,
+    [Define to 1 if structs-containing-references must not be declared const])
+    ;;
+esac
+AH_VERBATIM([DEF_CONST_PROBLEMATIC_WIN32],
+[/* On some platforms, structs-containing-references must not be declared 
const */
+#if defined CONST_IS_PROBLEMATIC_WIN32
+# define CONST_PROBLEMATIC_WIN32
+#else
+# define CONST_PROBLEMATIC_WIN32 const
+#endif
+])
+
 dnl Check for the expat XML parser.
 dnl On operating systems where binary distribution vendors are likely to
 dnl ship both gettext and expat, we use dynamic loading to avoid a hard
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-runtime/src/envsubst.c 
gettext-0.14.5/gettext-runtime/src/envsubst.c
--- gettext-0.14.5-orig/gettext-runtime/src/envsubst.c  2005-05-20 
16:14:16.000000000 -0400
+++ gettext-0.14.5/gettext-runtime/src/envsubst.c       2005-11-11 
11:07:50.796875000 -0500
@@ -43,7 +43,7 @@
 static bool all_variables;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "help", no_argument, NULL, 'h' },
   { "variables", no_argument, NULL, 'v' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-runtime/src/gettext.c 
gettext-0.14.5/gettext-runtime/src/gettext.c
--- gettext-0.14.5-orig/gettext-runtime/src/gettext.c   2005-05-20 
16:14:21.000000000 -0400
+++ gettext-0.14.5/gettext-runtime/src/gettext.c        2005-11-11 
11:08:03.859375000 -0500
@@ -48,7 +48,7 @@
 static bool do_expand;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "domain", required_argument, NULL, 'd' },
   { "help", no_argument, NULL, 'h' },
diff -urN -x .build -x .inst -x .sinst -x '*~' 
gettext-0.14.5-orig/gettext-runtime/src/ngettext.c 
gettext-0.14.5/gettext-runtime/src/ngettext.c
--- gettext-0.14.5-orig/gettext-runtime/src/ngettext.c  2005-05-20 
16:14:39.000000000 -0400
+++ gettext-0.14.5/gettext-runtime/src/ngettext.c       2005-11-11 
11:08:16.062500000 -0500
@@ -44,7 +44,7 @@
 static int do_expand;
 
 /* Long options.  */
-static const struct option long_options[] =
+static CONST_PROBLEMATIC_WIN32 struct option long_options[] =
 {
   { "domain", required_argument, NULL, 'd' },
   { "help", no_argument, NULL, 'h' },

reply via email to

[Prev in Thread] Current Thread [Next in Thread]