bfd/ELF: _bfd_elf_large_com_section is exposed to gas and x86-only

As a non-private data item, it shouldn't have a "_bfd_" prefix, but merely
a "bfd_" one. Furthermore, as being x86-only (forever since its
introduction), it doesn't need to be present in libbfd.{a,so} at all for
other targets.
This commit is contained in:
Jan Beulich
2025-11-07 14:59:45 +01:00
parent 4a890d55ad
commit 8b322fc15a
5 changed files with 16 additions and 17 deletions

View File

@@ -3222,8 +3222,8 @@ extern struct elf_link_hash_entry * _bfd_elf_get_link_hash_entry
extern asection *_bfd_get_local_sym_section
(struct elf_reloc_cookie *, unsigned int) ATTRIBUTE_HIDDEN;
/* Large common section. */
extern asection _bfd_elf_large_com_section;
/* Large common section (x86 only). */
extern asection bfd_elf_large_com_section;
/* Hash for local symbol with the first section id, ID, in the input
file and the local symbol index, SYM. */

View File

@@ -13449,15 +13449,6 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd,
return n;
}
/* It is only used by x86-64 so far.
??? This repeats *COM* id of zero. sec->id is supposed to be unique,
but current usage would allow all of _bfd_std_section to be zero. */
static const asymbol lcomm_sym
= GLOBAL_SYM_INIT ("LARGE_COMMON", &_bfd_elf_large_com_section);
asection _bfd_elf_large_com_section
= BFD_FAKE_SECTION (_bfd_elf_large_com_section, &lcomm_sym,
"LARGE_COMMON", 0, SEC_IS_COMMON);
bool
_bfd_elf_final_write_processing (bfd *abfd)
{

View File

@@ -1961,7 +1961,7 @@ elf_x86_64_convert_load_reloc (bfd *abfd,
else if (isym->st_shndx == SHN_COMMON)
tsec = bfd_com_section_ptr;
else if (isym->st_shndx == SHN_X86_64_LCOMMON)
tsec = &_bfd_elf_large_com_section;
tsec = &bfd_elf_large_com_section;
else
tsec = bfd_section_from_elf_index (abfd, isym->st_shndx);
}
@@ -6055,7 +6055,7 @@ static bool
elf_x86_64_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
asection *sec, int *index_return)
{
if (sec == &_bfd_elf_large_com_section)
if (sec == &bfd_elf_large_com_section)
{
*index_return = SHN_X86_64_LCOMMON;
return true;
@@ -6074,7 +6074,7 @@ elf_x86_64_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
switch (elfsym->internal_elf_sym.st_shndx)
{
case SHN_X86_64_LCOMMON:
asym->section = &_bfd_elf_large_com_section;
asym->section = &bfd_elf_large_com_section;
asym->value = elfsym->internal_elf_sym.st_size;
/* Common symbol doesn't set BSF_GLOBAL. */
asym->flags &= ~BSF_GLOBAL;
@@ -6104,7 +6104,7 @@ elf_x86_64_common_section (asection *sec)
if ((elf_section_flags (sec) & SHF_X86_64_LARGE) == 0)
return bfd_com_section_ptr;
else
return &_bfd_elf_large_com_section;
return &bfd_elf_large_com_section;
}
static bool

View File

@@ -29,6 +29,14 @@
#define ELF64_DYNAMIC_INTERPRETER "/lib/ld64.so.1"
#define ELFX32_DYNAMIC_INTERPRETER "/lib/ldx32.so.1"
/* ??? This repeats *COM* id of zero. sec->id is supposed to be unique,
but current usage would allow all of _bfd_std_section to be zero. */
static const asymbol lcomm_sym
= GLOBAL_SYM_INIT ("LARGE_COMMON", &bfd_elf_large_com_section);
asection bfd_elf_large_com_section
= BFD_FAKE_SECTION (bfd_elf_large_com_section, &lcomm_sym,
"LARGE_COMMON", 0, SEC_IS_COMMON);
bool
_bfd_x86_elf_mkobject (bfd *abfd)
{
@@ -1179,7 +1187,7 @@ _bfd_x86_elf_link_relax_section (bfd *abfd ATTRIBUTE_UNUSED,
case SHN_X86_64_LCOMMON:
if (!is_x86_64)
abort ();
sec = &_bfd_elf_large_com_section;
sec = &bfd_elf_large_com_section;
break;
default:
sec = bfd_section_from_elf_index (abfd, isym->st_shndx);

View File

@@ -18761,7 +18761,7 @@ handle_large_common (int small ATTRIBUTE_UNUSED)
subseg_set (seg, subseg);
}
elf_com_section_ptr = &_bfd_elf_large_com_section;
elf_com_section_ptr = &bfd_elf_large_com_section;
bss_section = lbss_section;
s_comm_internal (0, elf_common_parse);