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]

weak for Darwin


This patch is the result of several very long meetings, and quite a
bit of thought by everyone involved.

As Matt said,

> On Linux (and other ELF system), #pragma weak has three meanings
> depending on how it's used:
>  1. Applied to a symbol that's defined in the current translation
> unit, it makes it a weak definition. (i.e. one that can be overridden
> by a strong definition elsewhere).
>  2. Applied to a symbol that isn't defined in the current translation
> unit it makes a weak undefined symbol (i.e. one whose address must be
> tested before the symbol is used, because at runtime it may or may not
> have a definition).
>  3. With different syntax it can be used to create weak aliases
> (i.e. a symbol that is originally an alias for something else but that
> can be given a different definition of its own in another translation
> unit).
> 
> (The reason gcc uses the same syntax for three such different things
> is that on ELF they all use the same syntax and the same assembler
> directives.  See foo.c and foo.s, attached, for an illustration of all
> three cases.)
> 
> MACH-O doesn't quite have the same functionality as ELF. #1 is
> essentially identical to weak coalescing, and #2 is similar to our
> weak_import.  I don't know if we have any equivalent of #3.  So: on
> our system, what do we want "#pragma weak" to do?  Currently we're
> just ignoring it, which probably isn't what our customers want.
...
> Having talked this over with Nick, Kevin, and Geoff, we believe the
> right solution is to treat #pragma weak for an undefined symbol as
> weak_import; the meaning is similar enough that this makes sense.
> MACH-O has no equivalent of weak aliases, so we should continue to
> warn that "#pragma weak foo=bar" is ignored.

There is, however, a complication.  The Darwin loader doesn't really
handle weak symbols, or symbol overriding of any kind, unless you use
flat namespaces.  After the afore-mentioned discussion, we concluded
that the best thing would be if the Darwin loader did handle this, and
it's planned to be implemented (you'll note that the magic words
"implemented now" did not appear in that sentence).

So, what does this patch *do*?

GCC used to handle overriding of operator new and operator delete in
libstdc++ by using Darwin's "multi-module" mechanism, together with
flat namespaces.  That worked fine, but made application startup
slower than it needed to be (which is a *big* concern here at Apple),
and caused concerns about forwards binary compatibility (which worries
those who take the long view).

After the patch, GCC makes operator new and operator delete weak,
relies on the loader to implement weak semantics properly, and uses
-flat_namespace to work around the way that it doesn't.

At present, some cases need to have the overrider of new & delete be
-flat_namespace too, so if you run the testsuite with the right
MACOSX_DEPLOYMENT_TARGET you'll find g++.old-deja/g++.brendan/new3.C
and g++.old-deja/g++.abi/cxa_vec.C fail.  They pass if you build them
with -flat_namespace.  Hopefully they will pass when dyld is fixed
even without it.

Other exciting features?  Well, note the change to LINK_SPEC.  If you
have a symbol that's referenced weak in one file and not-weak in
another, the Darwin ld, by default, errors.  Annoying.  Especially if
you want to make a symbol in a library like libgcc.a weak, because
then every application that used that symbol would have to make it
weak too.

Also, it turns out that when you have weak symbols, gcj wants to build
up a section listing its classes instead of using a constructor to
register them.  I'm completely unclear on what the connection is,
but it seemed easy enough to implement that compared to the
mind-bending of working out what 'weak' means.

Bootstrapped & tested on powerpc-darwin.

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

===File ~/patches/gcc-darwin-weak.patch=====================
Index: gcc/gcc/ChangeLog
2004-10-25  Geoffrey Keating  <geoffk@apple.com>

	* config/darwin.h (LINK_SPEC): Default weak_reference_mismatches
	to 'non-weak'.
	(MAKE_DECL_ONE_ONLY): Set DECL_WEAK.
	(ASM_MAKE_LABEL_LINKONCE): Delete.
	(ASM_WEAKEN_DECL): New.
	(ASM_DECLARE_OBJECT_NAME): Look at DECL_WEAK not DECL_ONE_ONLY.
	(ASM_DECLARE_FUNCTION_NAME): Likewise.
	(TEXT_SECTION_ASM_OP): Add a tab.
	(DATA_SECTION_ASM_OP): Likewise.
	(SECTION_FUNCTION): Add a tab.  Use fputs.  Don't call
	data_section on every section change.
	(EXTRA_SECTIONS): Add a bunch of new extra sections.
	(EXTRA_SECTION_FUNCTIONS): Likewise.
	(USE_SELECT_SECTION_FOR_FUNCTIONS): Define.
	(JCR_SECTION_NAME): Define.
	(TARGET_SECTION_TYPE_FLAGS): Don't define.
	* config/darwin.c (darwin_encode_section_info): A symbol is defined
	in this file if it is not weak.
	(textcoal_section): Delete.
	(datacoal_section): Delete.
	(darwin_make_decl_one_only): Delete.
	(machopic_select_section): Handle functions.
	(darwin_asm_named_section): Add a tab.
	(darwin_section_type_flags): Delete.
	(darwin_unique_section): Delete contents.
	(darwin_emit_unwind_label): Add a tab.  Make decls weak if
	DECL_WEAK is set.
	* config/darwin-protos.h (darwin_section_type_flags): Delete.
	(darwin_make_decl_one_only): Delete.
	(text_coal_section): New.
	(text_unlikely_section): New.
	(text_unlikely_coal_section): New.
	(const_coal_section): New.
	(data_coal_section): New.
	(const_data_coal_section): New.
	* varasm.c (function_section): Honour
	USE_SELECT_SECTION_FOR_FUNCTIONS.
	* dwarf2out.c (output_call_frame_info): Look at DECL_WEAK when
	TARGET_USES_WEAK_UNWIND_INFO is in effect.
	* dbxout.c (dbxout_source_file): Don't change sections while
	a function is being output.

Index: gcc/testsuite/ChangeLog
2004-10-25  Geoffrey Keating  <geoffk@apple.com>

	* objc.dg/image-info.m: Update for changes to section selection.

Index: libjava/ChangeLog
2004-10-25  Geoffrey Keating  <geoffk@apple.com>

	* Makefile.am (DARWIN_CRT_SRC): New.
	(libgcj_la_SOURCES): Use it.
	* configure.ac: Define USING_DARWIN_CRT when on Darwin.
	* darwin.cc: New file.
	* include/jvm.h (_Jv_RegisterClasses): Constify.
	(_Jv_RegisterClasses_Counted): New prototype.
	* java/lang/Class.h: Include stddef.h.  
	(_Jv_RegisterClasses): Constify.
	(_Jv_RegisterClasses_Counted): New prototype.
	(Object): Make '_Jv_RegisterClasses_Counted' a friend.
	* java/lang/natClassLoader.cc (_Jv_RegisterClasses): Constify.
	(_Jv_RegisterClasses_Counted): New function.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* gcj/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

Index: libstdc++-v3/ChangeLog
2004-10-25  Geoffrey Keating  <geoffk@apple.com>

	* libsupc++/new_op.cc (new): Make weak.
	* libsupc++/new_opnt.cc (new): Make weak.
	* libsupc++/new_opv.cc (new): Make weak.
	* libsupc++/new_opvnt.cc (new): Make weak.
	* libsupc++/delete_op.cc (delete): Make weak.
	* libsupc++/delete_opnt.cc (delete): Make weak.
	* libsupc++/delete_opv.cc (delete): Make weak.
	* libsupc++/delete_opvnt.cc (delete): Make weak.

Index: gcc/dbxout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dbxout.c,v
retrieving revision 1.209
diff -u -p -u -p -r1.209 dbxout.c
--- gcc/dbxout.c	23 Oct 2004 20:31:24 -0000	1.209
+++ gcc/dbxout.c	26 Oct 2004 00:26:47 -0000
@@ -759,14 +759,10 @@ dbxout_source_file (FILE *file, const ch
       fprintf (asm_out_file, ",%d,0,0,", N_SOL);
       assemble_name (asm_out_file, ltext_label_name);
       fputc ('\n', asm_out_file);
-      if (current_function_decl != NULL_TREE
-	  && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
+      if (current_function_decl != NULL_TREE)
 	; /* Don't change section amid function.  */
       else
-	{
-	  if (!in_text_section () && !in_unlikely_text_section ())
-	    text_section ();
-	}
+	text_section ();
       targetm.asm_out.internal_label (file, "Ltext", source_label_number);
       source_label_number++;
       lastfile = filename;
Index: gcc/dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.557
diff -u -p -u -p -r1.557 dwarf2out.c
--- gcc/dwarf2out.c	25 Oct 2004 21:43:02 -0000	1.557
+++ gcc/dwarf2out.c	26 Oct 2004 00:26:48 -0000
@@ -2050,7 +2050,7 @@ output_call_frame_info (int for_eh)
   /* If we make FDEs linkonce, we may have to emit an empty label for
      an FDE that wouldn't otherwise be emitted.  We want to avoid
      having an FDE kept around when the function it refers to is
-     discarded. (Example where this matters: a primary function
+     discarded.  Example where this matters: a primary function
      template in C++ requires EH information, but an explicit
      specialization doesn't.  */
   if (TARGET_USES_WEAK_UNWIND_INFO
@@ -2059,7 +2059,7 @@ output_call_frame_info (int for_eh)
     for (i = 0; i < fde_table_in_use; i++)
       if ((fde_table[i].nothrow || fde_table[i].all_throwers_are_sibcalls)
           && !fde_table[i].uses_eh_lsda
-	  && ! DECL_ONE_ONLY (fde_table[i].decl))
+	  && ! DECL_WEAK (fde_table[i].decl))
 	targetm.asm_out.unwind_label (asm_out_file, fde_table[i].decl,
 				      for_eh, /* empty */ 1);
 
@@ -2074,8 +2074,7 @@ output_call_frame_info (int for_eh)
       for (i = 0; i < fde_table_in_use; i++)
 	if (fde_table[i].uses_eh_lsda)
 	  any_eh_needed = any_lsda_needed = true;
-        else if (TARGET_USES_WEAK_UNWIND_INFO
-		 && DECL_ONE_ONLY (fde_table[i].decl))
+        else if (TARGET_USES_WEAK_UNWIND_INFO && DECL_WEAK (fde_table[i].decl))
 	  any_eh_needed = true;
 	else if (! fde_table[i].nothrow
 		 && ! fde_table[i].all_throwers_are_sibcalls)
@@ -2222,7 +2221,7 @@ output_call_frame_info (int for_eh)
       /* Don't emit EH unwind info for leaf functions that don't need it.  */
       if (for_eh && !flag_asynchronous_unwind_tables && flag_exceptions
 	  && (fde->nothrow || fde->all_throwers_are_sibcalls)
-	  && (! TARGET_USES_WEAK_UNWIND_INFO || ! DECL_ONE_ONLY (fde->decl))
+	  && ! (TARGET_USES_WEAK_UNWIND_INFO && DECL_WEAK (fde_table[i].decl))
 	  && !fde->uses_eh_lsda)
 	continue;
 
Index: gcc/varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.454
diff -u -p -u -p -r1.454 varasm.c
--- gcc/varasm.c	22 Oct 2004 18:48:13 -0000	1.454
+++ gcc/varasm.c	26 Oct 2004 00:26:48 -0000
@@ -574,13 +574,19 @@ asm_output_aligned_bss (FILE *file, tree
 void
 function_section (tree decl)
 {
+#ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
+  bool unlikely = scan_ahead_for_unlikely_executed_note (get_insns());
+  
+  targetm.asm_out.select_section (decl, unlikely, DECL_ALIGN (decl));
+#else
   if (scan_ahead_for_unlikely_executed_note (get_insns()))
     unlikely_text_section ();
   else if (decl != NULL_TREE
 	   && DECL_SECTION_NAME (decl) != NULL_TREE)
     named_section (decl, (char *) 0, 0);
   else
-    text_section (); 
+    text_section ();
+#endif
 }
 
 /* Switch to read-only data section associated with function DECL.  */
Index: gcc/config/darwin-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin-protos.h,v
retrieving revision 1.38
diff -u -p -u -p -r1.38 darwin-protos.h
--- gcc/config/darwin-protos.h	15 Sep 2004 17:02:58 -0000	1.38
+++ gcc/config/darwin-protos.h	26 Oct 2004 00:26:49 -0000
@@ -70,7 +70,6 @@ extern void machopic_select_rtx_section 
 
 extern void darwin_unique_section (tree decl, int reloc);
 extern void darwin_asm_named_section (const char *, unsigned int, tree);
-extern unsigned int darwin_section_type_flags (tree, const char *, int);
 extern void darwin_non_lazy_pcrel (FILE *, rtx);
 
 extern void darwin_emit_unwind_label (FILE *, tree, int, int);
@@ -81,12 +80,17 @@ extern void darwin_pragma_unused (struct
 
 extern void darwin_file_end (void);
 
-extern void darwin_make_decl_one_only (tree decl);
 extern void darwin_mark_decl_preserved (const char *);
 
 /* Expanded by EXTRA_SECTION_FUNCTIONS into varasm.o.  */
+extern void text_coal_section (void);
+extern void text_unlikely_section (void);
+extern void text_unlikely_coal_section (void);
 extern void const_section (void);
+extern void const_coal_section (void);
 extern void const_data_section (void);
+extern void const_data_coal_section (void);
+extern void data_coal_section (void);
 extern void cstring_section (void);
 extern void literal4_section (void);
 extern void literal8_section (void);
Index: gcc/config/darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.c,v
retrieving revision 1.92
diff -u -p -u -p -r1.92 darwin.c
--- gcc/config/darwin.c	22 Sep 2004 18:11:50 -0000	1.92
+++ gcc/config/darwin.c	26 Oct 2004 00:26:49 -0000
@@ -976,7 +976,7 @@ darwin_encode_section_info (tree decl, r
     SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_FLAG_VARIABLE;
 
   if (!DECL_EXTERNAL (decl)
-      && (!TREE_PUBLIC (decl) || (!DECL_ONE_ONLY (decl) && !DECL_WEAK (decl)))
+      && (!TREE_PUBLIC (decl) || !DECL_WEAK (decl))
       && ((TREE_STATIC (decl)
 	   && (!DECL_COMMON (decl) || !TREE_PUBLIC (decl)))
 	  || (!DECL_COMMON (decl) && DECL_INITIAL (decl)
@@ -989,29 +989,6 @@ darwin_encode_section_info (tree decl, r
     SYMBOL_REF_FLAGS (sym_ref) |= MACHO_SYMBOL_STATIC;
 }
 
-static GTY(()) tree textcoal_section = 0;
-static GTY(()) tree datacoal_section = 0;
-
-void
-darwin_make_decl_one_only (tree decl)
-{
-  tree sec = 0;
-  if (textcoal_section == 0)
-    {
-      static const char *ts = "__TEXT,__textcoal_nt,coalesced";
-      static const char *ds = "__DATA,__datacoal_nt,coalesced";
-      textcoal_section = build_string (strlen (ts), ts);
-      datacoal_section = build_string (strlen (ds), ds);
-    }
-
-  sec = TREE_CODE (decl) == FUNCTION_DECL
-    ? textcoal_section
-    : datacoal_section;
-  TREE_PUBLIC (decl) = 1;
-  DECL_ONE_ONLY (decl) = 1;
-  DECL_SECTION_NAME (decl) = sec;
-}
-
 void
 darwin_mark_decl_preserved (const char *name)
 {
@@ -1025,13 +1002,23 @@ machopic_select_section (tree exp, int r
 			 unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
 {
   void (*base_function)(void);
-
-  if (decl_readonly_section_1 (exp, reloc, MACHOPIC_INDIRECT))
-    base_function = readonly_data_section;
+  bool weak_p = DECL_P (exp) && DECL_WEAK (exp);
+  static void (* const base_funs[][2])(void) = {
+    { text_section, text_coal_section },
+    { text_unlikely_section, text_unlikely_coal_section },
+    { readonly_data_section, const_coal_section },
+    { const_data_section, const_data_coal_section },
+    { data_section, data_coal_section }
+  };
+
+  if (TREE_CODE (exp) == FUNCTION_DECL)
+    base_function = base_funs[reloc][weak_p];
+  else if (decl_readonly_section_1 (exp, reloc, MACHOPIC_INDIRECT))
+    base_function = base_funs[2][weak_p];
   else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))
-    base_function = const_data_section;
+    base_function = base_funs[3][weak_p];
   else
-    base_function = data_section;
+    base_function = base_funs[4][weak_p];
 
   if (TREE_CODE (exp) == STRING_CST
       && ((size_t) TREE_STRING_LENGTH (exp)
@@ -1125,6 +1112,28 @@ machopic_select_section (tree exp, int r
       else
 	base_function ();
     }
+  /* ::operator new and ::operator delete must be coalesced, even
+     if not weak.  There are 8 variants that we look for.  */
+  else if (TREE_CODE (exp) == FUNCTION_DECL
+	   && ! DECL_ONE_ONLY (exp))
+    {
+      const char * name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (exp));
+      if (name[0] == '_' && name[1] == 'Z'
+	  && ((name[2] == 'n' && (name[3] == 'a' || name[3] == 'w')
+	       && name[4] == 'm')
+	      || (name[2] == 'd' && (name[3] == 'a' || name[3] == 'l')
+		  && name[4] == 'P' && name[5] == 'v')))
+	{
+	  bool delete_p = name[2] == 'd';
+	  if (name[5 + delete_p] == 0
+	      || strcmp (name + 5 + delete_p, "KSt9nothrow_t") == 0)
+	    base_funs[reloc][1] ();
+	  else
+	    base_function ();
+	}
+      else
+	base_function ();
+    }
   else
     base_function ();
 }
@@ -1191,30 +1200,13 @@ darwin_asm_named_section (const char *na
 			  unsigned int flags ATTRIBUTE_UNUSED,
 			  tree decl ATTRIBUTE_UNUSED)
 {
-  fprintf (asm_out_file, ".section %s\n", name);
+  fprintf (asm_out_file, "\t.section %s\n", name);
 }
 
-unsigned int
-darwin_section_type_flags (tree decl, const char *name, int reloc)
-{
-  unsigned int flags = default_section_type_flags (decl, name, reloc);
- 
-  /* Weak or linkonce variables live in a writable section.  */
-  if (decl != 0 && TREE_CODE (decl) != FUNCTION_DECL
-      && (DECL_WEAK (decl) || DECL_ONE_ONLY (decl)))
-    flags |= SECTION_WRITE;
-  
-  return flags;
-}              
-
 void 
-darwin_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED)
+darwin_unique_section (tree decl ATTRIBUTE_UNUSED, int reloc ATTRIBUTE_UNUSED)
 {
-  /* Darwin does not use unique sections.  However, the target's
-     unique_section hook is called for linkonce symbols.  We need
-     to set an appropriate section for such symbols. */
-  if (DECL_ONE_ONLY (decl) && !DECL_SECTION_NAME (decl))
-    darwin_make_decl_one_only (decl);
+  /* Darwin does not use unique sections.  */
 }
 
 #define HAVE_DEAD_STRIP 0
@@ -1265,14 +1257,14 @@ darwin_emit_unwind_label (FILE *file, tr
     strcat(lab, "\"");
 
   if (TREE_PUBLIC (decl))
-    fprintf (file, "%s %s\n",
+    fprintf (file, "\t%s %s\n",
 	     (DECL_VISIBILITY (decl) != VISIBILITY_HIDDEN
 	      ? ".globl"
 	      : ".private_extern"),
 	     lab);
 
-  if (DECL_ONE_ONLY (decl) && TREE_PUBLIC (decl))
-    fprintf (file, ".weak_definition %s\n", lab);
+  if (DECL_WEAK (decl))
+    fprintf (file, "\t.weak_definition %s\n", lab);
 
   if (empty)
     {
Index: gcc/config/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.h,v
retrieving revision 1.99
diff -u -p -u -p -r1.99 darwin.h
--- gcc/config/darwin.h	21 Oct 2004 00:53:28 -0000	1.99
+++ gcc/config/darwin.h	26 Oct 2004 00:26:49 -0000
@@ -295,6 +295,7 @@ extern const char *darwin_fix_and_contin
    %{undefined*} \
    %{Zunexported_symbols_list*:-unexported_symbols_list %*} \
    %{Zweak_reference_mismatches*:-weak_reference_mismatches %*} \
+   %{!Zweak_reference_mismatches*:-weak_reference_mismatches non-weak} \
    %{X} \
    %{y*} \
    %{w} \
@@ -364,16 +365,33 @@ extern const char *darwin_fix_and_contin
 
 #define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
 
-/* Making a symbols weak on Darwin requires more than just setting DECL_WEAK. */
-#define MAKE_DECL_ONE_ONLY(DECL) darwin_make_decl_one_only (DECL)
+/* GCC's definition of 'one_only' is the same as its definition of 'weak'.  */
+#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
 
-/* Representation of linkonce symbols for the MACH-O assembler. Linkonce
-   symbols must be given a special section *and* must be preceded by a 
-   special assembler directive. */
-#define ASM_MAKE_LABEL_LINKONCE(FILE,  NAME)                            \
- do { const char* _x = (NAME); if (!!strncmp (_x, "_OBJC_", 6)) {	\
-  fputs (".weak_definition ", FILE); assemble_name (FILE, _x);		\
-  fputs ("\n", FILE); }} while (0)
+/* Mach-O supports 'weak imports', and 'weak definitions' in coalesced
+   sections.  machopic_select_section ensures that weak variables go in
+   coalesced sections.  Weak aliases (or any other kind of aliases) are
+   not supported.  Weak symbols that aren't visible outside the .s file
+   are not supported.  */
+#define ASM_WEAKEN_DECL(FILE, DECL, NAME, ALIAS)			\
+  do {									\
+    if (ALIAS)								\
+      {									\
+	warning ("alias definitions not supported in Mach-O; ignored");	\
+	break;								\
+      }									\
+ 									\
+    if (! DECL_EXTERNAL (DECL) && TREE_PUBLIC (DECL))			\
+      targetm.asm_out.globalize_label (FILE, NAME);			\
+    if (DECL_EXTERNAL (DECL))						\
+      fputs ("\t.weak_reference ", FILE);				\
+    else if (TREE_PUBLIC (DECL))					\
+      fputs ("\t.weak_definition ", FILE);				\
+    else								\
+      break;								\
+    assemble_name (FILE, NAME);						\
+    fputc ('\n', FILE);							\
+  } while (0)
 
 /* We support hidden visibility */
 #undef TARGET_SUPPORTS_HIDDEN
@@ -455,37 +473,37 @@ extern const char *darwin_fix_and_contin
     const char *xname = NAME;						\
     if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF)		\
       xname = IDENTIFIER_POINTER (DECL_NAME (DECL));			\
-    if (! DECL_ONE_ONLY (DECL) && ! DECL_WEAK (DECL))                   \
-      if ((TREE_STATIC (DECL)						\
-	   && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))		\
-          || DECL_INITIAL (DECL))					\
+    if (! DECL_WEAK (DECL)						\
+        && ((TREE_STATIC (DECL)						\
+	     && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))		\
+            || DECL_INITIAL (DECL)))					\
         machopic_define_symbol (DECL_RTL (DECL));			\
     if ((TREE_STATIC (DECL)						\
 	 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))		\
         || DECL_INITIAL (DECL))						\
       (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false);	\
     ASM_OUTPUT_LABEL (FILE, xname);					\
-    /* Darwin doesn't support zero-size objects, so give them a	\
+    /* Darwin doesn't support zero-size objects, so give them a		\
        byte.  */							\
     if (tree_low_cst (DECL_SIZE_UNIT (DECL), 1) == 0)			\
       assemble_zeros (1);						\
   } while (0)
 
-#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
+#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)			\
   do {									\
-    const char *xname = NAME;                                           \
-    if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF)             \
-      xname = IDENTIFIER_POINTER (DECL_NAME (DECL));                    \
-    if (! DECL_ONE_ONLY (DECL) && ! DECL_WEAK (DECL))			\
-      if ((TREE_STATIC (DECL)                                           \
-	   && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))             \
-          || DECL_INITIAL (DECL))                                       \
-        machopic_define_symbol (DECL_RTL (DECL));                       \
-    if ((TREE_STATIC (DECL)                                             \
-	 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
-        || DECL_INITIAL (DECL))                                         \
+    const char *xname = NAME;						\
+    if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF)		\
+      xname = IDENTIFIER_POINTER (DECL_NAME (DECL));			\
+    if (! DECL_WEAK (DECL)						\
+        && ((TREE_STATIC (DECL)						\
+	     && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))		\
+            || DECL_INITIAL (DECL)))					\
+        machopic_define_symbol (DECL_RTL (DECL));			\
+    if ((TREE_STATIC (DECL)						\
+	 && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))		\
+        || DECL_INITIAL (DECL))						\
       (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false);	\
-    ASM_OUTPUT_LABEL (FILE, xname);                                     \
+    ASM_OUTPUT_LABEL (FILE, xname);					\
   } while (0)
 
 #define ASM_DECLARE_CONSTANT_NAME(FILE, NAME, EXP, SIZE)	\
@@ -529,12 +547,12 @@ extern const char *darwin_fix_and_contin
 
 /* Output before executable code.  */
 #undef TEXT_SECTION_ASM_OP
-#define TEXT_SECTION_ASM_OP ".text"
+#define TEXT_SECTION_ASM_OP "\t.text"
 
 /* Output before writable data.  */
 
 #undef DATA_SECTION_ASM_OP
-#define DATA_SECTION_ASM_OP ".data"
+#define DATA_SECTION_ASM_OP "\t.data"
 
 #undef	ALIGN_ASM_OP
 #define ALIGN_ASM_OP		".align"
@@ -580,9 +598,8 @@ FUNCTION (void)								\
     {									\
       if (OBJC)								\
 	objc_section_init ();						\
-      data_section ();							\
       if (asm_out_file)							\
-	fprintf (asm_out_file, "%s\n", DIRECTIVE);			\
+	fputs ("\t" DIRECTIVE "\n", asm_out_file);			\
       in_section = SECTION;						\
     }									\
 }									\
@@ -590,150 +607,178 @@ FUNCTION (void)								\
 /* Darwin uses many types of special sections.  */
 
 #undef	EXTRA_SECTIONS
-#define EXTRA_SECTIONS					\
+#define EXTRA_SECTIONS							\
+  in_text_coal, in_text_unlikely, in_text_unlikely_coal,		\
   in_const, in_const_data, in_cstring, in_literal4, in_literal8,	\
+  in_const_coal, in_const_data_coal, in_data_coal,			\
   in_constructor, in_destructor, in_mod_init, in_mod_term,		\
-  in_objc_class, in_objc_meta_class, in_objc_category,	\
-  in_objc_class_vars, in_objc_instance_vars,		\
-  in_objc_cls_meth, in_objc_inst_meth,			\
-  in_objc_cat_cls_meth, in_objc_cat_inst_meth,		\
-  in_objc_selector_refs,				\
-  in_objc_selector_fixup,				\
-  in_objc_symbols, in_objc_module_info,			\
-  in_objc_protocol, in_objc_string_object,		\
-  in_objc_constant_string_object,			\
-  in_objc_image_info,					\
-  in_objc_class_names, in_objc_meth_var_names,		\
-  in_objc_meth_var_types, in_objc_cls_refs,		\
-  in_machopic_nl_symbol_ptr,				\
-  in_machopic_lazy_symbol_ptr,				\
-  in_machopic_symbol_stub,				\
-  in_machopic_symbol_stub1,				\
-  in_machopic_picsymbol_stub,				\
-  in_machopic_picsymbol_stub1,				\
-  in_darwin_exception, in_darwin_eh_frame,		\
+  in_objc_class, in_objc_meta_class, in_objc_category,			\
+  in_objc_class_vars, in_objc_instance_vars,				\
+  in_objc_cls_meth, in_objc_inst_meth,					\
+  in_objc_cat_cls_meth, in_objc_cat_inst_meth,				\
+  in_objc_selector_refs,						\
+  in_objc_selector_fixup,						\
+  in_objc_symbols, in_objc_module_info,					\
+  in_objc_protocol, in_objc_string_object,				\
+  in_objc_constant_string_object,					\
+  in_objc_image_info,							\
+  in_objc_class_names, in_objc_meth_var_names,				\
+  in_objc_meth_var_types, in_objc_cls_refs,				\
+  in_machopic_nl_symbol_ptr,						\
+  in_machopic_lazy_symbol_ptr,						\
+  in_machopic_symbol_stub,						\
+  in_machopic_symbol_stub1,						\
+  in_machopic_picsymbol_stub,						\
+  in_machopic_picsymbol_stub1,						\
+  in_darwin_exception, in_darwin_eh_frame,				\
   num_sections
 
 #undef	EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS			\
-static void objc_section_init (void);		\
-SECTION_FUNCTION (const_section,		\
-                  in_const,			\
-                  ".const", 0)			\
-SECTION_FUNCTION (const_data_section,		\
-                  in_const_data,		\
-                  ".const_data", 0)		\
-SECTION_FUNCTION (cstring_section,		\
-		  in_cstring,			\
-		  ".cstring", 0)		\
-SECTION_FUNCTION (literal4_section,		\
-		  in_literal4,			\
-		  ".literal4", 0)		\
-SECTION_FUNCTION (literal8_section,		\
-		  in_literal8,			\
-		  ".literal8", 0)		\
-SECTION_FUNCTION (constructor_section,		\
-		  in_constructor,		\
-		  ".constructor", 0)		\
-SECTION_FUNCTION (mod_init_section,		\
-		  in_mod_init,			\
-		  ".mod_init_func", 0)	\
-SECTION_FUNCTION (mod_term_section, \
-		  in_mod_term,			\
-		  ".mod_term_func", 0)	\
-SECTION_FUNCTION (destructor_section,		\
-		  in_destructor,		\
-		  ".destructor", 0)		\
-SECTION_FUNCTION (objc_class_section,		\
-		  in_objc_class,		\
-		  ".objc_class", 1)		\
-SECTION_FUNCTION (objc_meta_class_section,	\
-		  in_objc_meta_class,		\
-		  ".objc_meta_class", 1)	\
-SECTION_FUNCTION (objc_category_section,	\
-		  in_objc_category,		\
-		".objc_category", 1)		\
-SECTION_FUNCTION (objc_class_vars_section,	\
-		  in_objc_class_vars,		\
-		  ".objc_class_vars", 1)	\
-SECTION_FUNCTION (objc_instance_vars_section,	\
-		  in_objc_instance_vars,	\
-		  ".objc_instance_vars", 1)	\
-SECTION_FUNCTION (objc_cls_meth_section,	\
-		  in_objc_cls_meth,		\
-		  ".objc_cls_meth", 1)	\
-SECTION_FUNCTION (objc_inst_meth_section,	\
-		  in_objc_inst_meth,		\
-		  ".objc_inst_meth", 1)	\
-SECTION_FUNCTION (objc_cat_cls_meth_section,	\
-		  in_objc_cat_cls_meth,		\
-		  ".objc_cat_cls_meth", 1)	\
-SECTION_FUNCTION (objc_cat_inst_meth_section,	\
-		  in_objc_cat_inst_meth,	\
-		  ".objc_cat_inst_meth", 1)	\
-SECTION_FUNCTION (objc_selector_refs_section,	\
-		  in_objc_selector_refs,	\
-		  ".objc_message_refs", 1)	\
-SECTION_FUNCTION (objc_selector_fixup_section,	\
-		  in_objc_selector_fixup,	\
-		  ".section __OBJC, __sel_fixup, regular, no_dead_strip", 1)	\
-SECTION_FUNCTION (objc_symbols_section,		\
-		  in_objc_symbols,		\
-		  ".objc_symbols", 1)	\
-SECTION_FUNCTION (objc_module_info_section,	\
-		  in_objc_module_info,		\
-		  ".objc_module_info", 1)	\
-SECTION_FUNCTION (objc_protocol_section,	\
-		  in_objc_protocol,		\
-		  ".objc_protocol", 1)	\
-SECTION_FUNCTION (objc_string_object_section,	\
-		  in_objc_string_object,	\
-		  ".objc_string_object", 1)	\
-SECTION_FUNCTION (objc_constant_string_object_section,	\
-		  in_objc_constant_string_object,	\
-		  ".section __OBJC, __cstring_object, regular, no_dead_strip", 1)	\
-/* Fix-and-Continue image marker.  */		\
-SECTION_FUNCTION (objc_image_info_section,	\
-                  in_objc_image_info,		\
-                  ".section __OBJC, __image_info, regular, no_dead_strip", 1)	\
-SECTION_FUNCTION (objc_class_names_section,	\
-		in_objc_class_names,		\
-		".objc_class_names", 1)	\
-SECTION_FUNCTION (objc_meth_var_names_section,	\
-		in_objc_meth_var_names,		\
-		".objc_meth_var_names", 1)	\
-SECTION_FUNCTION (objc_meth_var_types_section,	\
-		in_objc_meth_var_types,		\
-		".objc_meth_var_types", 1)	\
-SECTION_FUNCTION (objc_cls_refs_section,	\
-		in_objc_cls_refs,		\
-		".objc_cls_refs", 1)		\
-						\
-SECTION_FUNCTION (machopic_lazy_symbol_ptr_section,	\
-		in_machopic_lazy_symbol_ptr,		\
-		".lazy_symbol_pointer", 0)	\
-SECTION_FUNCTION (machopic_nl_symbol_ptr_section,	\
-		in_machopic_nl_symbol_ptr,		\
-		".non_lazy_symbol_pointer", 0)	\
-SECTION_FUNCTION (machopic_symbol_stub_section,		\
-		in_machopic_symbol_stub,		\
-		".symbol_stub", 0)		\
-SECTION_FUNCTION (machopic_symbol_stub1_section,	\
-		in_machopic_symbol_stub1,		\
-		".section __TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16", 0)\
-SECTION_FUNCTION (machopic_picsymbol_stub_section,	\
-		in_machopic_picsymbol_stub,		\
-		".picsymbol_stub", 0)		\
-SECTION_FUNCTION (machopic_picsymbol_stub1_section,	\
-		in_machopic_picsymbol_stub1,		\
-		".section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32", 0)\
-SECTION_FUNCTION (darwin_exception_section,		\
-		in_darwin_exception,			\
-		".section __DATA,__gcc_except_tab", 0)	\
-SECTION_FUNCTION (darwin_eh_frame_section,		\
-		in_darwin_eh_frame,			\
-		".section " EH_FRAME_SECTION_NAME ",__eh_frame" EH_FRAME_SECTION_ATTR, 0)  \
-							\
+#define EXTRA_SECTION_FUNCTIONS					\
+static void objc_section_init (void);				\
+SECTION_FUNCTION (text_coal_section,				\
+		  in_text_coal,					\
+		  ".section __TEXT,__textcoal_nt,coalesced,"	\
+		    "pure_instructions", 0)			\
+SECTION_FUNCTION (text_unlikely_section,			\
+		  in_text_unlikely,				\
+		  ".section __TEXT,__text_unlikely,coalesced,"	\
+		    "pure_instructions", 0)			\
+SECTION_FUNCTION (text_unlikely_coal_section,			\
+		  in_text_unlikely_coal,			\
+		  ".section __TEXT,__text_unlikely_coal,"	\
+		    "coalesced,pure_instructions", 0)		\
+SECTION_FUNCTION (const_section,				\
+                  in_const,					\
+                  ".const", 0)					\
+SECTION_FUNCTION (const_coal_section,				\
+		  in_const_coal,				\
+		  ".section __TEXT,__const_coal,coalesced", 0)	\
+SECTION_FUNCTION (const_data_section,				\
+                  in_const_data,				\
+                  ".const_data", 0)				\
+SECTION_FUNCTION (const_data_coal_section,			\
+                  in_const_data_coal,				\
+                  ".section __DATA,__const_coal,coalesced", 0)	\
+SECTION_FUNCTION (data_coal_section,				\
+                  in_data_coal,					\
+                  ".section __DATA,__datacoal_nt,coalesced", 0)	\
+SECTION_FUNCTION (cstring_section,				\
+		  in_cstring,					\
+		  ".cstring", 0)				\
+SECTION_FUNCTION (literal4_section,				\
+		  in_literal4,					\
+		  ".literal4", 0)				\
+SECTION_FUNCTION (literal8_section,				\
+		  in_literal8,					\
+		  ".literal8", 0)				\
+SECTION_FUNCTION (constructor_section,				\
+		  in_constructor,				\
+		  ".constructor", 0)				\
+SECTION_FUNCTION (mod_init_section,				\
+		  in_mod_init,					\
+		  ".mod_init_func", 0)				\
+SECTION_FUNCTION (mod_term_section,				\
+		  in_mod_term,					\
+		  ".mod_term_func", 0)				\
+SECTION_FUNCTION (destructor_section,				\
+		  in_destructor,				\
+		  ".destructor", 0)				\
+SECTION_FUNCTION (objc_class_section,				\
+		  in_objc_class,				\
+		  ".objc_class", 1)				\
+SECTION_FUNCTION (objc_meta_class_section,			\
+		  in_objc_meta_class,				\
+		  ".objc_meta_class", 1)			\
+SECTION_FUNCTION (objc_category_section,			\
+		  in_objc_category,				\
+		".objc_category", 1)				\
+SECTION_FUNCTION (objc_class_vars_section,			\
+		  in_objc_class_vars,				\
+		  ".objc_class_vars", 1)			\
+SECTION_FUNCTION (objc_instance_vars_section,			\
+		  in_objc_instance_vars,			\
+		  ".objc_instance_vars", 1)			\
+SECTION_FUNCTION (objc_cls_meth_section,			\
+		  in_objc_cls_meth,				\
+		  ".objc_cls_meth", 1)				\
+SECTION_FUNCTION (objc_inst_meth_section,			\
+		  in_objc_inst_meth,				\
+		  ".objc_inst_meth", 1)				\
+SECTION_FUNCTION (objc_cat_cls_meth_section,			\
+		  in_objc_cat_cls_meth,				\
+		  ".objc_cat_cls_meth", 1)			\
+SECTION_FUNCTION (objc_cat_inst_meth_section,			\
+		  in_objc_cat_inst_meth,			\
+		  ".objc_cat_inst_meth", 1)			\
+SECTION_FUNCTION (objc_selector_refs_section,			\
+		  in_objc_selector_refs,			\
+		  ".objc_message_refs", 1)			\
+SECTION_FUNCTION (objc_selector_fixup_section,				     \
+		  in_objc_selector_fixup,				     \
+		  ".section __OBJC, __sel_fixup, regular, no_dead_strip", 1) \
+SECTION_FUNCTION (objc_symbols_section,					\
+		  in_objc_symbols,					\
+		  ".objc_symbols", 1)					\
+SECTION_FUNCTION (objc_module_info_section,				\
+		  in_objc_module_info,					\
+		  ".objc_module_info", 1)				\
+SECTION_FUNCTION (objc_protocol_section,				\
+		  in_objc_protocol,					\
+		  ".objc_protocol", 1)					\
+SECTION_FUNCTION (objc_string_object_section,				\
+		  in_objc_string_object,				\
+		  ".objc_string_object", 1)				\
+SECTION_FUNCTION (objc_constant_string_object_section,			\
+		  in_objc_constant_string_object,			\
+		  ".section __OBJC, __cstring_object, regular, "	\
+		    "no_dead_strip", 1)					\
+/* Fix-and-Continue image marker.  */					\
+SECTION_FUNCTION (objc_image_info_section,				\
+                  in_objc_image_info,					\
+                  ".section __OBJC, __image_info, regular, "		\
+		    "no_dead_strip", 1)					\
+SECTION_FUNCTION (objc_class_names_section,				\
+		in_objc_class_names,					\
+		".objc_class_names", 1)					\
+SECTION_FUNCTION (objc_meth_var_names_section,				\
+		in_objc_meth_var_names,					\
+		".objc_meth_var_names", 1)				\
+SECTION_FUNCTION (objc_meth_var_types_section,				\
+		in_objc_meth_var_types,					\
+		".objc_meth_var_types", 1)				\
+SECTION_FUNCTION (objc_cls_refs_section,				\
+		in_objc_cls_refs,					\
+		".objc_cls_refs", 1)					\
+\
+SECTION_FUNCTION (machopic_lazy_symbol_ptr_section,			\
+		in_machopic_lazy_symbol_ptr,				\
+		".lazy_symbol_pointer", 0)				\
+SECTION_FUNCTION (machopic_nl_symbol_ptr_section,			\
+		in_machopic_nl_symbol_ptr,				\
+		".non_lazy_symbol_pointer", 0)				\
+SECTION_FUNCTION (machopic_symbol_stub_section,				\
+		in_machopic_symbol_stub,				\
+		".symbol_stub", 0)					\
+SECTION_FUNCTION (machopic_symbol_stub1_section,			\
+		in_machopic_symbol_stub1,				\
+		".section __TEXT,__symbol_stub1,symbol_stubs,"		\
+		  "pure_instructions,16", 0)				\
+SECTION_FUNCTION (machopic_picsymbol_stub_section,			\
+		in_machopic_picsymbol_stub,				\
+		".picsymbol_stub", 0)					\
+SECTION_FUNCTION (machopic_picsymbol_stub1_section,			\
+		in_machopic_picsymbol_stub1,				\
+		".section __TEXT,__picsymbolstub1,symbol_stubs,"	\
+		  "pure_instructions,32", 0)				\
+SECTION_FUNCTION (darwin_exception_section,				\
+		in_darwin_exception,					\
+		".section __DATA,__gcc_except_tab", 0)			\
+SECTION_FUNCTION (darwin_eh_frame_section,				\
+		in_darwin_eh_frame,					\
+		".section " EH_FRAME_SECTION_NAME ",__eh_frame"		\
+		  EH_FRAME_SECTION_ATTR, 0)				\
+\
 static void					\
 objc_section_init (void)			\
 {						\
@@ -771,6 +816,8 @@ objc_section_init (void)			\
 
 #undef	TARGET_ASM_SELECT_SECTION
 #define TARGET_ASM_SELECT_SECTION machopic_select_section
+#define USE_SELECT_SECTION_FOR_FUNCTIONS
+
 #undef	TARGET_ASM_SELECT_RTX_SECTION
 #define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section
 #undef  TARGET_ASM_UNIQUE_SECTION
@@ -918,6 +965,9 @@ enum machopic_addr_class {
 #define EH_FRAME_SECTION_NAME   "__TEXT"
 #define EH_FRAME_SECTION_ATTR ",coalesced,no_toc+strip_static_syms+live_support"
 
+/* Java runtime class list.  */
+#define JCR_SECTION_NAME "__DATA,jcr,regular,no_dead_strip"
+
 #undef ASM_PREFERRED_EH_DATA_FORMAT
 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  \
   (((CODE) == 2 && (GLOBAL) == 1) \
@@ -938,8 +988,6 @@ enum machopic_addr_class {
 
 #undef TARGET_ASM_NAMED_SECTION
 #define TARGET_ASM_NAMED_SECTION darwin_asm_named_section
-#undef TARGET_SECTION_TYPE_FLAGS
-#define TARGET_SECTION_TYPE_FLAGS darwin_section_type_flags
 
 #define DARWIN_REGISTER_TARGET_PRAGMAS()			\
   do {								\
Index: gcc/testsuite/objc.dg/image-info.m
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/objc.dg/image-info.m,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 image-info.m
--- gcc/testsuite/objc.dg/image-info.m	4 May 2004 19:03:38 -0000	1.4
+++ gcc/testsuite/objc.dg/image-info.m	26 Oct 2004 00:27:03 -0000
@@ -35,4 +35,4 @@ extern void abort(void);
 }
 @end
 
-/* { dg-final { scan-assembler "\n.data\n.section __OBJC, __image_info.*\n\t.align.*\nL_OBJC_IMAGE_INFO.*:\n\t.long\t0\n\t.long\t1\n.data\n.objc_module_info\n" } } */
+/* { dg-final { scan-assembler "\t.section __OBJC, __image_info.*\n\t.align.*\nL_OBJC_IMAGE_INFO.*:\n\t.long\t0\n\t.long\t1\n\t.objc_module_info\n" } } */
Index: libjava/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.420
diff -u -p -u -p -r1.420 Makefile.am
--- libjava/Makefile.am	15 Oct 2004 17:01:18 -0000	1.420
+++ libjava/Makefile.am	26 Oct 2004 00:27:05 -0000
@@ -69,6 +69,13 @@ else
 SUBDIRS = $(DIRLTDL) gcj include
 endif
 
+## Darwin uses the jcr section, but doesn't use crtstuff.
+if USING_DARWIN_CRT
+DARWIN_CRT_SRC = darwin.cc
+else
+DARWIN_CRT_SRC = 
+endif
+
 # write_entries_to_file - writes each entry in a list
 # to the specified file. Each entry is written individually
 # to accomodate systems with severe command-line-length
@@ -206,6 +213,7 @@ libgcj_la_SOURCES = prims.cc jni.cc exce
 	$(BOEHMGC_SRC) $(NOGC_SRC) \
 	$(BACKTRACE_SRC) \
 	$(POSIX_PLATFORM_SRC) $(WIN32_PLATFORM_SRC) $(ECOS_PLATFORM_SRC) \
+	$(DARWIN_CRT_SRC) \
 	$(POSIX_THREAD_SRC) $(WIN32_THREAD_SRC) $(NO_THREAD_SRC)
 libgcj_la_DEPENDENCIES = libgcj-@gcc_version@.jar \
 	java/lang/fdlibm.h java/lang/ieeefp.h java/lang/mprec.h \
Index: libjava/Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.in,v
retrieving revision 1.448
diff -u -p -u -p -r1.448 Makefile.in
--- libjava/Makefile.in	15 Oct 2004 17:01:19 -0000	1.448
+++ libjava/Makefile.in	26 Oct 2004 00:27:06 -0000
@@ -2261,8 +2261,8 @@ am__libgcj_la_SOURCES_DIST = prims.cc jn
 	javax/transaction/UserTransaction.java \
 	java/lang/ConcreteProcess.java \
 	gnu/classpath/Configuration.java boehm.cc nogc.cc \
-	sysdep/dwarf2-backtrace.cc posix.cc win32.cc posix-threads.cc \
-	win32-threads.cc no-threads.cc
+	sysdep/dwarf2-backtrace.cc posix.cc win32.cc darwin.cc \
+	posix-threads.cc win32-threads.cc no-threads.cc
 am__objects_6 = gnu/gcj/natCore.lo \
 	gnu/gcj/convert/JIS0208_to_Unicode.lo \
 	gnu/gcj/convert/JIS0212_to_Unicode.lo \
@@ -4028,15 +4028,17 @@ am__objects_16 = java/lang/ConcreteProce
 @USING_POSIX_PLATFORM_TRUE@am__objects_20 = posix.lo
 @USING_WIN32_PLATFORM_TRUE@am__objects_21 = win32.lo
 @USING_ECOS_PLATFORM_TRUE@am__objects_22 = posix.lo
-@USING_POSIX_THREADS_TRUE@am__objects_23 = posix-threads.lo
-@USING_WIN32_THREADS_TRUE@am__objects_24 = win32-threads.lo
-@USING_NO_THREADS_TRUE@am__objects_25 = no-threads.lo
+@USING_DARWIN_CRT_TRUE@am__objects_23 = darwin.lo
+@USING_POSIX_THREADS_TRUE@am__objects_24 = posix-threads.lo
+@USING_WIN32_THREADS_TRUE@am__objects_25 = win32-threads.lo
+@USING_NO_THREADS_TRUE@am__objects_26 = no-threads.lo
 am_libgcj_la_OBJECTS = prims.lo jni.lo exception.lo resolve.lo \
 	defineclass.lo interpret.lo verify.lo $(am__objects_6) \
 	$(am__objects_7) $(am__objects_15) $(am__objects_16) \
 	$(am__objects_17) $(am__objects_18) $(am__objects_19) \
 	$(am__objects_20) $(am__objects_21) $(am__objects_22) \
-	$(am__objects_23) $(am__objects_24) $(am__objects_25)
+	$(am__objects_23) $(am__objects_24) $(am__objects_25) \
+	$(am__objects_26)
 libgcj_la_OBJECTS = $(am_libgcj_la_OBJECTS)
 am_libgij_la_OBJECTS = gij.lo
 libgij_la_OBJECTS = $(am_libgij_la_OBJECTS)
@@ -4243,6 +4245,8 @@ THREADSPEC = @THREADSPEC@
 TOOLKIT = @TOOLKIT@
 USING_BOEHMGC_FALSE = @USING_BOEHMGC_FALSE@
 USING_BOEHMGC_TRUE = @USING_BOEHMGC_TRUE@
+USING_DARWIN_CRT_FALSE = @USING_DARWIN_CRT_FALSE@
+USING_DARWIN_CRT_TRUE = @USING_DARWIN_CRT_TRUE@
 USING_ECOS_PLATFORM_FALSE = @USING_ECOS_PLATFORM_FALSE@
 USING_ECOS_PLATFORM_TRUE = @USING_ECOS_PLATFORM_TRUE@
 USING_GCC_FALSE = @USING_GCC_FALSE@
@@ -4355,6 +4359,8 @@ ACLOCAL_AMFLAGS = -I . -I ../config
 @USING_NO_THREADS_TRUE@NO_THREAD_SRC = no-threads.cc
 @TESTSUBDIR_FALSE@SUBDIRS = $(DIRLTDL) gcj include
 @TESTSUBDIR_TRUE@SUBDIRS = $(DIRLTDL) testsuite gcj include
+@USING_DARWIN_CRT_FALSE@DARWIN_CRT_SRC = 
+@USING_DARWIN_CRT_TRUE@DARWIN_CRT_SRC = darwin.cc
 
 # write_entries_to_file - writes each entry in a list
 # to the specified file. Each entry is written individually
@@ -4426,6 +4432,7 @@ libgcj_la_SOURCES = prims.cc jni.cc exce
 	$(BOEHMGC_SRC) $(NOGC_SRC) \
 	$(BACKTRACE_SRC) \
 	$(POSIX_PLATFORM_SRC) $(WIN32_PLATFORM_SRC) $(ECOS_PLATFORM_SRC) \
+	$(DARWIN_CRT_SRC) \
 	$(POSIX_THREAD_SRC) $(WIN32_THREAD_SRC) $(NO_THREAD_SRC)
 
 libgcj_la_DEPENDENCIES = libgcj-@gcc_version@.jar \
@@ -18976,6 +18983,7 @@ distclean-compile:
 	-rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boehm.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/darwin.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/defineclass.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gij.Plo@am__quote@
Index: libjava/configure
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure,v
retrieving revision 1.240
diff -u -p -u -p -r1.240 configure
--- libjava/configure	21 Oct 2004 10:44:36 -0000	1.240
+++ libjava/configure	26 Oct 2004 00:27:07 -0000
@@ -310,7 +310,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS libgcj_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical LN_S mkinstalldirs CC ac_ct_CC EXEEXT OBJEXT CXX ac_ct_CXX CFLAGS CXXFLAGS LDFLAGS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE AS ac_ct_AS AR ac
 _ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBGCJ_CFLAGS LIBGCJ_CXXFLAGS LIBGCJ_JAVAFLAGS INCLTDL LIBLTDL DIRLTDL LIBTOOL CXXCPP CPPFLAGS GCJ GCJFLAGS GCJDEPMODE am__fastdepGCJ_TRUE am__fastdepGCJ_FALSE subdirs COMPPATH TESTSUBDIR_TRUE TESTSUBDIR_FALSE ONESTEP_TRUE ONESTEP_FALSE LIBGCJDEBUG INTERPRETER LIBFFI LIBFFIINCS PLATFORM_INNER_NAT_HDRS CPP EGREP USING_WIN32_PLATFORM_TRUE USING_WIN32_PLATFORM_FALSE USING_POSIX_PLATFORM_TRUE USING_POSIX_PLATFORM_FALSE USING_ECOS_PLATFORM_TRUE USING_ECOS_PLATFORM_FALSE SYSTEMSPEC LIBGCJTESTSPEC ZLIBSPEC ZLIBTESTSPEC X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS TOOLKIT XLIB_AWT_TRUE XLIB_AWT_FALSE GTK_AWT_TRUE GTK_AWT_FALSE GTK_CAIRO_TRUE GTK_CAIRO_FALSE PKG_CONFIG CAIRO_CFLAGS CAIRO_LIBS PANGOFT2_CFLAGS PANGOFT2_LIBS GCLIBS GCINCS GCDEPS GCSPEC JC1GCSPEC GCTESTSPEC USING_BOEHMGC_TRUE USING_BOEHMGC_FALSE USING_NOGC_TRUE USING_NOGC_FALSE THREADLIBS THREADINCS THREADDEPS THREADSPEC THREADLDFLAGS THREADCXXFLAGS U
 SING_POSIX_THREADS_TRUE USING_POSIX_THREADS_FALSE USING_WIN32_THREADS_TRUE USING_WIN32_THREADS_FALSE USING_NO_THREADS_TRUE USING_NO_THREADS_FALSE HASH_SYNC_SPEC USING_GCC_TRUE USING_GCC_FALSE tool_include_dir gcc_version LIBICONV LTLIBICONV GTK_CFLAGS GTK_LIBS GLIB_CFLAGS GLIB_LIBS LIBART_CFLAGS LIBART_LIBS SUPPLY_BACKTRACE_TRUE SUPPLY_BACKTRACE_FALSE GCJH ZIP ac_ct_GCJ ZLIBS SYS_ZLIBS ZINCS DIVIDESPEC CHECKREFSPEC EXCEPTIONSPEC IEEESPEC NATIVE_TRUE NATIVE_FALSE NEEDS_DATA_START_TRUE NEEDS_DATA_START_FALSE GCC_UNWIND_INCLUDE toolexecdir toolexecmainlibdir toolexeclibdir GCJVERSION ALLOCA PERL BACKTRACESPEC SYSDEP_SOURCES here LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS libgcj_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical LN_S mkinstalldirs CC ac_ct_CC EXEEXT OBJEXT CXX ac_ct_CXX CFLAGS CXXFLAGS LDFLAGS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE AS ac_ct_AS AR ac
 _ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBGCJ_CFLAGS LIBGCJ_CXXFLAGS LIBGCJ_JAVAFLAGS INCLTDL LIBLTDL DIRLTDL LIBTOOL CXXCPP CPPFLAGS GCJ GCJFLAGS GCJDEPMODE am__fastdepGCJ_TRUE am__fastdepGCJ_FALSE subdirs COMPPATH TESTSUBDIR_TRUE TESTSUBDIR_FALSE ONESTEP_TRUE ONESTEP_FALSE LIBGCJDEBUG INTERPRETER LIBFFI LIBFFIINCS PLATFORM_INNER_NAT_HDRS CPP EGREP USING_WIN32_PLATFORM_TRUE USING_WIN32_PLATFORM_FALSE USING_POSIX_PLATFORM_TRUE USING_POSIX_PLATFORM_FALSE USING_ECOS_PLATFORM_TRUE USING_ECOS_PLATFORM_FALSE USING_DARWIN_CRT_TRUE USING_DARWIN_CRT_FALSE SYSTEMSPEC LIBGCJTESTSPEC ZLIBSPEC ZLIBTESTSPEC X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS TOOLKIT XLIB_AWT_TRUE XLIB_AWT_FALSE GTK_AWT_TRUE GTK_AWT_FALSE GTK_CAIRO_TRUE GTK_CAIRO_FALSE PKG_CONFIG CAIRO_CFLAGS CAIRO_LIBS PANGOFT2_CFLAGS PANGOFT2_LIBS GCLIBS GCINCS GCDEPS GCSPEC JC1GCSPEC GCTESTSPEC USING_BOEHMGC_TRUE USING_BOEHMGC_FALSE USING_NOGC_TRUE USING_NOGC_FALSE THREADLIBS THREADINCS THREADD
 EPS THREADSPEC THREADLDFLAGS THREADCXXFLAGS USING_POSIX_THREADS_TRUE USING_POSIX_THREADS_FALSE USING_WIN32_THREADS_TRUE USING_WIN32_THREADS_FALSE USING_NO_THREADS_TRUE USING_NO_THREADS_FALSE HASH_SYNC_SPEC USING_GCC_TRUE USING_GCC_FALSE tool_include_dir gcc_version LIBICONV LTLIBICONV GTK_CFLAGS GTK_LIBS GLIB_CFLAGS GLIB_LIBS LIBART_CFLAGS LIBART_LIBS SUPPLY_BACKTRACE_TRUE SUPPLY_BACKTRACE_FALSE GCJH ZIP ac_ct_GCJ ZLIBS SYS_ZLIBS ZINCS DIVIDESPEC CHECKREFSPEC EXCEPTIONSPEC IEEESPEC NATIVE_TRUE NATIVE_FALSE NEEDS_DATA_START_TRUE NEEDS_DATA_START_FALSE GCC_UNWIND_INCLUDE toolexecdir toolexecmainlibdir toolexeclibdir GCJVERSION ALLOCA PERL BACKTRACESPEC SYSDEP_SOURCES here LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -6328,6 +6328,21 @@ else
 fi
 
 
+case "$host" in
+  *-darwin*) DARWIN_CRT=true ;;
+  *) DARWIN_CRT=false ;;
+esac
+
+
+if $DARWIN_CRT; then
+  USING_DARWIN_CRT_TRUE=
+  USING_DARWIN_CRT_FALSE='#'
+else
+  USING_DARWIN_CRT_TRUE='#'
+  USING_DARWIN_CRT_FALSE=
+fi
+
+
 # These may not be defined in a non-ANS conformant embedded system.
 # FIXME: Should these case a runtime exception in that case?
 cat >conftest.$ac_ext <<_ACEOF
@@ -16433,6 +16448,13 @@ echo "$as_me: error: conditional \"USING
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${USING_DARWIN_CRT_TRUE}" && test -z "${USING_DARWIN_CRT_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"USING_DARWIN_CRT\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"USING_DARWIN_CRT\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 if test -z "${XLIB_AWT_TRUE}" && test -z "${XLIB_AWT_FALSE}"; then
   { { echo "$as_me:$LINENO: error: conditional \"XLIB_AWT\" was never defined.
 Usually this means the macro was only invoked conditionally." >&5
@@ -17190,6 +17212,8 @@ s,@USING_POSIX_PLATFORM_TRUE@,$USING_POS
 s,@USING_POSIX_PLATFORM_FALSE@,$USING_POSIX_PLATFORM_FALSE,;t t
 s,@USING_ECOS_PLATFORM_TRUE@,$USING_ECOS_PLATFORM_TRUE,;t t
 s,@USING_ECOS_PLATFORM_FALSE@,$USING_ECOS_PLATFORM_FALSE,;t t
+s,@USING_DARWIN_CRT_TRUE@,$USING_DARWIN_CRT_TRUE,;t t
+s,@USING_DARWIN_CRT_FALSE@,$USING_DARWIN_CRT_FALSE,;t t
 s,@SYSTEMSPEC@,$SYSTEMSPEC,;t t
 s,@LIBGCJTESTSPEC@,$LIBGCJTESTSPEC,;t t
 s,@ZLIBSPEC@,$ZLIBSPEC,;t t
Index: libjava/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.ac,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 configure.ac
--- libjava/configure.ac	21 Oct 2004 10:44:38 -0000	1.10
+++ libjava/configure.ac	26 Oct 2004 00:27:07 -0000
@@ -427,6 +427,12 @@ AM_CONDITIONAL(USING_WIN32_PLATFORM, tes
 AM_CONDITIONAL(USING_POSIX_PLATFORM, test "$PLATFORM" = Posix)
 AM_CONDITIONAL(USING_ECOS_PLATFORM, test "$PLATFORM" = Ecos)
 
+case "$host" in
+  *-darwin*) DARWIN_CRT=true ;;
+  *) DARWIN_CRT=false ;;
+esac
+AM_CONDITIONAL(USING_DARWIN_CRT, $DARWIN_CRT)
+
 # These may not be defined in a non-ANS conformant embedded system.
 # FIXME: Should these case a runtime exception in that case?
 AC_EGREP_HEADER(mktime, time.h, AC_DEFINE(HAVE_MKTIME, 1,
Index: libjava/darwin.cc
===================================================================
RCS file: libjava/darwin.cc
diff -N libjava/darwin.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libjava/darwin.cc	26 Oct 2004 00:27:07 -0000
@@ -0,0 +1,63 @@
+/* darwin.cc - class loader stuff for Darwin.  */
+
+/* Copyright (C) 2004  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+
+#include <jvm.h>
+
+/* In theory, we should be able to do:
+   #include <mach-o/getsect.h>
+   #include <mach-o/dyld.h>
+
+   but all the types in these headers changed between Panther and Tiger,
+   so the only way to be avoid type mismatches is to declare the routines
+   ourself.  */
+
+#include <stdint.h>
+struct mach_header;
+extern "C" void _dyld_register_func_for_add_image
+  (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));
+extern "C" char *getsectdatafromheader
+(const struct mach_header *mhp, const char *segname, const char *sectname,
+ uint32_t *size);
+
+/* 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,
+					  intptr_t slide)
+{
+  char *fde;
+  uint32_t sz;
+
+  fde = getsectdatafromheader (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() 
+  {
+    _dyld_register_func_for_add_image 
+      (darwin_java_register_dyld_add_image_hook);
+    /* At present, you mustn't unload any java plugin.  */
+  };
+} darwin_constructor;
Index: libjava/gcj/Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gcj/Makefile.in,v
retrieving revision 1.56
diff -u -p -u -p -r1.56 Makefile.in
--- libjava/gcj/Makefile.in	23 Sep 2004 01:14:02 -0000	1.56
+++ libjava/gcj/Makefile.in	26 Oct 2004 00:27:08 -0000
@@ -196,6 +196,8 @@ THREADSPEC = @THREADSPEC@
 TOOLKIT = @TOOLKIT@
 USING_BOEHMGC_FALSE = @USING_BOEHMGC_FALSE@
 USING_BOEHMGC_TRUE = @USING_BOEHMGC_TRUE@
+USING_DARWIN_CRT_FALSE = @USING_DARWIN_CRT_FALSE@
+USING_DARWIN_CRT_TRUE = @USING_DARWIN_CRT_TRUE@
 USING_ECOS_PLATFORM_FALSE = @USING_ECOS_PLATFORM_FALSE@
 USING_ECOS_PLATFORM_TRUE = @USING_ECOS_PLATFORM_TRUE@
 USING_GCC_FALSE = @USING_GCC_FALSE@
Index: libjava/include/Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/Makefile.in,v
retrieving revision 1.57
diff -u -p -u -p -r1.57 Makefile.in
--- libjava/include/Makefile.in	23 Sep 2004 01:14:02 -0000	1.57
+++ libjava/include/Makefile.in	26 Oct 2004 00:27:08 -0000
@@ -195,6 +195,8 @@ THREADSPEC = @THREADSPEC@
 TOOLKIT = @TOOLKIT@
 USING_BOEHMGC_FALSE = @USING_BOEHMGC_FALSE@
 USING_BOEHMGC_TRUE = @USING_BOEHMGC_TRUE@
+USING_DARWIN_CRT_FALSE = @USING_DARWIN_CRT_FALSE@
+USING_DARWIN_CRT_TRUE = @USING_DARWIN_CRT_TRUE@
 USING_ECOS_PLATFORM_FALSE = @USING_ECOS_PLATFORM_FALSE@
 USING_ECOS_PLATFORM_TRUE = @USING_ECOS_PLATFORM_TRUE@
 USING_GCC_FALSE = @USING_GCC_FALSE@
Index: libjava/include/jvm.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/jvm.h,v
retrieving revision 1.68
diff -u -p -u -p -r1.68 jvm.h
--- libjava/include/jvm.h	12 Aug 2004 06:53:42 -0000	1.68
+++ libjava/include/jvm.h	26 Oct 2004 00:27:08 -0000
@@ -411,7 +411,9 @@ extern "C" void *_Jv_LookupInterfaceMeth
                                                int meth_idx);
 extern "C" void _Jv_CheckArrayStore (jobject array, jobject obj);
 extern "C" void _Jv_RegisterClass (jclass klass);
-extern "C" void _Jv_RegisterClasses (jclass *classes);
+extern "C" void _Jv_RegisterClasses (const jclass *classes);
+extern "C" void _Jv_RegisterClasses_Counted (const jclass *classes,
+					     size_t count);
 extern "C" void _Jv_RegisterResource (void *vptr);
 extern void _Jv_UnregisterClass (_Jv_Utf8Const*, java::lang::ClassLoader*);
 extern void _Jv_ResolveField (_Jv_Field *, java::lang::ClassLoader*);
Index: libjava/java/lang/Class.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/Class.h,v
retrieving revision 1.69
diff -u -p -u -p -r1.69 Class.h
--- libjava/java/lang/Class.h	12 Aug 2004 06:53:42 -0000	1.69
+++ libjava/java/lang/Class.h	26 Oct 2004 00:27:09 -0000
@@ -14,6 +14,7 @@ details.  */
 
 #pragma interface
 
+#include <stddef.h>
 #include <java/lang/Object.h>
 #include <java/lang/String.h>
 #include <java/net/URL.h>
@@ -24,7 +25,9 @@ details.  */
 
 // We declare these here to avoid including gcj/cni.h.
 extern "C" void _Jv_InitClass (jclass klass);
-extern "C" void _Jv_RegisterClasses (jclass *classes);
+extern "C" void _Jv_RegisterClasses (const jclass *classes);
+extern "C" void _Jv_RegisterClasses_Counted (const jclass *classes,
+					     size_t count);
 
 // This must be predefined with "C" linkage.
 extern "C" void *_Jv_LookupInterfaceMethodIdx (jclass klass, jclass iface, 
@@ -310,7 +313,9 @@ private:   
   friend class java::io::ObjectStreamClass;
 
   friend void _Jv_WaitForState (jclass, int);
-  friend void _Jv_RegisterClasses (jclass *classes);
+  friend void _Jv_RegisterClasses (const jclass *classes);
+  friend void _Jv_RegisterClasses_Counted (const jclass *classes, 
+					   size_t count);
   friend void _Jv_RegisterClassHookDefault (jclass klass);
   friend void _Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
   friend void _Jv_UnregisterClass (jclass);
Index: libjava/java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.70
diff -u -p -u -p -r1.70 natClassLoader.cc
--- libjava/java/lang/natClassLoader.cc	20 Oct 2004 21:42:33 -0000	1.70
+++ libjava/java/lang/natClassLoader.cc	26 Oct 2004 00:27:09 -0000
@@ -316,7 +316,7 @@ _Jv_RegisterInitiatingLoader (jclass kla
 // class chain.  At all other times, the caller should synchronize on
 // Class::class$.
 void
-_Jv_RegisterClasses (jclass *classes)
+_Jv_RegisterClasses (const jclass *classes)
 {
   for (; *classes; ++classes)
     {
@@ -331,6 +331,24 @@ _Jv_RegisterClasses (jclass *classes)
     }
 }
 
+// This is a version of _Jv_RegisterClasses that takes a count.
+void
+_Jv_RegisterClasses_Counted (const jclass * classes, size_t count)
+{
+  size_t i;
+  for (i = 0; i < count; i++)
+    {
+      jclass klass = classes[i];
+
+      (*_Jv_RegisterClassHook) (klass);
+
+      // registering a compiled class causes
+      // it to be immediately "prepared".  
+      if (klass->state == JV_STATE_NOTHING)
+	klass->state = JV_STATE_COMPILED;
+    }
+}
+
 void
 _Jv_RegisterClassHookDefault (jclass klass)
 {
Index: libjava/testsuite/Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/testsuite/Makefile.in,v
retrieving revision 1.67
diff -u -p -u -p -r1.67 Makefile.in
--- libjava/testsuite/Makefile.in	23 Sep 2004 01:14:03 -0000	1.67
+++ libjava/testsuite/Makefile.in	26 Oct 2004 00:27:10 -0000
@@ -184,6 +184,8 @@ THREADSPEC = @THREADSPEC@
 TOOLKIT = @TOOLKIT@
 USING_BOEHMGC_FALSE = @USING_BOEHMGC_FALSE@
 USING_BOEHMGC_TRUE = @USING_BOEHMGC_TRUE@
+USING_DARWIN_CRT_FALSE = @USING_DARWIN_CRT_FALSE@
+USING_DARWIN_CRT_TRUE = @USING_DARWIN_CRT_TRUE@
 USING_ECOS_PLATFORM_FALSE = @USING_ECOS_PLATFORM_FALSE@
 USING_ECOS_PLATFORM_TRUE = @USING_ECOS_PLATFORM_TRUE@
 USING_GCC_FALSE = @USING_GCC_FALSE@
Index: libstdc++-v3/configure.host
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/configure.host,v
retrieving revision 1.30
diff -u -p -u -p -r1.30 configure.host
--- libstdc++-v3/configure.host	5 Oct 2004 13:45:36 -0000	1.30
+++ libstdc++-v3/configure.host	26 Oct 2004 00:27:13 -0000
@@ -172,6 +172,13 @@ case "${host_os}" in
   cygwin*)
     os_include_dir="os/newlib"
     ;;
+  darwin*)
+    # On Darwin, performance is improved if libstdc++ is single-module.
+    # Up to at least 10.3.5, -flat_namespace is required for proper
+    # treatment of coalesced symbols.
+    OPT_LDFLAGS="${OPT_LDFLAGS} -Wl,-single_module -Wl,-flat_namespace"
+    os_include_dir="os/generic"
+    ;;
   *djgpp*)      # leading * picks up "msdosdjgpp"
     os_include_dir="os/djgpp"
     ;;
Index: libstdc++-v3/libsupc++/del_op.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/del_op.cc,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 del_op.cc
--- libstdc++-v3/libsupc++/del_op.cc	3 Aug 2004 07:11:16 -0000	1.6
+++ libstdc++-v3/libsupc++/del_op.cc	26 Oct 2004 00:27:14 -0000
@@ -39,7 +39,7 @@ using std::free;
 extern "C" void free(void *);
 #endif
 
-void
+__attribute__((weak)) void
 operator delete (void *ptr) throw ()
 {
   if (ptr)
Index: libstdc++-v3/libsupc++/del_opnt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/del_opnt.cc,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 del_opnt.cc
--- libstdc++-v3/libsupc++/del_opnt.cc	24 May 2003 16:22:03 -0000	1.3
+++ libstdc++-v3/libsupc++/del_opnt.cc	26 Oct 2004 00:27:14 -0000
@@ -32,7 +32,7 @@
 
 extern "C" void free (void *);
 
-void
+__attribute__((weak)) void
 operator delete (void *ptr, const std::nothrow_t&) throw ()
 {
   if (ptr)
Index: libstdc++-v3/libsupc++/del_opv.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/del_opv.cc,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 del_opv.cc
--- libstdc++-v3/libsupc++/del_opv.cc	24 May 2003 16:22:03 -0000	1.3
+++ libstdc++-v3/libsupc++/del_opv.cc	26 Oct 2004 00:27:14 -0000
@@ -30,7 +30,7 @@
 
 #include "new"
 
-void
+__attribute__((weak)) void
 operator delete[] (void *ptr) throw ()
 {
   ::operator delete (ptr);
Index: libstdc++-v3/libsupc++/del_opvnt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/del_opvnt.cc,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 del_opvnt.cc
--- libstdc++-v3/libsupc++/del_opvnt.cc	24 May 2003 16:22:03 -0000	1.3
+++ libstdc++-v3/libsupc++/del_opvnt.cc	26 Oct 2004 00:27:14 -0000
@@ -30,7 +30,7 @@
 
 #include "new"
 
-void
+__attribute__((weak)) void
 operator delete[] (void *ptr, const std::nothrow_t&) throw ()
 {
   ::operator delete (ptr);
Index: libstdc++-v3/libsupc++/new_op.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_op.cc,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 new_op.cc
--- libstdc++-v3/libsupc++/new_op.cc	3 Aug 2004 07:11:16 -0000	1.8
+++ libstdc++-v3/libsupc++/new_op.cc	26 Oct 2004 00:27:14 -0000
@@ -43,7 +43,7 @@ extern "C" void *malloc (std::size_t);
 
 extern new_handler __new_handler;
 
-void *
+__attribute__((weak)) void *
 operator new (std::size_t sz) throw (std::bad_alloc)
 {
   void *p;
Index: libstdc++-v3/libsupc++/new_opnt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_opnt.cc,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 new_opnt.cc
--- libstdc++-v3/libsupc++/new_opnt.cc	24 May 2003 16:22:03 -0000	1.4
+++ libstdc++-v3/libsupc++/new_opnt.cc	26 Oct 2004 00:27:14 -0000
@@ -36,7 +36,7 @@ using std::bad_alloc;
 extern "C" void *malloc (std::size_t);
 extern new_handler __new_handler;
 
-void *
+__attribute__((weak)) void *
 operator new (std::size_t sz, const std::nothrow_t&) throw()
 {
   void *p;
Index: libstdc++-v3/libsupc++/new_opv.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_opv.cc,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 new_opv.cc
--- libstdc++-v3/libsupc++/new_opv.cc	24 May 2003 16:22:03 -0000	1.4
+++ libstdc++-v3/libsupc++/new_opv.cc	26 Oct 2004 00:27:14 -0000
@@ -30,7 +30,7 @@
 
 #include "new"
 
-void *
+__attribute__((weak)) void *
 operator new[] (std::size_t sz) throw (std::bad_alloc)
 {
   return ::operator new(sz);
Index: libstdc++-v3/libsupc++/new_opvnt.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_opvnt.cc,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 new_opvnt.cc
--- libstdc++-v3/libsupc++/new_opvnt.cc	24 May 2003 16:22:03 -0000	1.4
+++ libstdc++-v3/libsupc++/new_opvnt.cc	26 Oct 2004 00:27:14 -0000
@@ -30,7 +30,7 @@
 
 #include "new"
 
-void *
+__attribute__((weak)) void *
 operator new[] (std::size_t sz, const std::nothrow_t& nothrow) throw()
 {
   return ::operator new(sz, nothrow);
============================================================


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