]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/48094 (ld: warning: section has unexpectedly large size errors...
authorDominique d'Humieres <dominiq@lps.ens.fr>
Mon, 7 Apr 2014 06:40:18 +0000 (08:40 +0200)
committerDominique d'Humieres <dominiq@gcc.gnu.org>
Mon, 7 Apr 2014 06:40:18 +0000 (08:40 +0200)
2014-04-03  Dominique d'Humieres <dominiq@lps.ens.fr>

Backport from mainline
2013-09-14  Iain Sandoe <iains@gcc.gnu.org>

gcc:

PR target/48094
* config/darwin.c (darwin_objc2_section): Note if ObjC Metadata is seen.
(darwin_objc1_section): Likewise.
(darwin_file_end): Emit Image Info section when required.

gcc/c-family:

PR target/48094
* c.opt (fgnu-runtime, fnext-runtime, fobjc-abi-version,
fobjc-gc, freplace-objc-classes): Accept for LTO.

gcc/objc:

PR target/48094
* objc-next-runtime-abi-01.c (generate_objc_image_info): Remove.
(objc_generate_v1_next_metadata): Remove generation of ImageInfo.
* objc-next-runtime-abi-02.c (generate_v2_objc_image_info): Remove.
(objc_generate_v2_next_metadata): Remove generation of ImageInfo.

From-SVN: r209175

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c.opt
gcc/config/darwin.c
gcc/objc/ChangeLog
gcc/objc/objc-next-runtime-abi-01.c
gcc/objc/objc-next-runtime-abi-02.c

index 03ccd37aed41a839bd4c61469dfe4c87581e771f..902d7bbf5ab78db789a3d7d02c5abd4610eb9f65 100644 (file)
@@ -1,3 +1,14 @@
+2014-04-03  Dominique d'Humieres <dominiq@lps.ens.fr>    
+
+       Backport from mainline
+       2013-09-14  Iain Sandoe <iains@gcc.gnu.org>
+
+       PR target/48094
+       * config/darwin.c (darwin_objc2_section): Note if ObjC Metadata
+       is seen.
+       (darwin_objc1_section): Likewise.
+       (darwin_file_end): Emit Image Info section when required.
+
 2014-04-05  Alan Modra  <amodra@gmail.com>
 
        Apply from mainline
index a18bb5cbae00a699f2a3732104cd3d46ecd51cdd..496f20c162f0d054031adb16be0396678c05b303 100644 (file)
@@ -1,3 +1,12 @@
+2014-04-03  Dominique d'Humieres <dominiq@lps.ens.fr>    
+
+       Backport from mainline
+       2013-09-14  Iain Sandoe <iains@gcc.gnu.org>
+
+       PR target/48094
+       * c.opt (fgnu-runtime, fnext-runtime, fobjc-abi-version,
+       fobjc-gc, freplace-objc-classes): Accept for LTO.
+
 2014-03-06  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
index 10ae84dbb24b99a03d9810ec88251419dbfb72b5..4da80b0edf558d2ab7b2ce740d0fca4fc4901929 100644 (file)
@@ -933,7 +933,7 @@ C++ ObjC++ Var(flag_no_gnu_keywords, 0)
 Recognize GNU-defined keywords
 
 fgnu-runtime
-ObjC ObjC++ Report RejectNegative Var(flag_next_runtime,0) Init(NEXT_OBJC_RUNTIME)
+ObjC ObjC++ LTO Report RejectNegative Var(flag_next_runtime,0) Init(NEXT_OBJC_RUNTIME)
 Generate code for GNU runtime environment
 
 fgnu89-inline
@@ -1007,7 +1007,7 @@ fnew-abi
 C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
 
 fnext-runtime
-ObjC ObjC++ Report RejectNegative Var(flag_next_runtime)
+ObjC ObjC++ LTO Report RejectNegative Var(flag_next_runtime)
 Generate code for NeXT (Apple Mac OS X) runtime environment
 
 fnil-receivers
@@ -1025,7 +1025,7 @@ 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)
+ObjC ObjC++ LTO Joined Report RejectNegative UInteger Var(flag_objc_abi)
 Specify which ABI to use for Objective-C family code and meta-data generation.
 
 ; Generate special '- .cxx_construct' and '- .cxx_destruct' methods
@@ -1045,7 +1045,7 @@ ObjC ObjC++ Var(flag_objc_exceptions)
 Enable Objective-C exception and synchronization syntax
 
 fobjc-gc
-ObjC ObjC++ Var(flag_objc_gc)
+ObjC ObjC++ LTO Var(flag_objc_gc)
 Enable garbage collection (GC) in Objective-C/Objective-C++ programs
 
 fobjc-nilcheck
@@ -1105,7 +1105,7 @@ C++ ObjC++ Var(flag_pretty_templates) Init(1)
 -fno-pretty-templates Do not pretty-print template specializations as the template signature followed by the arguments
 
 freplace-objc-classes
-ObjC ObjC++ Var(flag_replace_objc_classes)
+ObjC ObjC++ LTO Var(flag_replace_objc_classes)
 Used in Fix-and-Continue mode to indicate that object files may be swapped in at runtime
 
 frepo
index e07fa4c83249d1d0fa80352d49050d89e156f124..d4700034699e65ca519f46915c0320899fcfafa4 100644 (file)
@@ -1329,6 +1329,9 @@ is_objc_metadata (tree decl)
   return NULL_TREE;
 }
 
+static int classes_seen;
+static int objc_metadata_seen;
+
 /* Return the section required for Objective C ABI 2 metadata.  */
 static section *
 darwin_objc2_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base)
@@ -1338,12 +1341,9 @@ darwin_objc2_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base)
   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.  */
+  gcc_checking_assert (flag_next_runtime == 1 && flag_objc_abi == 2);
 
-  flag_next_runtime = 1;
-  flag_objc_abi = 2;
+  objc_metadata_seen = 1;
 
   if (base == data_section)
     base = darwin_sections[objc2_metadata_section];
@@ -1366,7 +1366,10 @@ darwin_objc2_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base)
   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];
+    {
+      classes_seen = 1;
+      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))
@@ -1401,12 +1404,9 @@ darwin_objc1_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base)
   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;
+  gcc_checking_assert (flag_next_runtime == 1 && flag_objc_abi < 2);
+
+  objc_metadata_seen = 1;
 
   /* String sections first, cos there are lots of strings.  */
   if      (!strncmp (p, "V1_STRG", 7))
@@ -1419,7 +1419,10 @@ darwin_objc1_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base)
     return darwin_sections[objc_meth_var_types_section];
 
   else if (!strncmp (p, "V1_CLAS", 7))
-    return darwin_sections[objc_class_section];
+    {
+      classes_seen = 1;
+      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))
@@ -1603,8 +1606,6 @@ 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)
@@ -2845,6 +2846,33 @@ darwin_file_end (void)
     finalize_ctors ();
   if (!vec_safe_is_empty (dtors))
     finalize_dtors ();
+
+  /* If we are expecting to output NeXT ObjC meta-data, (and we actually see
+     some) then we output the fix-and-continue marker (Image Info).
+     This applies to Objective C, Objective C++ and LTO with either language
+     as part of the input.  */
+  if (flag_next_runtime && objc_metadata_seen)
+    {
+      unsigned int flags = 0;
+      if (flag_objc_abi >= 2)
+       {
+         flags = 16;
+         output_section_asm_op
+           (darwin_sections[objc2_image_info_section]->unnamed.data);
+       }
+      else
+       output_section_asm_op
+         (darwin_sections[objc_image_info_section]->unnamed.data);
+
+      ASM_OUTPUT_ALIGN (asm_out_file, 2);
+      fputs ("L_OBJC_ImageInfo:\n", asm_out_file);
+
+      flags |= (flag_replace_objc_classes && classes_seen) ? 1 : 0;
+      flags |= flag_objc_gc ? 2 : 0;
+
+      fprintf (asm_out_file, "\t.long\t0\n\t.long\t%u\n", flags);
+     }
+
   machopic_finish (asm_out_file);
   if (strcmp (lang_hooks.name, "GNU C++") == 0)
     {
index 508874cec3e440800e5167a9bfd90f0966e4bb45..4748e7d468b13fef2b452f67c7e8058bc66b2d22 100644 (file)
@@ -1,3 +1,14 @@
+2014-04-03  Dominique d'Humieres <dominiq@lps.ens.fr>    
+
+       Backport from mainline
+       2013-09-14  Iain Sandoe <iains@gcc.gnu.org>
+
+       PR target/48094
+       * objc-next-runtime-abi-01.c (generate_objc_image_info): Remove.
+       (objc_generate_v1_next_metadata): Remove generation of ImageInfo.
+       * objc-next-runtime-abi-02.c (generate_v2_objc_image_info): Remove.
+       (objc_generate_v2_next_metadata): Remove generation of ImageInfo.
+
 2013-10-16  Release Manager
 
        * GCC 4.8.2 released.
index a9845cfc0b8310fb44a408c801d0e1b39f047fb4..63af0e413b4373f76064e671cc99d1eb7c56d0ac 100644 (file)
@@ -2332,36 +2332,6 @@ generate_classref_translation_entry (tree chain)
   return;
 }
 
-
-/* The Fix-and-Continue functionality available in Mac OS X 10.3 and
-   later requires that ObjC translation units participating in F&C be
-   specially marked.  The following routine accomplishes this.  */
-
-/* static int _OBJC_IMAGE_INFO[2] = { 0, 1 }; */
-
-static void
-generate_objc_image_info (void)
-{
-  tree decl;
-  int flags
-    = ((flag_replace_objc_classes && imp_count ? 1 : 0)
-       | (flag_objc_gc ? 2 : 0));
-  vec<constructor_elt, va_gc> *v = NULL;
-  tree array_type;
-
-  array_type  = build_sized_array_type (integer_type_node, 2);
-
-  decl = start_var_decl (array_type, "_OBJC_ImageInfo");
-
-  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, integer_zero_node);
-  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (integer_type_node, flags));
-  /* The runtime wants this and refers to it in a manner hidden from the compiler.
-     So we must force the output.  */
-  DECL_PRESERVE_P (decl) = 1;
-  OBJCMETA (decl, objc_meta, meta_info);
-  finish_var_decl (decl, objc_build_constructor (TREE_TYPE (decl), v));
-}
-
 static void
 objc_generate_v1_next_metadata (void)
 {
@@ -2412,9 +2382,6 @@ objc_generate_v1_next_metadata (void)
   attr = build_tree_list (objc_meta, meta_modules);
   build_module_descriptor (vers, attr);
 
-  /* This conveys information on GC usage and zero-link.  */
-  generate_objc_image_info ();
-
   /* Dump the class references.  This forces the appropriate classes
      to be linked into the executable image, preserving unix archive
      semantics.  */
index 8ce0c22d39759bab41652da40f407b9d0463f7c8..97d1b295e78c0972f0eb153a4f7bdd597e9d8991 100644 (file)
@@ -3329,31 +3329,6 @@ build_v2_ivar_offset_ref_table (void)
     finish_var_decl (ref->decl, ref->offset);
 }
 
-/* static int _OBJC_IMAGE_INFO[2] = { 0, 16 | flags }; */
-
-static void
-generate_v2_objc_image_info (void)
-{
-  tree decl, array_type;
-  vec<constructor_elt, va_gc> *v = NULL;
-  int flags =
-       ((flag_replace_objc_classes && imp_count ? 1 : 0)
-         | (flag_objc_gc ? 2 : 0));
-
-  flags |= 16;
-
-  array_type  = build_sized_array_type (integer_type_node, 2);
-
-  decl = start_var_decl (array_type, "_OBJC_ImageInfo");
-
-  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, integer_zero_node);
-  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (integer_type_node, flags));
-  /* The Runtime wants this.  */
-  DECL_PRESERVE_P (decl) = 1;
-  OBJCMETA (decl, objc_meta, meta_info);
-  finish_var_decl (decl, objc_build_constructor (TREE_TYPE (decl), v));
-}
-
 static void
 objc_generate_v2_next_metadata (void)
 {
@@ -3405,9 +3380,6 @@ objc_generate_v2_next_metadata (void)
   build_v2_address_table (nonlazy_category_list, "_OBJC_NonLazyCategoryList$",
                          meta_label_nonlazy_categorylist);
 
-  /* This conveys information on GC usage and zero-link.  */
-  generate_v2_objc_image_info ();
-
   /* Generate catch objects for eh, if any are needed.  */
   build_v2_eh_catch_objects ();