From: Rainer Orth Date: Tue, 15 Jul 2025 10:13:18 +0000 (+0100) Subject: Only parse attributes in ELF sections with the SHT_GNU_ATTRIBUTES type if the OS... X-Git-Tag: binutils-2_45~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45c3d20e7a4bf611a68a5b0dfe1643d912fdf475;p=thirdparty%2Fbinutils-gdb.git 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 architectures PR 33153 --- 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..5d0e4439bce 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -281,6 +281,9 @@ elf32_sparc_reloc_type_class (const struct bfd_link_info *info, #undef TARGET_BIG_NAME #define TARGET_BIG_NAME "elf32-sparc-sol2" +#undef ELF_TARGET_OS +#define ELF_TARGET_OS is_solaris + #undef elf32_bed #define elf32_bed elf32_sparc_sol2_bed diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index c45dee81af6..afd061ffb8f 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -1008,6 +1008,9 @@ 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