From 1311fe91acdc96ab224c54e56f5e5ff777ddee0c Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@sandoe.co.uk>
Date: Sun, 4 Oct 2020 12:50:15 +0100
Subject: [PATCH] Darwin, Arm64 : Make more Objective-C metadata
 linker-visible.

It seems that the aarch64 port for clang exposes more of the meta-data entries
to ld64 (than for x86_64).  However, the linker seems to require this for arm64
(so that the atom checks are apparently different).  Anyway - we just punt on
hidding any of the metadata lables for now.

(cherry picked from commit a0b1e3944b152ff9e4e29262b097c80c16e4cf10)
Signed-off-by: Kirill A. Korinsky <kirill@korins.ky>
---
 gcc/config/darwin.h | 55 +++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git gcc/config/darwin.h gcc/config/darwin.h
index 1a1133db7de..c79d2e12ed1 100644
--- gcc/config/darwin.h
+++ gcc/config/darwin.h
@@ -838,34 +838,35 @@ int darwin_label_is_anonymous_local_objc_name (const char *name);
 
 #undef	ASM_OUTPUT_LABELREF
 #define ASM_OUTPUT_LABELREF(FILE,NAME)					     \
-  do {									     \
-       const char *xname = (NAME);					     \
-       if (! strcmp (xname, MACHOPIC_FUNCTION_BASE_NAME))		     \
-         machopic_output_function_base_name(FILE);                           \
-       else if (xname[0] == '&' || xname[0] == '*')			     \
-         {								     \
-           int len = strlen (xname);					     \
-	   if (len > 6 && !strcmp ("$stub", xname + len - 5))		     \
-	     machopic_validate_stub_or_non_lazy_ptr (xname);		     \
-	   else if (len > 7 && !strcmp ("$stub\"", xname + len - 6))	     \
-	     machopic_validate_stub_or_non_lazy_ptr (xname);		     \
-	   else if (len > 14 && !strcmp ("$non_lazy_ptr", xname + len - 13)) \
-	     machopic_validate_stub_or_non_lazy_ptr (xname);		     \
-	   else if (len > 15 && !strcmp ("$non_lazy_ptr\"", xname + len - 14)) \
-	     machopic_validate_stub_or_non_lazy_ptr (xname);		     \
-	   if (xname[1] != '"' && name_needs_quotes (&xname[1]))	     \
-	     fprintf (FILE, "\"%s\"", &xname[1]);			     \
-	   else								     \
-	     fputs (&xname[1], FILE); 					     \
-	 }								     \
-       else if (xname[0] == '+' || xname[0] == '-')			     \
-         fprintf (FILE, "\"%s\"", xname);				     \
-       else if (darwin_label_is_anonymous_local_objc_name (xname))	     \
-         fprintf (FILE, "L%s", xname);					     \
-       else if (xname[0] != '"' && name_needs_quotes (xname))		     \
+  do									     \
+    {									     \
+      const char *xname = (NAME);					     \
+      if (! strcmp (xname, MACHOPIC_FUNCTION_BASE_NAME))		     \
+	machopic_output_function_base_name(FILE);			     \
+      else if (xname[0] == '&' || xname[0] == '*')			     \
+	{								     \
+	  int len = strlen (xname);					     \
+	  if (len > 6 && !strcmp ("$stub", xname + len - 5))		     \
+	    machopic_validate_stub_or_non_lazy_ptr (xname);		     \
+	  else if (len > 7 && !strcmp ("$stub\"", xname + len - 6))	     \
+	    machopic_validate_stub_or_non_lazy_ptr (xname);		     \
+	  else if (len > 14 && !strcmp ("$non_lazy_ptr", xname + len - 13))  \
+	    machopic_validate_stub_or_non_lazy_ptr (xname);		     \
+	  else if (len > 15 && !strcmp ("$non_lazy_ptr\"", xname + len - 14))\
+	    machopic_validate_stub_or_non_lazy_ptr (xname);		     \
+	  if (xname[1] != '"' && name_needs_quotes (&xname[1]))		     \
+	    fprintf (FILE, "\"%s\"", &xname[1]);			     \
+	  else								     \
+	    fputs (&xname[1], FILE); 					     \
+	}								     \
+      else if (xname[0] == '+' || xname[0] == '-')			     \
+	fprintf (FILE, "\"%s\"", xname);				     \
+      else if (darwin_label_is_anonymous_local_objc_name (xname))	     \
+	fprintf (FILE, "l%s", xname);					     \
+      else if (xname[0] != '"' && name_needs_quotes (xname))		     \
 	 asm_fprintf (FILE, "\"%U%s\"", xname);				     \
-       else								     \
-         asm_fprintf (FILE, "%U%s", xname);				     \
+      else								     \
+	asm_fprintf (FILE, "%U%s", xname);				     \
   } while (0)
 
 /* Output before executable code.  */
-- 
2.42.1

