[PATCH 23/27] bfd/ELF: _bfd_elf_large_com_section is exposed to gas and x86-only
Jan Beulich
jbeulich@suse.com
Mon Oct 27 14:23:44 GMT 2025
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.
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -3215,8 +3215,8 @@ extern struct elf_link_hash_entry * _bfd
(struct elf_link_hash_entry **, unsigned int, Elf_Internal_Shdr *)
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. */
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -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)
{
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -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);
}
@@ -6053,7 +6053,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;
@@ -6072,7 +6072,7 @@ elf_x86_64_symbol_processing (bfd *abfd
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;
@@ -6102,7 +6102,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
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -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)
{
@@ -1177,7 +1185,7 @@ _bfd_x86_elf_link_relax_section (bfd *ab
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);
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -18750,7 +18750,7 @@ handle_large_common (int small ATTRIBUTE
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);
More information about the Binutils
mailing list