]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Only parse attributes in ELF sections with the SHT_GNU_ATTRIBUTES type if the OS...
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 15 Jul 2025 10:15:46 +0000 (11:15 +0100)
committerNick Clifton <nickc@redhat.com>
Tue, 15 Jul 2025 10:15:46 +0000 (11:15 +0100)
PR 33153

bfd/elf.c
bfd/elf32-sparc.c
bfd/elf64-sparc.c

index ba0e313524da31a8359f0f8718c6a5da6ec89dc6..dfa04c9268d7353354ad0f572cef264063ea0461 100644 (file)
--- 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;
index e5efbcca62d976592016229becba6e328c8a921a..0bb86f1c4b5aaf965ef677bea36e32c1e49fb1b2 100644 (file)
@@ -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
index c45dee81af6afbbec26839d97e0dfeb6e46d1199..9f8cbd914f90e8b772e24a64d4b6b7fc1ceb68d7 100644 (file)
@@ -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