public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] aix: ensure reference to __tls_get_addr is in text section.
@ 2021-10-14  7:06 CHIGOT, CLEMENT
  2021-10-14 13:42 ` David Edelsohn
  0 siblings, 1 reply; 5+ messages in thread
From: CHIGOT, CLEMENT @ 2021-10-14  7:06 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Edelsohn

[-- Attachment #1: Type: text/plain, Size: 205 bytes --]

The garbage collector of AIX linker might remove the reference to
__tls_get_addr if it's added inside an unused csect.


Clément Chigot
ATOS Bull SAS
1 rue de Provence - 38432 Échirolles - France


[-- Attachment #2: 0001-aix-ensure-reference-to-__tls_get_addr-is-in-text-se.patch --]
[-- Type: application/octet-stream, Size: 934 bytes --]

From 17832ad26ffd061f5304acf03ca4f34646421e93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Thu, 14 Oct 2021 09:03:13 +0200
Subject: [PATCH] aix: ensure reference to __tls_get_addr is in text section.

The garbage collector of AIX linker might remove the reference to
__tls_get_addr if it's added inside an unused csect.
---
 gcc/config/rs6000/rs6000.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index acba4d9f26c..62a98e7255c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -21636,6 +21636,7 @@ rs6000_xcoff_file_end (void)
   if (xcoff_tls_exec_model_detected)
     {
       /* Add a .ref to __tls_get_addr to force libpthread dependency.  */
+      switch_to_section (text_section);
       fputs ("\t.extern __tls_get_addr\n\t.ref __tls_get_addr\n", asm_out_file);
     }
 }
-- 
2.33.0


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH] aix: ensure reference to __tls_get_addr is in text section.
@ 2021-10-19 12:40 CHIGOT, CLEMENT
  0 siblings, 0 replies; 5+ messages in thread
From: CHIGOT, CLEMENT @ 2021-10-19 12:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Edelsohn

[-- Attachment #1: Type: text/plain, Size: 409 bytes --]

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.

Approved offline by David Edelson.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-aix-ensure-reference-to-__tls_get_addr-is-in-text-se.patch --]
[-- Type: text/x-patch; name="0001-aix-ensure-reference-to-__tls_get_addr-is-in-text-se.patch", Size: 1720 bytes --]

From 52e9e4554d8dba9f9c9c56267789fc1d08b1de98 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Thu, 14 Oct 2021 09:03:13 +0200
Subject: [PATCH] aix: ensure reference to __tls_get_addr is in text section.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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 | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 68111c3fe6a..bac959f4ef4 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -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
-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-19 12:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14  7:06 [PATCH] aix: ensure reference to __tls_get_addr is in text section CHIGOT, CLEMENT
2021-10-14 13:42 ` David Edelsohn
2021-10-14 14:10   ` CHIGOT, CLEMENT
2021-10-14 14:37     ` David Edelsohn
2021-10-19 12:40 CHIGOT, CLEMENT

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).