]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aix: ensure reference to __tls_get_addr is in text section.
authorClément Chigot <clement.chigot@atos.net>
Thu, 14 Oct 2021 07:03:13 +0000 (09:03 +0200)
committerClément Chigot <clement.chigot@atos.net>
Tue, 19 Oct 2021 12:42:45 +0000 (14:42 +0200)
The garbage collector of AIX linker might remove the reference to
__tls_get_addr if it's added inside an unused csect, which can be
the case of .data with very simple programs.

gcc/ChangeLog:
2021-10-19  Clément Chigot  <clement.chigot@atos.net>

* config/rs6000/rs6000.c (rs6000_xcoff_file_end): Move
__tls_get_addr reference to .text csect.

gcc/config/rs6000/rs6000.c

index 68111c3fe6ad532507f34fa6e8de47bdb413b103..bac959f4ef4e618eae7d3d684388c139c59c6543 100644 (file)
@@ -21626,17 +21626,17 @@ static void
 rs6000_xcoff_file_end (void)
 {
   switch_to_section (text_section);
+  if (xcoff_tls_exec_model_detected)
+    {
+      /* Add a .ref to __tls_get_addr to force libpthread dependency.  */
+      fputs ("\t.extern __tls_get_addr\n\t.ref __tls_get_addr\n", asm_out_file);
+    }
   fputs ("_section_.text:\n", asm_out_file);
   switch_to_section (data_section);
   fputs (TARGET_32BIT
         ? "\t.long _section_.text\n" : "\t.llong _section_.text\n",
         asm_out_file);
 
-  if (xcoff_tls_exec_model_detected)
-    {
-      /* Add a .ref to __tls_get_addr to force libpthread dependency.  */
-      fputs ("\t.extern __tls_get_addr\n\t.ref __tls_get_addr\n", asm_out_file);
-    }
 }
 
 struct declare_alias_data