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]

[PATCH] Fix PR java/41991


  The attached patch eliminates PR java/41991 on darwin10. The failures in
the libjava WalkerTest and the aborts of gcj in compiling java code on darwin10
are due to the non-functional _Unwind_FindEnclosingFunction() in Apple's libSystem.
In darwin10, the functionality of libgcc has been subsumed into libSystem.
Furthermore, since the linker default in darwin10 is to use compact unwind code
in the new system unwinder, any call, like _Unwind_FindEnclosingFunction(). that
indirectly require FDEs is set to the not-implemented macro which is an abort() call.
   Fortunately FSF gcc trunk currently sets -no_compact_unwind when linking in order
to avoid system unwinder aborts due to the new epilog notes in the unwind info
generated in gcc 4.5. This means that FSF gcc is using the compatibility unwinder
in libSystem which still uses FDEs. Thus, the fix to PR41991 is to re-export
the FSF libgcc _Unwind_FindEnclosingFunction symbol via the new libgcc_ext versioned
stubs as _darwin10_Unwind_FindEnclosingFunction.
    While the new gcc/libgcc-libsystem.ver currently only contains a single
symbol to be re-exported, it is available to add additional symbols (since Apple
appears to have set a number of libgcc calls to the not-implemented abort macro).
I am attempting to get a complete list of those from Apple for a PR to track them
for latent gcc breakage under darwin10. Regression tested on x86_64-apple-darwin10 and
i386-apple-darwin10. Okay for gcc trunk?
            Jack
ps In the long run, once Apple fixes its unwinder to tolerate the new epilog notes in
unwind info, FSF gcc should no longer assume FDEs are available for darwin and write
unwind code for the compact unwinder instead of the legacy unwinder in libSystem.



2009-12-21  Jack Howarth  <howarth@bromo.med.uc.edu>

	PR java/41991
	* libgcc/config/t-slibgcc-darwin: Add libgcc-libsystem.ver to SHLIB_MAPFILES.
	* gcc/unwind-dw2-fde-darwin.c: Re-export _Unwind_FindEnclosingFunction() as
	  _darwin10_Unwind_FindEnclosingFunction().
	* libjava/include/posix.h: Redefine _Unwind_FindEnclosingFunction.
	* gcc/libgcc-libsystem.ver: New.

Index: libgcc/config/t-slibgcc-darwin
===================================================================
--- libgcc/config/t-slibgcc-darwin	(revision 155289)
+++ libgcc/config/t-slibgcc-darwin	(working copy)
@@ -24,7 +24,7 @@
 
 SHLIB_MKMAP = $(gcc_srcdir)/mkmap-flat.awk
 SHLIB_MKMAP_OPTS = -v leading_underscore=1
-SHLIB_MAPFILES += $(gcc_srcdir)/libgcc-std.ver
+SHLIB_MAPFILES += $(gcc_srcdir)/libgcc-std.ver $(gcc_srcdir)/libgcc-libsystem.ver
 
 # we're only going to build the stubs if the target slib is /usr/lib
 # there is no other case in which they're useful in a live system.
Index: gcc/unwind-dw2-fde-darwin.c
===================================================================
--- gcc/unwind-dw2-fde-darwin.c	(revision 155289)
+++ gcc/unwind-dw2-fde-darwin.c	(working copy)
@@ -273,3 +273,15 @@
 					  the_obj_info);
   return ret;
 }
+
+void *
+_darwin10_Unwind_FindEnclosingFunction (void *pc)
+{
+  struct dwarf_eh_bases bases;
+  const struct dwarf_fde *fde = _Unwind_Find_FDE (pc-1, &bases);
+  if (fde)
+    return bases.func;
+  else
+    return NULL;
+}
+
Index: libjava/include/posix.h
===================================================================
--- libjava/include/posix.h	(revision 155289)
+++ libjava/include/posix.h	(working copy)
@@ -56,6 +56,11 @@
 #define _Jv_platform_solib_suffix ".so"
 #endif
 
+#if defined(__APPLE__) && defined(__MACH__)
+#undef _Unwind_FindEnclosingFunction
+#define _Unwind_FindEnclosingFunction(PC) _darwin10_Unwind_FindEnclosingFunction(PC)
+#endif
+
 // Some POSIX systems don't have O_SYNC and O_DYSNC so we define them here.
 // Needed in java/io/natFileDescriptorPosix.cc.
 #if !defined (O_SYNC) && defined (O_FSYNC)
--- /dev/null	2002-12-31 19:00:46.107008625 -0500
+++ gcc/libgcc-libsystem.ver	2009-12-21 13:28:50.000000000 -0500
@@ -0,0 +1 @@
+_darwin10_Unwind_FindEnclosingFunction


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