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 +#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= ;;