[pushed] Darwin: Fix a typo in Objective-C meta-data.

Message ID 20240118142132.24592-1-iain@sandoe.co.uk
State Unresolved
Headers
Series [pushed] Darwin: Fix a typo in Objective-C meta-data. |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Iain Sandoe Jan. 18, 2024, 2:21 p.m. UTC
  Tested on i686, powerpc, x86_64 Darwin, x86_64 Linux, pushed to trunk,
thanks,
Iain

--- 8< ---

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>
---
 gcc/config/darwin.cc | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index b15f3b1a1d9..7f43718820b 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -1638,7 +1638,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;
@@ -1782,7 +1782,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
@@ -1804,6 +1804,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;
     }