This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[patch] darwin full x86_64 and i?86 libjava support
- From: Andreas Tobler <andreast-list at fgznet dot ch>
- To: Java Patches <java-patches at gcc dot gnu dot org>, Eric Christopher <echristo at apple dot com>
- Date: Thu, 06 Dec 2007 23:45:17 +0100
- Subject: [patch] darwin full x86_64 and i?86 libjava support
Hi all,
the appended patch brings libjava support for i?86-apple-darwin9 with
signal handling and x86_64-apple-darwin9 as well.
(the magic throw_2 passes !!!)
i?86-apple-darwin9 was tested with 32 and 64-bit support.
x86_64-apple-darwin9 only on 64-bit. According to Eric it is not
foreseen to have a x86_64-apple-darwin9 compiler which supports -m32.
There are 2 failures in the 64-bit part, the PR16923 run part and the
magic events output. These two failures are not unique to darwin, I see
them as well on sparc-solaris and hupx (HPUX) 64-bit. I'll address them
later.
On the 32-bit part there is one failure: ClosureGC.jar, and from my
opinion this one is due to 32843, I was not able to fix this one due to
time constraints. Also in the queue to fix.
The test results look like this:
for i?86-apple-darwin9
=== libjava Summary for unix/-m64 ===
# of expected passes 2548
# of unexpected failures 2
# of untested testcases 1
=== libjava Summary for unix ===
# of expected passes 2548
# of unexpected failures 1
# of untested testcases 1
=== libjava Summary ===
# of expected passes 5096
# of unexpected failures 3
# of untested testcases 2
for x86_64-apple-darwin9:
=== libjava Summary ===
# of expected passes 2548
# of unexpected failures 2
# of untested testcases 1
Is this patch feasible for trunk ? No regression, nothing, only improved
situation....
Thanks for review and feedback,
Andreas
2007-12-06 Andreas Tobler <a.tobler@schweiz.org>
* configure.host: Add bits for i?86-*-darwin9 and x86_64-*-darwin9.
* configure.ac: Add darwin-signal.h to x86_64-*-darwin9 and
i?86-*darwin9.
* configure.in: Regenerate.
* darwin.cc: Add definitions for Darwin specific functions for 64-bit.
(darwin_java_register_dyld_add_image_hook): Use this specific
functions.
* Makefile.am (gij_LDFLAGS): Add extra_gij_ldflags for Darwin9.
* Makefile.in: Regenerate.
* testsuite/lib/libjava.exp (libjava_arguments): Add allow_stack_execute
for *-*-darwin9*.
Index: Makefile.am
===================================================================
--- Makefile.am (revision 130657)
+++ Makefile.am (working copy)
@@ -675,7 +675,8 @@
## need this because we are explicitly using libtool to link using the
## `.la' file.
gij_LDFLAGS = -rpath $(dbexecdir) -rpath $(toolexeclibdir) \
- -shared-libgcc $(THREADLDFLAGS) $(extra_ldflags)
+ -shared-libgcc $(THREADLDFLAGS) $(extra_ldflags) \
+ $(extra_gij_ldflags)
gij_LINK = $(GCJLINK)
## See jv_convert_LDADD.
gij_LDADD = -L$(here)/.libs libgij.la
Index: darwin.cc
===================================================================
--- darwin.cc (revision 130657)
+++ darwin.cc (working copy)
@@ -1,6 +1,6 @@
/* darwin.cc - class loader stuff for Darwin. */
-/* Copyright (C) 2004 Free Software Foundation
+/* Copyright (C) 2004, 2007 Free Software Foundation
This file is part of libgcj.
@@ -21,42 +21,62 @@
ourself. */
#include <stdint.h>
+#if !defined (__LP64__)
struct mach_header;
+#define JAVA_MACH_HEADER mach_header
+#define mh_size_t uint32_t
extern "C" void _dyld_register_func_for_add_image
- (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
+(void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
extern "C" void _dyld_register_func_for_remove_image
- (void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
+(void (*func)(const struct mach_header *mh, intptr_t vmaddr_slide));
extern "C" char *getsectdatafromheader
(const struct mach_header *mhp, const char *segname, const char *sectname,
uint32_t *size);
+#else
+struct mach_header_64;
+#define JAVA_MACH_HEADER mach_header_64
+#define mh_size_t uint64_t
+extern "C" void _dyld_register_func_for_add_image
+(void (*func)(const struct mach_header_64 *mh, intptr_t vmaddr_slide));
+extern "C" void _dyld_register_func_for_remove_image
+(void (*func)(const struct mach_header_64 *mh, intptr_t vmaddr_slide));
+extern "C" char *getsectdatafromheader_64
+(const struct mach_header_64 *mhp, const char *segname, const char *sectname,
+ uint64_t *size);
+#endif
/* When a new image is loaded, look to see if it has a jcr section
and if so register the classes listed in it. */
static void
-darwin_java_register_dyld_add_image_hook (const struct mach_header *mh,
+darwin_java_register_dyld_add_image_hook (const struct JAVA_MACH_HEADER *mh,
intptr_t slide)
{
char *fde;
- uint32_t sz;
+ mh_size_t sz;
- fde = getsectdatafromheader (mh, "__DATA", "jcr", &sz);
+#if defined (__LP64__)
+ fde = getsectdatafromheader_64(
+#else
+ fde = getsectdatafromheader(
+#endif
+ mh, "__DATA", "jcr", &sz);
if (! fde)
return;
-
+
/* As far as I can tell, you're only supposed to load shared
libraries while having a lock on java.lang.Class. So there's
no need to synchronize on anything here. (I'm not sure how exactly
you can ensure this given lazy library loading. FIXME.) */
-
+
_Jv_RegisterClasses_Counted ((const jclass *) (fde + slide),
sz / sizeof (jclass *));
}
static struct darwin_constructor_s{
- darwin_constructor_s()
+ darwin_constructor_s()
{
- _dyld_register_func_for_add_image
+ _dyld_register_func_for_add_image
(darwin_java_register_dyld_add_image_hook);
/* At present, you mustn't unload any java plugin. */
};
Index: testsuite/lib/libjava.exp
===================================================================
--- testsuite/lib/libjava.exp (revision 130657)
+++ testsuite/lib/libjava.exp (working copy)
@@ -429,6 +429,10 @@
lappend args "additional_flags=-bind_at_load"
lappend args "additional_flags=-multiply_defined suppress"
}
+ if { [istarget "*-*-darwin9*"] } {
+ lappend args "additional_flags=-Wl,-allow_stack_execute"
+ }
+
}
return $args
Index: configure.ac
===================================================================
--- configure.ac (revision 130657)
+++ configure.ac (working copy)
@@ -788,6 +788,9 @@
# on Darwin -single_module speeds up loading of the dynamic libraries.
extra_ldflags_libjava=-Wl,-single_module
;;
+*-*-darwin[[9]]*)
+ extra_gij_ldflags=-Wl,-allow_stack_execute
+ ;;
arm*linux*eabi)
# Some of the ARM unwinder code is actually in libstdc++. We
# could in principle replicate it in libgcj, but it's better to
@@ -798,6 +801,7 @@
;;
esac
AC_SUBST(extra_ldflags_libjava)
+AC_SUBST(extra_gij_ldflags)
AC_SUBST(extra_ldflags)
AC_SUBST(LIBSTDCXXSPEC)
@@ -1546,7 +1550,7 @@
m68*-*-linux*)
SIGNAL_HANDLER=include/dwarf2-signal.h
;;
- powerpc*-*-darwin*)
+ powerpc*-*-darwin* | i?86-*-darwin9* | x86_64-*-darwin9*)
SIGNAL_HANDLER=include/darwin-signal.h
;;
*)
Index: configure.host
===================================================================
--- configure.host (revision 130657)
+++ configure.host (working copy)
@@ -295,6 +295,17 @@
slow_pthread_self=
can_unwind_signal=no
;;
+ i?86-*-darwin9*)
+ can_unwind_signal=yes
+ DIVIDESPEC=-f%{m32:no-}%{!m32:%{!m64:no-}}%{m64:}use-divide-subroutine
+ ;;
+ x86_64-*-darwin9*)
+ enable_hash_synchronization_default=yes
+ slow_pthread_self=
+ can_unwind_signal=yes
+ DIVIDESPEC=-fuse-divide-subroutine
+ CHECKREFSPEC=-fcheck-references
+ ;;
*-*-freebsd*)
slow_pthread_self=
;;