These sections have SHF_STRINGS in sh_flags on Solaris. Commit
84865015459b in part implemented this variation by an elf_backend_data
field used to set the flags, but that only works of course if one of
the solaris targets is used. Which in some ways is fair enough. If
you want solaris support then it is reasonable to require the solaris
targets to be compiled in. However if they are not the default, other
ELF targets may be used even when the solaris targets are compiled in,
because many ELF targets allow any ELFOSABI object to match. (Which
is arguably a bug.)
So instead of the current scheme this patch implements the solaris
specific sh_flags in _bfd_elf_final_write_processing. That way either
a solaris target being used, or ELFOSABI_SOLARIS in the object will
get the correct sh_flags.
PR 19938
* elf-bfd.h (struct elf_backend_data): Delete elf_strtab_flags.
* elf.c (_bfd_elf_final_write_processing): Handle solaris
peculiarities here.
(_bfd_elf_compute_section_file_positions): Leave shstrtab sh_flags
zero, and don't re-zero other fields.
(swap_out_syms): Similarly for sym strtab.
* elflink.c (_bfd_elf_final_link): Likewise.
* elf32-i386.c (elf_backend_strtab_flags): Don't define.
* elf32-sparc.c: Likewise.
* elf64-sparc.c: Likewise.
* elf64-x86-64.c: Likewise.
* elfxx-target.h: Likewise.
/* Alignment for the PT_GNU_STACK segment. */
unsigned stack_align;
- /* Flag bits to assign to a section of type SHT_STRTAB. */
- unsigned long elf_strtab_flags;
-
/* This is TRUE if the linker should act like collect and gather
global constructors and destructors by name. This is TRUE for
MIPS ELF because the Irix 5 tools can not handle the .init
shstrtab_hdr = &elf_tdata (abfd)->shstrtab_hdr;
/* sh_name was set in init_file_header. */
shstrtab_hdr->sh_type = SHT_STRTAB;
- shstrtab_hdr->sh_flags = bed->elf_strtab_flags;
- shstrtab_hdr->sh_addr = 0;
+ /* sh_flags, sh_addr, sh_entsize, sh_link, sh_info are all zeroed
+ when tdata is allocated. */
/* sh_size is set in _bfd_elf_assign_file_positions_for_non_load. */
- shstrtab_hdr->sh_entsize = 0;
- shstrtab_hdr->sh_link = 0;
- shstrtab_hdr->sh_info = 0;
/* sh_offset is set in _bfd_elf_assign_file_positions_for_non_load. */
shstrtab_hdr->sh_addralign = 1;
*sttp = stt;
symstrtab_hdr->sh_size = _bfd_elf_strtab_size (stt);
symstrtab_hdr->sh_type = SHT_STRTAB;
- symstrtab_hdr->sh_flags = bed->elf_strtab_flags;
- symstrtab_hdr->sh_addr = 0;
- symstrtab_hdr->sh_entsize = 0;
- symstrtab_hdr->sh_link = 0;
- symstrtab_hdr->sh_info = 0;
symstrtab_hdr->sh_addralign = 1;
return true;
bool
_bfd_elf_final_write_processing (bfd *abfd)
{
- Elf_Internal_Ehdr *i_ehdrp; /* ELF file header, internal form. */
-
- i_ehdrp = elf_elfheader (abfd);
+ Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
+ const struct elf_backend_data *bed = get_elf_backend_data (abfd);
if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE)
- i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi;
+ i_ehdrp->e_ident[EI_OSABI] = bed->elf_osabi;
+
+ if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_SOLARIS
+ || bed->target_os == is_solaris)
+ {
+ elf_tdata (abfd)->strtab_hdr.sh_flags = SHF_STRINGS;
+ elf_tdata (abfd)->shstrtab_hdr.sh_flags = SHF_STRINGS;
+ }
/* Set the osabi field to ELFOSABI_GNU if the binary contains
SHF_GNU_MBIND or SHF_GNU_RETAIN sections or symbols of STT_GNU_IFUNC type
#undef elf_backend_want_plt_sym
#define elf_backend_want_plt_sym 1
-#undef elf_backend_strtab_flags
-#define elf_backend_strtab_flags SHF_STRINGS
-
#include "elf32-target.h"
/* Intel MCU support. */
#undef elf_backend_want_plt_sym
#define elf_backend_want_plt_sym 0
-#undef elf_backend_strtab_flags
-
#include "elf32-target.h"
/* Restore defaults. */
#undef elf_backend_static_tls_alignment
#define elf_backend_static_tls_alignment 8
-#undef elf_backend_strtab_flags
-#define elf_backend_strtab_flags SHF_STRINGS
-
static bool
elf32_sparc_copy_solaris_special_section_fields (const bfd *ibfd ATTRIBUTE_UNUSED,
bfd *obfd ATTRIBUTE_UNUSED,
#define elf_backend_final_write_processing \
elf32_sparc_vxworks_final_write_processing
#undef elf_backend_static_tls_alignment
-#undef elf_backend_strtab_flags
#undef elf_backend_copy_special_section_fields
#undef elf32_bed
#undef elf_backend_static_tls_alignment
#define elf_backend_static_tls_alignment 16
-#undef elf_backend_strtab_flags
-#define elf_backend_strtab_flags SHF_STRINGS
-
static bool
elf64_sparc_copy_solaris_special_section_fields (const bfd *ibfd ATTRIBUTE_UNUSED,
bfd *obfd ATTRIBUTE_UNUSED,
#include "elf64-target.h"
-#undef elf_backend_strtab_flags
#undef elf_backend_copy_special_section_fields
#undef elf_backend_want_plt_sym
#define elf_backend_want_plt_sym 1
-#undef elf_backend_strtab_flags
-#define elf_backend_strtab_flags SHF_STRINGS
-
#include "elf64-target.h"
/* Restore defaults. */
#undef elf_backend_static_tls_alignment
#undef elf_backend_want_plt_sym
#define elf_backend_want_plt_sym 0
-#undef elf_backend_strtab_flags
/* 32bit x86-64 support. */
}
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
- /* sh_name was set in prep_headers. */
symstrtab_hdr->sh_type = SHT_STRTAB;
- symstrtab_hdr->sh_flags = bed->elf_strtab_flags;
- symstrtab_hdr->sh_addr = 0;
symstrtab_hdr->sh_size = _bfd_elf_strtab_size (flinfo.symstrtab);
- symstrtab_hdr->sh_entsize = 0;
- symstrtab_hdr->sh_link = 0;
- symstrtab_hdr->sh_info = 0;
- /* sh_offset is set just below. */
symstrtab_hdr->sh_addralign = 1;
off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr,
#ifndef elf_backend_stack_align
#define elf_backend_stack_align 16
#endif
-#ifndef elf_backend_strtab_flags
-#define elf_backend_strtab_flags 0
-#endif
#ifndef elf_backend_use_mmap
#define elf_backend_use_mmap false
#endif
elf_backend_write_secondary_reloc_section,
elf_backend_static_tls_alignment,
elf_backend_stack_align,
- elf_backend_strtab_flags,
elf_backend_collect,
elf_backend_type_change_ok,
elf_backend_may_use_rel_p,