]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Darwin: Fix a typo in Objective-C meta-data.
authorIain Sandoe <iain@sandoe.co.uk>
Mon, 8 Jan 2024 16:17:04 +0000 (16:17 +0000)
committerIain Sandoe <iain@sandoe.co.uk>
Sun, 31 Mar 2024 11:26:59 +0000 (12:26 +0100)
We have a typo in the metadata for assigning NSStrings to a specific
section for the V1 (32b) ABI.  When that is fixed we should never see
the case where the section needs to be deduced from the properties of
the DECLs.

gcc/ChangeLog:

* config/darwin.cc (darwin_objc1_section): Use the correct
meta-data version for constant strings.
(machopic_select_section): Assert if we fail to handle CFString
sections as Obejctive-C meta-data or drectly.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 8d26636f0da31e6c17b57ced52bfc61a45f23cee)

gcc/config/darwin.cc

index d23bfcca18c6f0f169c90586453fe99652404438..5431b2721c9d5119e70b08a1bb0656375db5636d 100644 (file)
@@ -1586,7 +1586,7 @@ darwin_objc1_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base)
   else if (startswith (p, "V1_CEXT"))
     return darwin_sections[objc1_class_ext_section];
 
-  else if (startswith (p, "V2_CSTR"))
+  else if (startswith (p, "V1_CSTR"))
     return darwin_sections[objc_constant_string_object_section];
 
   return base;
@@ -1730,7 +1730,7 @@ machopic_select_section (tree decl,
        return base_section; /* GNU runtime is happy with it all in one pot.  */
     }
 
-  /* b) Constant string objects.  */
+  /* b) Constructors for constant NSstring [but not CFString] objects.  */
   if (TREE_CODE (decl) == CONSTRUCTOR
       && TREE_TYPE (decl)
       && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
@@ -1752,6 +1752,12 @@ machopic_select_section (tree decl,
          else
            return darwin_sections[objc_string_object_section];
        }
+      else if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_CFString"))
+       {
+         /* We should have handled __anon_cfstrings above.  */
+         gcc_checking_assert (0);
+         return darwin_sections[cfstring_constant_object_section];
+       }
       else
        return base_section;
     }