[binutils-gdb] Make Solaris global ABI syms STT_OBJECT and STV_PROTECTED

Alan Modra amodra@sourceware.org
Sat Feb 21 00:28:31 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3049829f1e6dd849e5d3ca71d633990f8d799ae6

commit 3049829f1e6dd849e5d3ca71d633990f8d799ae6
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Feb 21 10:56:49 2026 +1030

    Make Solaris global ABI syms STT_OBJECT and STV_PROTECTED
    
            PR 33177
            * emultempl/solaris2.em (elf_solaris_before_allocation): Make
            globals defined here STV_PROTECTED and STT_OBJECT.  Use
            elf_backend_hide_symbol rather that just setting forced_local
            for local ABI syms.

Diff:
---
 ld/emultempl/solaris2.em | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/ld/emultempl/solaris2.em b/ld/emultempl/solaris2.em
index 0b0be93d4b9..3a20d7a16a6 100644
--- a/ld/emultempl/solaris2.em
+++ b/ld/emultempl/solaris2.em
@@ -101,7 +101,9 @@ elf_solaris2_before_allocation (void)
 
 	      /* Undo the hiding done by _bfd_elf_define_linkage_sym.  */
 	      h->forced_local = 0;
-	      h->other &= ~STV_HIDDEN;
+	      h->type = STT_OBJECT;
+	      if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
+		h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_PROTECTED;
 
 	      /* Emit it into the .dynamic section, too.  */
 	      bfd_elf_link_record_dynamic_symbol (&link_info, h);
@@ -110,6 +112,7 @@ elf_solaris2_before_allocation (void)
 	  for (sym = local_syms; *sym != NULL; sym++)
 	    {
 	      struct elf_link_hash_entry *h;
+	      elf_backend_data *bed;
 
 	      /* Lookup symbol.  */
 	      h = elf_link_hash_lookup (elf_hash_table (&link_info), *sym,
@@ -118,7 +121,9 @@ elf_solaris2_before_allocation (void)
 		continue;
 
 	      /* Turn it local.  */
-	      h->forced_local = 1;
+	      bed = get_elf_backend_data (link_info.output_bfd);
+	      bed->elf_backend_hide_symbol (&link_info, h, true);
+
 	      /* Type should be STT_OBJECT, not STT_NOTYPE.  */
 	      h->type = STT_OBJECT;
 	    }


More information about the Binutils-cvs mailing list