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
This commit is contained in:
Rainer Orth
2025-07-15 11:13:18 +01:00
committed by Nick Clifton
parent e35b2e9572
commit 45c3d20e7a
3 changed files with 10 additions and 2 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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