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]

fix ABI problem on x86-darwin


My previous patch, which introduced DBX_REGISTER_NUMBER to
i386/darwin.h, caused ABI breakage, because DBX_REGISTER_NUMBER also
applies to the eh_frame information.  Thus, this hack.

Bootstrapped & tested on i386-darwin, and I checked that the testcase
does fail if you try it with a compiler without this patch using the
system libgcc_s.1.dylib.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-darwin-4439051abi.patch===============
Index: ChangeLog
2006-02-21  Geoffrey Keating  <geoffk@apple.com>

	* config/i386/darwin.h (DWARF2_FRAME_REG_OUT): New.

Index: testsuite/ChangeLog
2006-02-21  Geoffrey Keating  <geoffk@apple.com>

	* g++.dg/eh/spbp.C: New.

Index: config/i386/darwin.h
===================================================================
--- config/i386/darwin.h	(revision 111006)
+++ config/i386/darwin.h	(working copy)
@@ -157,8 +157,16 @@
    register numbers for STABS.  Fortunately for 64-bit code the
    default and the standard are the same.  */
 #undef DBX_REGISTER_NUMBER
-#define DBX_REGISTER_NUMBER(n) (TARGET_64BIT			\
-				? dbx64_register_map[n]		\
-				: write_symbols == DWARF2_DEBUG	\
-				? svr4_dbx_register_map[n]	\
-				: dbx_register_map[n])
+#define DBX_REGISTER_NUMBER(n) 					\
+  (TARGET_64BIT ? dbx64_register_map[n]				\
+   : write_symbols == DWARF2_DEBUG ? svr4_dbx_register_map[n]	\
+   : dbx_register_map[n])
+
+/* Unfortunately, the 32-bit EH information also doesn't use the standard
+   DWARF register numbers.  */
+#define DWARF2_FRAME_REG_OUT(n, for_eh)					\
+  (! (for_eh) || write_symbols != DWARF2_DEBUG || TARGET_64BIT ? (n)	\
+   : (n) == 5 ? 4							\
+   : (n) == 4 ? 5							\
+   : (n) >= 11 && (n) <= 18 ? (n) + 1					\
+   : (n))
Index: testsuite/g++.dg/eh/spbp.C
===================================================================
--- testsuite/g++.dg/eh/spbp.C	(revision 0)
+++ testsuite/g++.dg/eh/spbp.C	(revision 0)
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options "-gdwarf-2" } */
+
+/* This was a bug on x86-darwin, where the register numbering for SP
+   and BP was swapped (it's easy to do because on that port it's
+   different for eh_frame and debug_frame).  */
+
+#include <stdlib.h>
+
+void f1(int t)
+{
+  char u[t];
+  throw 1;
+}
+
+int main()
+{
+  bool b = true;
+  try {
+    f1(100);
+  } catch (int x) {
+    if (b)
+      exit (0);
+  }
+  abort ();
+}
============================================================


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