[pcre-dev] [Bug 664] ABI breakage in PCRE 7.6

Page principale
Supprimer ce message
Auteur: Philip Hazel
Date:  
À: pcre-dev
Sujet: [pcre-dev] [Bug 664] ABI breakage in PCRE 7.6
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=664




--- Comment #22 from Philip Hazel <ph10@???> 2008-03-26 17:45:18 ---
Oh, Bugzilla seems to have chopped off the forwarded message that I
included. Here it is, indented to avoid that happening again (I hope).

---------- Forwarded message ----------
Date: Mon, 24 Mar 2008 16:17:32 -0700 (PDT)
From: Craig Silverstein <csilvers@???>
To: zackw@???
Cc: pcre-dev@???
Subject: Re: [pcre-dev] [Bug 664] ABI breakage in PCRE 7.6

  } #if defined(__GNUC__) && __GNUC__ >= 3
  } extern Arg no_arg __attribute__((
  } #ifdef __MACH__
  } // Mach (or at least OS X), doesn't support strong aliases, so make it
  } // weak.  This is a smidge less safe in theory (conceivably, someone
  } // could override this symbol in their own binary), but perfectly ok.
  }                                weak,
  } #endif
  }                                alias(__USER_LABEL_PREFIX__
  }                                      "_ZN7pcrecpp2RE6no_argE")));
  } #endif


I like this solution!, though it's a bit ugly. I didn't know about
__USER_LABEL_PREFIX__. Below is an alternate patch that uses this
approach, and is a smidgen safer.

craig

--cut here--

Index: pcrecpp.cc
===================================================================
--- pcrecpp.cc (revision 327)
+++ pcrecpp.cc (working copy)
@@ -59,11 +59,23 @@

// This is for ABI compatibility with old versions of pcre (pre-7.6),
// which defined a global no_arg variable instead of putting it in the
-// RE class. This works on GCC >= 3, at least. We could probably have
-// a more inclusive test if we ever needed it.
+// RE class. This works on GCC >= 3, at least. We could probably
+// have a more inclusive test if we ever needed it. (Note that not
+// only the __attribute__ syntax, but also __USER_LABEL_PREFIX__, are
+// gnu-specific.)
#if defined(__GNUC__) && __GNUC__ >= 3
-extern Arg no_arg __attribute__((alias("_ZN7pcrecpp2RE6no_argE")));
+#if defined(__ELF__)
+extern Arg no_arg
+ __attribute__((alias(__USER_LABEL_PREFIX__ "_ZN7pcrecpp2RE6no_argE")));
+#else
+// While we know elf supports strong aliases, not all formats do (Mach
+// doesn't, for instance). So make aliases weak by default. This is
+// a smidge less safe in theory (conceivably, someone could override
+// this symbol in their own binary), but perfectly ok in practice.
+extern Arg no_arg
+ __attribute__((weak, alias(__USER_LABEL_PREFIX__
"_ZN7pcrecpp2RE6no_argE")));
#endif
+#endif

// If a regular expression has no error, its error_ field points here
static const string empty_string;



--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email