[pushed] Darwin: Amend linker-visibility of strings [PR126723].

Iain Sandoe <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
Tested on x86_64/aarch64 darwin, pushed to trunk, thanks
Iain

--- 8< ---

There seems to be quite some variability in the cases that clang makes
string constant labels linker-visible, however the most conservative
case is "all of them" which appears to be the strategy for aarch64.
We dadopt this here, although there is some slight loss of efficiency
for x86_64.

	PR target/126723

gcc/ChangeLog:

	* config/darwin.cc (darwin_encode_section_info): Make all
	string constant labels linker-visible.  Likewise const
	section anchors.

Signed-off-by: Iain Sandoe <[email protected]>
---
 gcc/config/darwin.cc | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index 5812d61765b..2f823298963 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -1314,18 +1314,15 @@ darwin_encode_section_info (tree decl, rtx rtl, int first)
       gcc_checking_assert (strncmp ("*lC", name, 3) == 0);
 
       char *buf;
+      /* Some versions of clang make all string constants linker-visible,
+	 independent of their final section, follow this.  */
       if (is_str)
-	{
-	  bool for_asan = (flag_sanitize & SANITIZE_ADDRESS)
-			   && asan_protect_global (const_cast<tree> (decl));
-	  /* When we are generating code for sanitized strings, the string
-	     internal symbols are made visible in the object.  */
-	  buf = xasprintf ("*%c.str.%s", for_asan ? 'l' : 'L', &name[3]);
-	}
+	buf = xasprintf ("*l.str.%s", &name[3]);
       else
 	/* Lets identify anchored constants with a different prefix, for the
-	   sake of inspection only.  */
-	buf = xasprintf ("*LaC%s", &name[3]);
+	   sake of inspection only.  Assume these need to co-exist with weak
+	   constant defs and so need to be linker-visible.  */
+	buf = xasprintf ("*laC%s", &name[3]);
       if (sym_decl)
 	DECL_NAME (sym_decl) = get_identifier (buf);
       XSTR (sym_ref, 0) = ggc_strdup (buf);
-- 
2.50.1 (Apple Git-155)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.