ELF SEC_SMALL_DATA

For those ELF targets that have .sdata or .sbss sections, or similar
sections, arrange to mark the sections with the SEC_SMALL_DATA flag.
This fixes regressions in nm symbol type caused by removing .sdata
and .sbss from coff_section_type with commit 49d9fd42ac.

	* elf32-m32r.c (m32r_elf_section_flags): New function.
	(elf_backend_section_flags): Define.
	* elf32-nds32.c (nds32_elf_section_flags): New function.
	(elf_backend_section_flags): Define.
	* elf32-ppc.c (ppc_elf_section_from_shdr): Set SEC_SMALL_DATA for
	.sbss and .sdata sections.
	* elf32-v850.c (v850_elf_section_from_shdr): Set SEC_SMALL_DATA
	for SHF_V850_GPREL sections.
	* elf64-alpha.c (elf64_alpha_section_from_shdr): Delete outdated
	FIXME.
	* elf64-hppa.c (elf64_hppa_section_from_shdr): Set SEC_SMALL_DATA
	for SHF_PARISC_SHORT sections.
	* elf64-ppc.c (ppc64_elf_section_flags): New function.
	(elf_backend_section_flags): Define.
	* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Set SEC_SMALL_DATA
	for SHF_MIPS_GPREL sections.  Delete FIXME.
This commit is contained in:
Alan Modra 2020-03-02 10:16:39 +10:30
parent 8c803a2dd7
commit bf57746745
9 changed files with 85 additions and 16 deletions

View File

@ -1,3 +1,22 @@
2020-03-02 Alan Modra <amodra@gmail.com>
* elf32-m32r.c (m32r_elf_section_flags): New function.
(elf_backend_section_flags): Define.
* elf32-nds32.c (nds32_elf_section_flags): New function.
(elf_backend_section_flags): Define.
* elf32-ppc.c (ppc_elf_section_from_shdr): Set SEC_SMALL_DATA for
.sbss and .sdata sections.
* elf32-v850.c (v850_elf_section_from_shdr): Set SEC_SMALL_DATA
for SHF_V850_GPREL sections.
* elf64-alpha.c (elf64_alpha_section_from_shdr): Delete outdated
FIXME.
* elf64-hppa.c (elf64_hppa_section_from_shdr): Set SEC_SMALL_DATA
for SHF_PARISC_SHORT sections.
* elf64-ppc.c (ppc64_elf_section_flags): New function.
(elf_backend_section_flags): Define.
* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Set SEC_SMALL_DATA
for SHF_MIPS_GPREL sections. Delete FIXME.
2020-03-02 Alan Modra <amodra@gmail.com>
* elf-bfd.h (elf_backend_section_flags): Remove flagword* param.

View File

@ -3827,6 +3827,18 @@ static const struct bfd_elf_special_section m32r_elf_special_sections[] =
{ NULL, 0, 0, 0, 0 }
};
static bfd_boolean
m32r_elf_section_flags (const Elf_Internal_Shdr *hdr)
{
const char *name = hdr->bfd_section->name;
if (strncmp (name, ".sbss", 5) == 0
|| strncmp (name, ".sdata", 6) == 0)
hdr->bfd_section->flags |= SEC_SMALL_DATA;
return TRUE;
}
static enum elf_reloc_type_class
m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
const asection *rel_sec ATTRIBUTE_UNUSED,
@ -3897,6 +3909,7 @@ m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
#define bfd_elf32_bfd_set_private_flags m32r_elf_set_private_flags
#define bfd_elf32_bfd_print_private_bfd_data m32r_elf_print_private_bfd_data
#define elf_backend_special_sections m32r_elf_special_sections
#define elf_backend_section_flags m32r_elf_section_flags
#define elf_backend_linux_prpsinfo32_ugid16 TRUE

View File

@ -12593,6 +12593,18 @@ static struct bfd_elf_special_section const nds32_elf_special_sections[] =
{NULL, 0, 0, 0, 0}
};
static bfd_boolean
nds32_elf_section_flags (const Elf_Internal_Shdr *hdr)
{
const char *name = hdr->bfd_section->name;
if (strncmp (name, ".sbss", 5) == 0
|| strncmp (name, ".sdata", 6) == 0)
hdr->bfd_section->flags |= SEC_SMALL_DATA;
return TRUE;
}
static bfd_boolean
nds32_elf_output_arch_syms (bfd *output_bfd ATTRIBUTE_UNUSED,
struct bfd_link_info *info,
@ -14093,6 +14105,7 @@ nds32_elf_unify_tls_model (bfd *inbfd, asection *insec, bfd_byte *incontents,
#define elf_backend_object_p nds32_elf_object_p
#define elf_backend_final_write_processing nds32_elf_final_write_processing
#define elf_backend_special_sections nds32_elf_special_sections
#define elf_backend_section_flags nds32_elf_section_flags
#define bfd_elf32_bfd_get_relocated_section_contents \
nds32_elf_get_relocated_section_contents
#define bfd_elf32_bfd_is_target_special_symbol nds32_elf_is_target_special_symbol

View File

@ -1332,15 +1332,21 @@ ppc_elf_section_from_shdr (bfd *abfd,
return FALSE;
newsect = hdr->bfd_section;
flags = bfd_section_flags (newsect);
flags = 0;
if (hdr->sh_flags & SHF_EXCLUDE)
flags |= SEC_EXCLUDE;
if (hdr->sh_type == SHT_ORDERED)
flags |= SEC_SORT_ENTRIES;
bfd_set_section_flags (newsect, flags);
return TRUE;
if (strncmp (name, ".PPC.EMB", 8) == 0)
name += 8;
if (strncmp (name, ".sbss", 5) == 0
|| strncmp (name, ".sdata", 6) == 0)
flags |= SEC_SMALL_DATA;
return (flags == 0
|| bfd_set_section_flags (newsect, newsect->flags | flags));
}
/* Set up any other section flags and such that may be necessary. */

View File

@ -3151,6 +3151,8 @@ v850_elf_section_from_shdr (bfd *abfd,
const char *name,
int shindex)
{
flagword flags;
/* There ought to be a place to keep ELF backend specific flags, but
at the moment there isn't one. We just keep track of the
sections by their name, instead. */
@ -3158,18 +3160,21 @@ v850_elf_section_from_shdr (bfd *abfd,
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
return FALSE;
flags = 0;
switch (hdr->sh_type)
{
case SHT_V850_SCOMMON:
case SHT_V850_TCOMMON:
case SHT_V850_ZCOMMON:
if (!bfd_set_section_flags (hdr->bfd_section,
(bfd_section_flags (hdr->bfd_section)
| SEC_IS_COMMON)))
return FALSE;
flags = SEC_IS_COMMON;
}
return TRUE;
if ((hdr->sh_flags & SHF_V850_GPREL) != 0)
flags |= SEC_SMALL_DATA;
return (flags == 0
|| bfd_set_section_flags (hdr->bfd_section,
hdr->bfd_section->flags | flags));
}
/* Set the correct type for a V850 ELF section. We do this

View File

@ -1136,9 +1136,7 @@ elf64_alpha_info_to_howto (bfd *abfd, arelent *cache_ptr,
/* Handle an Alpha specific section when reading an object file. This
is called when bfd_section_from_shdr finds a section with an unknown
type.
FIXME: We need to handle the SHF_ALPHA_GPREL flag, but I'm not sure
how to. */
type. */
static bfd_boolean
elf64_alpha_section_from_shdr (bfd *abfd,

View File

@ -383,7 +383,9 @@ elf64_hppa_section_from_shdr (bfd *abfd,
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
return FALSE;
return TRUE;
return ((hdr->sh_flags & SHF_PARISC_SHORT) == 0
|| bfd_set_section_flags (hdr->bfd_section,
hdr->bfd_section->flags | SEC_SMALL_DATA));
}
/* SEC is a section containing relocs for an input BFD when linking; return

View File

@ -125,6 +125,7 @@ static bfd_vma opd_entry_value
#define elf_backend_finish_dynamic_sections ppc64_elf_finish_dynamic_sections
#define elf_backend_link_output_symbol_hook ppc64_elf_output_symbol_hook
#define elf_backend_special_sections ppc64_elf_special_sections
#define elf_backend_section_flags ppc64_elf_section_flags
#define elf_backend_merge_symbol_attribute ppc64_elf_merge_symbol_attribute
#define elf_backend_merge_symbol ppc64_elf_merge_symbol
#define elf_backend_get_reloc_section bfd_get_section_by_name
@ -2011,6 +2012,18 @@ ppc64_elf_new_section_hook (bfd *abfd, asection *sec)
return _bfd_elf_new_section_hook (abfd, sec);
}
static bfd_boolean
ppc64_elf_section_flags (const Elf_Internal_Shdr *hdr)
{
const char *name = hdr->bfd_section->name;
if (strncmp (name, ".sbss", 5) == 0
|| strncmp (name, ".sdata", 6) == 0)
hdr->bfd_section->flags |= SEC_SMALL_DATA;
return TRUE;
}
static struct _opd_sec_data *
get_opd_info (asection * sec)
{

View File

@ -7425,10 +7425,7 @@ _bfd_mips_elf_section_processing (bfd *abfd, Elf_Internal_Shdr *hdr)
/* Handle a MIPS specific section when reading an object file. This
is called when elfcode.h finds a section with an unknown type.
This routine supports both the 32-bit and 64-bit ELF ABI.
FIXME: We need to handle the SHF_MIPS_GPREL flag, but I'm not sure
how to. */
This routine supports both the 32-bit and 64-bit ELF ABI. */
bfd_boolean
_bfd_mips_elf_section_from_shdr (bfd *abfd,
@ -7517,6 +7514,9 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd,
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
return FALSE;
if (hdr->sh_flags & SHF_MIPS_GPREL)
flags |= SEC_SMALL_DATA;
if (flags)
{
if (!bfd_set_section_flags (hdr->bfd_section,