--- ./gcc/config/rs6000/rs6000.c_orig	2022-10-31 12:19:17 +0000
+++ ./gcc/config/rs6000/rs6000.c	2022-12-09 06:04:12 +0000
@@ -21108,14 +21108,14 @@
 #if HAVE_AS_TLS
       if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl))
 	{
-	  if (bss_initializer_p (decl))
+      if (TREE_PUBLIC (decl))
+         return tls_data_section;
+	  else if (bss_initializer_p (decl))
 	    {
 	      /* Convert to COMMON to emit in BSS.  */
 	      DECL_COMMON (decl) = 1;
 	      return tls_comm_section;
 	    }
-	  else if (TREE_PUBLIC (decl))
-	    return tls_data_section;
 	  else
 	    return tls_private_data_section;
 	}
--- ./gcc/config/rs6000/xcoff.h_orig	2022-12-09 07:45:59 +0000
+++ ./gcc/config/rs6000/xcoff.h	2022-12-09 08:09:13 +0000
@@ -256,10 +256,10 @@
 
 #ifdef HAVE_AS_TLS
 #define ASM_OUTPUT_TLS_COMMON(FILE, DECL, NAME, SIZE)	\
-  do { fputs (COMMON_ASM_OP, (FILE));			\
-       RS6000_OUTPUT_BASENAME ((FILE), (NAME));		\
-       fprintf ((FILE), "[UL]," HOST_WIDE_INT_PRINT_UNSIGNED"\n", \
-       (SIZE));						\
+  do { fputs (LOCAL_COMMON_ASM_OP, (FILE));			\
+      fprintf ((FILE), "%s," HOST_WIDE_INT_PRINT_UNSIGNED",%s[UL],3\n", \
+               (*targetm.strip_name_encoding) (NAME), (SIZE),  \
+               (*targetm.strip_name_encoding) (NAME));  \
   } while (0)
 #endif
 
