diff mbox

[ObjC/Darwin,1/3] Fix wrong code gen for m64 Objective-C

Message ID 693A7472-3577-43AA-97B1-D5C2899651FC@sandoe-acoustics.co.uk
State New
Headers show

Commit Message

Iain Sandoe Feb. 14, 2011, 1:16 p.m. UTC
Hello all,

This patch corrects one of the two most significant outstanding Darwin  
problems;

That is, that we generate incorrect code and meta-data for m64  
Objective-C/C++, rendering these front ends of limited use on current  
darwin/OSX systems.   We also incorrectly assign GNU runtime data to  
NeXT sections when LTO is active at m32.

---

The patch-set has been reviewed and approved off-list for the  
Objective-C, Objective-C++ and Darwin aspects.

It touches only one file outside darwin & objc -
- which is to add two required flags to c-family/c.opt (for which I  
also need approval)

===

As far as when to apply it:

Whilst we are in stage-4, I believe that Richard (G) indicated that  
wrong-code bugs were eligible for inclusion, even at this stage.

If I have understood that correctly, I would ask please might this be  
included in 4.6,
since it would be of considerable benefit to arguably the main targets  
for Objective-C.

I should add that the patch is emphatically _not_ a "last minute fix" ..
.. it has been in progress for some months, it's regrettable that it  
should be ready so late.
(but that is a problem with volunteer contributions, I guess)

===

The patch has been tested thus:
   bootstrap/regtest
     i686-linux (F13)
     x86_64-linux (U10.10) @ m64/m32
     i686-darwin{8,9}, x86_64-darwin10, powerpc-darwin9 *
     cris-elf (simulator).

    * on Darwin 9 and Darwin 10 Objective C/C++ are tested with
    RUNTESTFLAGS="--target_board=unix\{-m32,-m32/-fobjc-abi-version=1,- 
m64} "
   to confirm the NeXT  V1 ABI at m32.

   without regression and with the expected new passes.

   I have also built a version that can be used from XCode and  
verified that the compiler builds

   http://developer.snowmintcs.com/frameworks/sm2dgraphview/
   http://aldebaran.armory.com/~zenomt/macosx/MTCoreAudio/

   for m32 and m64.
   for the first time since Darwin 9 was released :-)

cheers
Iain

====

** All three parts are required, I have split it up for ease of  
potentially different reviewer focus.

====

gcc/c-family

	* c.opts (fobjc-abi-version=) New.
	(fobjc-nilcheck): New.

gcc

	* config/darwin-c.c (darwin_cpp_builtins): Set __OBJC2__.
	* config/darwin.c (output_objc_section_asm_op): handle sections for
	objective-c ABI 1 and 2.
	(is_objc_metadata): Recognize objective-c meta-data attributes.
	(darwin_objc2_section): New.
	(darwin_objc1_section): New.
	(machopic_select_section): Improve robustness of objective-c section
	selection, deprecate the existing scheme (warn on use).
	(darwin_emit_objc_zeroed): Correct sections for Objective-c items  
placed
	into BSS.
	(darwin_output_aligned_bss): Likewise.
	(darwin_asm_output_aligned_decl_common): Likewise.
	(darwin_asm_output_aligned_decl_local): Likewise.
	* config/darwin-sections.def: Add section definitions for objective-c  
ABI 1
	and 2.
	* config/darwin.h (SUBTARGET_C_COMMON_OVERRIDE_OPTIONS):
	Set the default objective-c ABI correctly for m64 compilation.
	Adjust an over-length line.
Index: gcc/config/darwin-c.c
===================================================================
--- gcc/config/darwin-c.c	(revision 170111)
+++ gcc/config/darwin-c.c	(working copy)
@@ -629,6 +629,9 @@ darwin_cpp_builtins (cpp_reader *pfile)
       builtin_define ("__strong=");
       builtin_define ("__weak=");
     }
+
+  if (flag_objc_abi == 2)
+    builtin_define ("__OBJC2__");
 }
 
 /* Handle C family front-end options.  */
Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c	(revision 170111)
+++ gcc/config/darwin.c	(working copy)
@@ -148,13 +148,48 @@ output_objc_section_asm_op (const void *directive)
 	  objc_class_vars_section,
 	  objc_instance_vars_section,
 	  objc_module_info_section,
-	  objc_symbols_section
+	  objc_symbols_section,
 	};
+      /* ABI=1 */
+      static const enum darwin_section_enum tomarkv1[] =
+	{
+	  objc1_protocol_ext_section,
+	  objc1_class_ext_section,
+	  objc1_prop_list_section
+	} ;
+      /* ABI=2 */
+      static const enum darwin_section_enum tomarkv2[] =
+	{
+	  objc2_message_refs_section,
+	  objc2_classdefs_section,
+	  objc2_metadata_section,
+	  objc2_classrefs_section,
+	  objc2_classlist_section,
+	  objc2_categorylist_section,
+	  objc2_selector_refs_section,
+	  objc2_nonlazy_class_section,
+	  objc2_nonlazy_category_section,
+	  objc2_protocollist_section,
+	  objc2_protocolrefs_section,
+	  objc2_super_classrefs_section,
+	  objc2_image_info_section,
+	  objc2_constant_string_object_section
+	} ;
       size_t i;
 
       been_here = true;
-      for (i = 0; i < ARRAY_SIZE (tomark); i++)
-	switch_to_section (darwin_sections[tomark[i]]);
+      if (flag_objc_abi < 2)
+	{
+	  for (i = 0; i < ARRAY_SIZE (tomark); i++)
+	    switch_to_section (darwin_sections[tomark[i]]);
+	  if (flag_objc_abi == 1)
+	    for (i = 0; i < ARRAY_SIZE (tomarkv1); i++)
+	      switch_to_section (darwin_sections[tomarkv1[i]]);
+	}
+      else
+	for (i = 0; i < ARRAY_SIZE (tomarkv2); i++)
+	  switch_to_section (darwin_sections[tomarkv2[i]]);
+      /* Make sure we don't get varasm.c out of sync with us.  */
       switch_to_section (saved_in_section);
     }
   output_section_asm_op (directive);
@@ -277,7 +312,6 @@ indirect_data (rtx sym_ref)
   return ! lprefix;
 }
 
-
 static int
 machopic_data_defined_p (rtx sym_ref)
 {
@@ -1233,6 +1267,177 @@ machopic_reloc_rw_mask (void)
   return MACHOPIC_INDIRECT ? 3 : 0;
 }
 
+/* We have to deal with ObjC/C++ metadata section placement in the common
+   code, since it will also be called from LTO.
+   
+   Return metadata attributes, if present (searching for ABI=2 first)
+   Return NULL_TREE if no such attributes are found.  */
+
+static tree
+is_objc_metadata (tree decl)
+{
+  if (DECL_P (decl) 
+      && (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == CONST_DECL)
+      && DECL_ATTRIBUTES (decl))
+    {
+      tree meta = lookup_attribute ("OBJC2META", DECL_ATTRIBUTES (decl));
+      if (meta)
+	return meta;
+      meta = lookup_attribute ("OBJC1META", DECL_ATTRIBUTES (decl));
+      if (meta)
+	return meta;
+    }
+  return NULL_TREE;
+}
+
+/* Return the section required for Objective C ABI 2 metadata.  */
+static section *
+darwin_objc2_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base)
+{
+  const char *p;
+  tree ident = TREE_VALUE (meta);
+  gcc_assert (TREE_CODE (ident) == IDENTIFIER_NODE);
+  p = IDENTIFIER_POINTER (ident);
+
+  /* If we are in LTO, then we don't know the state of flag_next_runtime
+     or flag_objc_abi when the code was generated.  We set these from the
+     meta-data - which is needed to deal with const string constructors.  */
+
+  flag_next_runtime = 1;
+  flag_objc_abi = 2;
+
+  if (base == data_section)
+    base = darwin_sections[objc2_metadata_section];
+
+  /* Most of the OBJC2 META-data end up in the base section, so check it
+     first.  */
+  if      (!strncmp (p, "V2_BASE", 7))
+    return base;
+  else if (!strncmp (p, "V2_STRG", 7))
+    return darwin_sections[cstring_section];
+
+  else if (!strncmp (p, "G2_META", 7) || !strncmp (p, "G2_CLAS", 7))
+    return darwin_sections[objc2_classdefs_section];
+  else if (!strncmp (p, "V2_MREF", 7))
+    return darwin_sections[objc2_message_refs_section];
+  else if (!strncmp (p, "V2_CLRF", 7))
+    return darwin_sections[objc2_classrefs_section];
+  else if (!strncmp (p, "V2_SURF", 7))
+    return darwin_sections[objc2_super_classrefs_section];
+  else if (!strncmp (p, "V2_NLCL", 7))
+    return darwin_sections[objc2_nonlazy_class_section];
+  else if (!strncmp (p, "V2_CLAB", 7))
+    return darwin_sections[objc2_classlist_section];
+  else if (!strncmp (p, "V2_SRFS", 7))
+    return darwin_sections[objc2_selector_refs_section];
+  else if (!strncmp (p, "V2_NLCA", 7))
+    return darwin_sections[objc2_nonlazy_category_section];
+  else if (!strncmp (p, "V2_CALA", 7))
+    return darwin_sections[objc2_categorylist_section];
+
+  else if (!strncmp (p, "V2_PLST", 7))
+    return darwin_sections[objc2_protocollist_section];
+  else if (!strncmp (p, "V2_PRFS", 7))
+    return darwin_sections[objc2_protocolrefs_section];
+
+  else if (!strncmp (p, "V2_INFO", 7))
+    return darwin_sections[objc2_image_info_section];
+
+  else if (!strncmp (p, "V2_EHTY", 7))
+    return darwin_sections[data_coal_section];
+
+  else if (!strncmp (p, "V2_CSTR", 7))
+    return darwin_sections[objc2_constant_string_object_section];
+
+  /* Not recognized, default.  */
+  return base;
+}
+
+/* Return the section required for Objective C ABI 0/1 metadata.  */
+static section *
+darwin_objc1_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base)
+{
+  const char *p;
+  tree ident = TREE_VALUE (meta);
+  gcc_assert (TREE_CODE (ident) == IDENTIFIER_NODE);
+  p = IDENTIFIER_POINTER (ident);
+
+  /* If we are in LTO, then we don't know the state of flag_next_runtime
+     or flag_objc_abi when the code was generated.  We set these from the
+     meta-data - which is needed to deal with const string constructors.  */
+  flag_next_runtime = 1;
+  if (!global_options_set.x_flag_objc_abi)
+    flag_objc_abi = 1;
+
+  /* String sections first, cos there are lots of strings.  */
+  if      (!strncmp (p, "V1_STRG", 7))
+    return darwin_sections[cstring_section];
+  else if (!strncmp (p, "V1_CLSN", 7))
+    return darwin_sections[objc_class_names_section];
+  else if (!strncmp (p, "V1_METN", 7))
+    return darwin_sections[objc_meth_var_names_section];
+  else if (!strncmp (p, "V1_METT", 7))
+    return darwin_sections[objc_meth_var_types_section];
+
+  else if (!strncmp (p, "V1_CLAS", 7))
+    return darwin_sections[objc_class_section];
+  else if (!strncmp (p, "V1_META", 7))
+    return darwin_sections[objc_meta_class_section];
+  else if (!strncmp (p, "V1_CATG", 7))
+    return darwin_sections[objc_category_section];
+  else if (!strncmp (p, "V1_PROT", 7))
+    return darwin_sections[objc_protocol_section];
+
+  else if (!strncmp (p, "V1_CLCV", 7))
+    return darwin_sections[objc_class_vars_section];
+  else if (!strncmp (p, "V1_CLIV", 7))
+    return darwin_sections[objc_instance_vars_section];
+
+  else if (!strncmp (p, "V1_CLCM", 7))
+    return darwin_sections[objc_cls_meth_section];
+  else if (!strncmp (p, "V1_CLIM", 7))
+    return darwin_sections[objc_inst_meth_section];
+  else if (!strncmp (p, "V1_CACM", 7))
+    return darwin_sections[objc_cat_cls_meth_section];
+  else if (!strncmp (p, "V1_CAIM", 7))
+    return darwin_sections[objc_cat_inst_meth_section];
+  else if (!strncmp (p, "V1_PNSM", 7))
+    return darwin_sections[objc_cat_inst_meth_section];
+  else if (!strncmp (p, "V1_PCLM", 7))
+    return darwin_sections[objc_cat_cls_meth_section];
+
+  else if (!strncmp (p, "V1_CLPR", 7))
+    return darwin_sections[objc_cat_cls_meth_section];
+  else if (!strncmp (p, "V1_CAPR", 7))
+    return darwin_sections[objc_category_section]; /* ??? CHECK me.  */
+
+  else if (!strncmp (p, "V1_PRFS", 7))
+    return darwin_sections[objc_cat_cls_meth_section];
+  else if (!strncmp (p, "V1_CLRF", 7))
+    return darwin_sections[objc_cls_refs_section];
+  else if (!strncmp (p, "V1_SRFS", 7))
+    return darwin_sections[objc_selector_refs_section];
+
+  else if (!strncmp (p, "V1_MODU", 7))
+    return darwin_sections[objc_module_info_section];
+  else if (!strncmp (p, "V1_SYMT", 7))
+    return darwin_sections[objc_symbols_section];
+  else if (!strncmp (p, "V1_INFO", 7))
+    return darwin_sections[objc_image_info_section];
+
+  else if (!strncmp (p, "V1_PLST", 7))
+    return darwin_sections[objc1_prop_list_section];
+  else if (!strncmp (p, "V1_PEXT", 7))
+    return darwin_sections[objc1_protocol_ext_section];
+  else if (!strncmp (p, "V1_CEXT", 7))
+    return darwin_sections[objc1_class_ext_section];
+
+  else if (!strncmp (p, "V2_CSTR", 7))
+    return darwin_sections[objc_constant_string_object_section];
+
+  return base;
+}
+
 section *
 machopic_select_section (tree decl,
 			 int reloc,
@@ -1331,7 +1536,25 @@ machopic_select_section (tree decl,
       gcc_unreachable ();
     }
 
-  /* Darwin weird special cases.  */
+  /* Darwin weird special cases.  
+     a) OBJC Meta-data. */
+  if (DECL_P (decl) 
+      && (TREE_CODE (decl) == VAR_DECL 
+	  || TREE_CODE (decl) == CONST_DECL)
+      && DECL_ATTRIBUTES (decl))
+    {
+      tree meta = lookup_attribute ("OBJC2META", DECL_ATTRIBUTES (decl));
+      if (meta)
+	return darwin_objc2_section (decl, meta, base_section);
+      meta = lookup_attribute ("OBJC1META", DECL_ATTRIBUTES (decl));
+      if (meta)
+	return darwin_objc1_section (decl, meta, base_section);
+      meta = lookup_attribute ("OBJC1METG", DECL_ATTRIBUTES (decl));
+      if (meta)
+	return base_section; /* GNU runtime is happy with it all in one pot.  */
+    }
+
+  /* b) Constant string objects.  */
   if (TREE_CODE (decl) == CONSTRUCTOR
       && TREE_TYPE (decl)
       && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
@@ -1341,29 +1564,53 @@ machopic_select_section (tree decl,
       if (TREE_CODE (name) == TYPE_DECL)
         name = DECL_NAME (name);
 
+      /* FIXME: This is unsatisfactory for LTO, since it relies on other
+	 metadata determining the source FE.  */
       if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_ObjCString"))
-        {
-          if (flag_next_runtime)
-            return darwin_sections[objc_constant_string_object_section];
-          else
-            return darwin_sections[objc_string_object_section];
-        }
+	{
+	  if (flag_next_runtime)
+	    {
+	      if (flag_objc_abi == 2)
+		return darwin_sections[objc2_constant_string_object_section];
+	      else
+		return darwin_sections[objc_constant_string_object_section];
+	    }
+	  else
+	    return darwin_sections[objc_string_object_section];
+	}
       else if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_CFString"))
 	return darwin_sections[cfstring_constant_object_section];
       else
-        return base_section;
+	return base_section;
     }
+  /* c) legacy meta-data selection.  */
   else if (TREE_CODE (decl) == VAR_DECL
 	   && DECL_NAME (decl)
 	   && TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE
 	   && IDENTIFIER_POINTER (DECL_NAME (decl))
+	   && flag_next_runtime
 	   && !strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "_OBJC_", 6))
     {
       const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
-
+      static bool warned_objc_46 = false;
       /* We shall assert that zero-sized objects are an error in ObjC 
          meta-data.  */
       gcc_assert (tree_low_cst (DECL_SIZE_UNIT (decl), 1) != 0);
+      
+      /* ??? This mechanism for determining the metadata section is
+	 broken when LTO is in use, since the frontend that generated
+	 the data is not identified.  We will keep the capability for
+	 the short term - in case any non-Objective-C programs are using
+	 it to place data in specified sections.  */
+      if (!warned_objc_46)
+	{
+	  location_t loc = DECL_SOURCE_LOCATION (decl);
+	  warning_at (loc, 0, "the use of _OBJC_-prefixed variable names"
+		      " to select meta-data sections is deprecated at 4.6"
+		      " and will be removed in 4.7");
+	  warned_objc_46 = true;
+	}
+      
       if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))
         return darwin_sections[objc_cls_meth_section];
       else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))
@@ -1911,6 +2158,30 @@ darwin_emit_weak_or_comdat (FILE *fp, tree decl, c
     assemble_zeros (size);
 }
 
+/* Emit a chunk of data for ObjC meta-data that got placed in BSS erroneously.  */
+static void
+darwin_emit_objc_zeroed (FILE *fp, tree decl, const char *name,
+				  unsigned HOST_WIDE_INT size, 
+				  unsigned int align, tree meta)
+{
+  section *ocs = data_section;
+
+  if (TREE_PURPOSE (meta) == get_identifier("OBJC2META"))
+    ocs = darwin_objc2_section (decl, meta, ocs);
+  else
+    ocs = darwin_objc1_section (decl, meta, ocs);
+
+  switch_to_section (ocs);
+
+  /* We shall declare that zero-sized meta-data are not valid (yet).  */
+  gcc_assert (size);
+  fprintf (fp, "\t.align\t%d\n", floor_log2 (align / BITS_PER_UNIT));
+
+  /* ... and we let it deal with outputting one byte of zero for them too.  */ 
+  darwin_asm_declare_object_name (fp, name, decl);
+  assemble_zeros (size);
+}
+
 /* This routine emits 'local' storage:
 
    When Section Anchors are off this routine emits .zerofill commands in 
@@ -2042,6 +2313,7 @@ darwin_output_aligned_bss (FILE *fp, tree decl, co
 {
   unsigned int l2align;
   bool one, pub, weak;
+  tree meta;
 
   pub = TREE_PUBLIC (decl);
   one = DECL_ONE_ONLY (decl);
@@ -2058,6 +2330,14 @@ fprintf (fp, "# albss: %s (%lld,%d) ro %d cst %d s
 	pub, weak, one, (unsigned long)DECL_INITIAL (decl)); 
 #endif
 
+  /* ObjC metadata can get put in BSS because varasm.c decides it's BSS 
+     before the target has a chance to comment.  */
+  if ((meta = is_objc_metadata (decl)))
+    {
+      darwin_emit_objc_zeroed (fp, decl, name, size, DECL_ALIGN (decl), meta);
+      return;
+    }
+
   /* Check that any initializer is valid.  */
   gcc_assert ((DECL_INITIAL (decl) == NULL) 
 	       || (DECL_INITIAL (decl) == error_mark_node) 
@@ -2152,6 +2432,8 @@ darwin_asm_output_aligned_decl_common (FILE *fp, t
 {
   unsigned int l2align;
   bool one, weak;
+  tree meta;
+
   /* No corresponding var.  */
   if (decl==NULL)
     {
@@ -2176,6 +2458,14 @@ fprintf (fp, "# adcom: %s (%lld,%d) ro %d cst %d s
 	TREE_PUBLIC (decl), weak, one, (unsigned long)DECL_INITIAL (decl)); 
 #endif
 
+  /* ObjC metadata can get put in BSS because varasm.c decides it's BSS 
+     before the target has a chance to comment.  */
+  if ((meta = is_objc_metadata (decl)))
+    {
+      darwin_emit_objc_zeroed (fp, decl, name, size, DECL_ALIGN (decl), meta);
+      return;
+    }
+
   /* We shouldn't be messing with this if the decl has a section name.  */
   gcc_assert (DECL_SECTION_NAME (decl) == NULL);
 
@@ -2222,6 +2512,7 @@ darwin_asm_output_aligned_decl_local (FILE *fp, tr
 {
   unsigned long l2align;
   bool one, weak;
+  tree meta;
 
   one = DECL_ONE_ONLY (decl);
   weak = (DECL_P (decl)
@@ -2237,6 +2528,14 @@ fprintf (fp, "# adloc: %s (%lld,%d) ro %d cst %d s
 	weak , (unsigned long)DECL_INITIAL (decl)); 
 #endif
 
+  /* ObjC metadata can get put in BSS because varasm.c decides it's BSS 
+     before the target has a chance to comment.  */
+  if ((meta = is_objc_metadata (decl)))
+    {
+      darwin_emit_objc_zeroed (fp, decl, name, size, DECL_ALIGN (decl), meta);
+      return;
+    }
+
   /* We shouldn't be messing with this if the decl has a section name.  */
   gcc_assert (DECL_SECTION_NAME (decl) == NULL);
 
Index: gcc/config/darwin-sections.def
===================================================================
--- gcc/config/darwin-sections.def	(revision 170111)
+++ gcc/config/darwin-sections.def	(working copy)
@@ -94,7 +94,7 @@ DEF_SECTION (mod_term_section, 0, ".mod_term_func"
 DEF_SECTION (constructor_section, 0, ".constructor", 0)
 DEF_SECTION (destructor_section, 0, ".destructor", 0)
 
-/* Objective-C (V1) sections.  */
+/* Objective-C ABI=0 (Original version) sections.  */
 DEF_SECTION (objc_class_section, 0, ".objc_class", 1)
 DEF_SECTION (objc_meta_class_section, 0, ".objc_meta_class", 1)
 DEF_SECTION (objc_category_section, 0, ".objc_category", 1)
@@ -112,7 +112,7 @@ DEF_SECTION (objc_module_info_section, 0, ".objc_m
 DEF_SECTION (objc_protocol_section, 0, ".objc_protocol", 1)
 DEF_SECTION (objc_string_object_section, 0, ".objc_string_object", 1)
 DEF_SECTION (objc_constant_string_object_section, 0,
-	     ".section __OBJC, __cstring_object, regular, no_dead_strip", 1)
+	     ".section __OBJC, __cstring_object, regular, no_dead_strip", 0)
 
 /* Fix-and-Continue image marker.  */
 DEF_SECTION (objc_image_info_section, 0,
@@ -156,3 +156,40 @@ DEF_SECTION (darwin_exception_section, SECTION_NO_
 DEF_SECTION (darwin_eh_frame_section, SECTION_NO_ANCHOR,
 	     ".section " EH_FRAME_SECTION_NAME ",__eh_frame"
 	     EH_FRAME_SECTION_ATTR, 0)
+
+/* Sections for ObjC ABI=1 (ObjC 'V1' extensions) */
+DEF_SECTION (objc1_class_ext_section, 0,
+	    ".section __OBJC, __class_ext, regular, no_dead_strip", 1)
+DEF_SECTION (objc1_prop_list_section, 0,
+	    ".section __OBJC, __property, regular, no_dead_strip", 1)
+DEF_SECTION (objc1_protocol_ext_section, 0,
+	    ".section __OBJC, __protocol_ext, regular, no_dead_strip", 1)
+
+/* Sections for ObjC ABI=2 (m64).  */
+DEF_SECTION (objc2_message_refs_section, 0,
+	     ".section __DATA, __objc_msgrefs, regular, no_dead_strip", 1)
+DEF_SECTION (objc2_classdefs_section, 0, ".section __DATA, __objc_data", 1)
+DEF_SECTION (objc2_metadata_section, 0, ".section __DATA, __objc_const", 1)
+
+DEF_SECTION (objc2_classrefs_section, 0, 
+             ".section __DATA, __objc_classrefs, regular, no_dead_strip", 1)
+DEF_SECTION (objc2_classlist_section, 0,
+	     ".section __DATA, __objc_classlist, regular, no_dead_strip", 1)
+DEF_SECTION (objc2_categorylist_section, 0,
+	     ".section __DATA, __objc_catlist, regular, no_dead_strip", 1)
+DEF_SECTION (objc2_selector_refs_section, 0,
+	     ".section __DATA, __objc_selrefs, literal_pointers, no_dead_strip", 1)
+DEF_SECTION (objc2_nonlazy_class_section, 0,
+	     ".section __DATA, __objc_nlclslist, regular, no_dead_strip", 1)
+DEF_SECTION (objc2_nonlazy_category_section, 0,
+	     ".section __DATA, __objc_nlcatlist, regular, no_dead_strip", 1)
+DEF_SECTION (objc2_protocollist_section, 0,
+	     ".section __DATA, __objc_protolist, regular, no_dead_strip", 1)
+DEF_SECTION (objc2_protocolrefs_section, 0,
+	     ".section __DATA, __objc_protorefs, regular, no_dead_strip", 1)
+DEF_SECTION (objc2_super_classrefs_section, 0,
+	     ".section __DATA, __objc_superrefs, regular, no_dead_strip", 1)
+DEF_SECTION (objc2_image_info_section, 0,
+	     ".section __DATA, __objc_imageinfo, regular, no_dead_strip", 1)
+DEF_SECTION (objc2_constant_string_object_section, 0,
+	     ".section __DATA, __objc_stringobj, regular, no_dead_strip", 1)
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h	(revision 170111)
+++ gcc/config/darwin.h	(working copy)
@@ -140,6 +140,10 @@ extern GTY(()) int darwin_ms_struct;
   } while (0)
 
 #define SUBTARGET_C_COMMON_OVERRIDE_OPTIONS do {                        \
+  /* Unless set, force ABI=2 for NeXT and m64, 0 otherwise.  */		\
+  if (!global_options_set.x_flag_objc_abi)				\
+    global_options.x_flag_objc_abi					\
+	= (flag_next_runtime && TARGET_64BIT) ? 2 : 0;			\
   /* Sort out ObjC exceptions: If the runtime is NeXT we default to	\
      sjlj for m32 only.  */						\
   if (!global_options_set.x_flag_objc_sjlj_exceptions)			\
@@ -599,7 +603,7 @@ int darwin_label_is_anonymous_local_objc_name (con
 	 }								     \
        else if (xname[0] == '+' || xname[0] == '-')			     \
          fprintf (FILE, "\"%s\"", xname);				     \
-       else if (darwin_label_is_anonymous_local_objc_name (xname))				     \
+       else if (darwin_label_is_anonymous_local_objc_name (xname))	     \
          fprintf (FILE, "L%s", xname);					     \
        else if (!strncmp (xname, ".objc_class_name_", 17))		     \
 	 fprintf (FILE, "%s", xname);					     \

Comments

Joseph Myers Feb. 14, 2011, 6:22 p.m. UTC | #1
On Mon, 14 Feb 2011, IainS wrote:

> - which is to add two required flags to c-family/c.opt (for which I also need
> approval)

The c.opt change (note the ChangeLog entry has a "c.opts" typo) is OK if 
the options are also documented in invoke.texi.
Mike Stump Feb. 14, 2011, 11:55 p.m. UTC | #2
On Feb 14, 2011, at 5:16 AM, IainS wrote:
> Whilst we are in stage-4, I believe that Richard (G) indicated that wrong-code bugs were eligible for inclusion, even at this stage.

This work is Ok for the parts that I can approve.  The open question is check it in now, or later during stage1?  Since we're in a regression and doc phase, I think we need a RM to approve this for inclusion.  RMs?
Richard Biener Feb. 15, 2011, 10:10 a.m. UTC | #3
On Mon, 14 Feb 2011, Mike Stump wrote:

> On Feb 14, 2011, at 5:16 AM, IainS wrote:
> > Whilst we are in stage-4, I believe that Richard (G) indicated that wrong-code bugs were eligible for inclusion, even at this stage.
> 
> This work is Ok for the parts that I can approve.  The open question is check it in now, or later during stage1?  Since we're in a regression and doc phase, I think we need a RM to approve this for inclusion.  RMs?

Generally wrong-code fixes are ok.  Note that Objective-C is not release
critical, so we will not wait with a release in case you broke ObjC with
this patch and the release critical parts of the compiler are ready.
Thus, for non-release critical patches that fall in the regression / 
wrong-code area the respective maintainers should decide whether the
advantage of including the patch outweights the risks.

Richard.
diff mbox

Patch

Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt	(revision 170111)
+++ gcc/c-family/c.opt	(working copy)
@@ -853,6 +853,10 @@  fnothrow-opt
 C++ ObjC++ Optimization Var(flag_nothrow_opt)
 Treat a throw() exception specification as noexcept to improve code size
 
+fobjc-abi-version=
+ObjC ObjC++ Joined Report RejectNegative UInteger Var(flag_objc_abi)
+Specify which ABI to use in ObjC* code and meta-data generation.
+
 ; Generate special '- .cxx_construct' and '- .cxx_destruct' methods
 ; to initialize any non-POD ivars in Objective-C++ classes.
 fobjc-call-cxx-cdtors
@@ -873,6 +877,10 @@  fobjc-gc
 ObjC ObjC++ Var(flag_objc_gc)
 Enable garbage collection (GC) in Objective-C/Objective-C++ programs
 
+fobjc-nilcheck
+ObjC ObjC++ Var(flag_objc_nilcheck,1)
+Check for nil receivers when classes are lazily linked.
+
 ; Nonzero means that we generate NeXT setjmp based exceptions.
 fobjc-sjlj-exceptions
 ObjC ObjC++ Var(flag_objc_sjlj_exceptions) Init(-1)