[binutils-gdb] Only parse attributes in ELF sections with the SHT_GNU_ATTRIBUTES type if the OS is not Solaris. Se

Nick Clifton nickc@sourceware.org
Tue Jul 15 10:16:13 GMT 2025


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

commit 4cd91af023aff01d78c7b5d0786403683592902a
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Tue Jul 15 11:15:46 2025 +0100

    Only parse attributes in ELF sections with the SHT_GNU_ATTRIBUTES type if the OS is not Solaris.  Set the is_solaris flag for Sparc solaris
    
    PR 33153

Diff:
---
 bfd/elf.c         | 6 ++++--
 bfd/elf32-sparc.c | 5 ++++-
 bfd/elf64-sparc.c | 7 +++++--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/bfd/elf.c b/bfd/elf.c
index ba0e313524d..dfa04c9268d 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2882,8 +2882,10 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
 
     default:
       /* Possibly an attributes section.  */
-      if (hdr->sh_type == SHT_GNU_ATTRIBUTES
-	  || hdr->sh_type == bed->obj_attrs_section_type)
+      if (get_elf_backend_data (abfd)->target_os != is_solaris
+	  /* PR 33153: Solaris defines SHT_SUNW_cap which collides with SHT_GNU_ATTRIBUTES.  */
+	  && (hdr->sh_type == SHT_GNU_ATTRIBUTES
+	      || hdr->sh_type == bed->obj_attrs_section_type))
 	{
 	  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
 	    goto fail;
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index e5efbcca62d..0bb86f1c4b5 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -281,7 +281,10 @@ elf32_sparc_reloc_type_class (const struct bfd_link_info *info,
 #undef	TARGET_BIG_NAME
 #define	TARGET_BIG_NAME				"elf32-sparc-sol2"
 
-#undef elf32_bed
+#undef  ELF_TARGET_OS
+#define ELF_TARGET_OS				is_solaris
+
+#undef  elf32_bed
 #define elf32_bed				elf32_sparc_sol2_bed
 
 /* The 32-bit static TLS arena size is rounded to the nearest 8-byte
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index c45dee81af6..9f8cbd914f9 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -1008,16 +1008,19 @@ const struct elf_size_info elf64_sparc_size_info =
 #undef	TARGET_BIG_NAME
 #define	TARGET_BIG_NAME				"elf64-sparc-sol2"
 
+#undef  ELF_TARGET_OS
+#define ELF_TARGET_OS				is_solaris
+
 /* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE
    objects won't be recognized.  */
 #undef	ELF_OSABI
 
-#undef elf64_bed
+#undef  elf64_bed
 #define elf64_bed				elf64_sparc_sol2_bed
 
 /* The 64-bit static TLS arena size is rounded to the nearest 16-byte
    boundary.  */
-#undef elf_backend_static_tls_alignment
+#undef  elf_backend_static_tls_alignment
 #define elf_backend_static_tls_alignment	16
 
 #undef  elf_backend_strtab_flags


More information about the Binutils-cvs mailing list