[PATCH 25/27] bfd/ELF: mark functions exposed to ld as non-private

Jan Beulich jbeulich@suse.com
Mon Oct 27 14:24:43 GMT 2025
As non-private functions, these shouldn't have "_bfd_" prefixes,
but merely "bfd_" ones:
- _bfd_elf_size_group_sections(),
- _bfd_elf_match_sections_by_type(),
- _bfd_elf_strtab_{str,len}(),
- _bfd_elf_map_sections_to_segments(),
- _bfd_elf_tls_setup().

--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2376,7 +2376,7 @@ extern bool _bfd_elf_link_hash_table_ini
    unsigned int) ATTRIBUTE_HIDDEN;
 extern bool _bfd_elf_slurp_version_tables
   (bfd *, bool) ATTRIBUTE_HIDDEN;
-extern bool _bfd_elf_match_sections_by_type
+extern bool bfd_elf_match_sections_by_type
   (bfd *, const asection *, bfd *, const asection *);
 extern bool bfd_elf_is_group_section
   (bfd *, const struct bfd_section *);
@@ -2394,7 +2394,7 @@ extern asection *_bfd_elf_check_kept_sec
 extern void _bfd_elf_copy_link_hash_symbol_type
   (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *)
   ATTRIBUTE_HIDDEN;
-extern bool _bfd_elf_size_group_sections
+extern bool bfd_elf_size_group_sections
   (struct bfd_link_info *);
 extern bool _bfd_elf_fixup_group_sections
   (bfd *, asection *) ATTRIBUTE_HIDDEN;
@@ -2511,11 +2511,11 @@ extern void _bfd_elf_strtab_restore
   (struct elf_strtab_hash *, void *) ATTRIBUTE_HIDDEN;
 extern bfd_size_type _bfd_elf_strtab_size
   (struct elf_strtab_hash *) ATTRIBUTE_HIDDEN;
-extern bfd_size_type _bfd_elf_strtab_len
+extern bfd_size_type bfd_elf_strtab_len
   (struct elf_strtab_hash *);
 extern bfd_size_type _bfd_elf_strtab_offset
   (struct elf_strtab_hash *, size_t) ATTRIBUTE_HIDDEN;
-extern const char * _bfd_elf_strtab_str
+extern const char *bfd_elf_strtab_str
   (struct elf_strtab_hash *, size_t idx, bfd_size_type *offset);
 extern bool _bfd_elf_strtab_emit
   (bfd *, struct elf_strtab_hash *) ATTRIBUTE_HIDDEN;
@@ -2617,7 +2617,7 @@ extern int bfd_elf_discard_info
   (bfd *, struct bfd_link_info *);
 extern unsigned int _bfd_elf_default_action_discarded
   (struct bfd_section *) ATTRIBUTE_HIDDEN;
-extern struct bfd_section *_bfd_elf_tls_setup
+extern struct bfd_section *bfd_elf_tls_setup
   (bfd *, struct bfd_link_info *);
 
 extern bool _bfd_elf_link_create_dynamic_sections
@@ -2890,7 +2890,7 @@ extern bool bfd_elf_reloc_symbol_deleted
 extern struct elf_segment_map * _bfd_elf_make_dynamic_segment
   (bfd *, asection *) ATTRIBUTE_HIDDEN;
 
-extern bool _bfd_elf_map_sections_to_segments
+extern bool bfd_elf_map_sections_to_segments
   (bfd *, struct bfd_link_info *, bool *);
 
 extern bool _bfd_elf_is_function_type
--- a/bfd/elf-strtab.c
+++ b/bfd/elf-strtab.c
@@ -275,7 +275,7 @@ _bfd_elf_strtab_size (struct elf_strtab_
 }
 
 bfd_size_type
-_bfd_elf_strtab_len (struct elf_strtab_hash *tab)
+bfd_elf_strtab_len (struct elf_strtab_hash *tab)
 {
   return tab->size;
 }
@@ -296,8 +296,8 @@ _bfd_elf_strtab_offset (struct elf_strta
 }
 
 const char *
-_bfd_elf_strtab_str (struct elf_strtab_hash *tab, size_t idx,
-		     bfd_size_type *offset)
+bfd_elf_strtab_str (struct elf_strtab_hash *tab, size_t idx,
+		    bfd_size_type *offset)
 {
   if (idx == 0)
     return NULL;
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5085,9 +5085,9 @@ elf_modify_segment_map (bfd *abfd,
    NEED_LAYOUT if the section layout is changed.  */
 
 bool
-_bfd_elf_map_sections_to_segments (bfd *abfd,
-				   struct bfd_link_info *info,
-				   bool *need_layout)
+bfd_elf_map_sections_to_segments (bfd *abfd,
+				  struct bfd_link_info *info,
+				  bool *need_layout)
 {
   unsigned int count;
   struct elf_segment_map *m;
@@ -5906,7 +5906,7 @@ assign_file_positions_for_load_sections
   unsigned int opb = bfd_octets_per_byte (abfd, NULL);
 
   if (link_info == NULL
-      && !_bfd_elf_map_sections_to_segments (abfd, link_info, NULL))
+      && !bfd_elf_map_sections_to_segments (abfd, link_info, NULL))
     return false;
 
   alloc = 0;
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -4354,7 +4354,7 @@ ppc_elf_tls_setup (bfd *obfd, struct bfd
       elf_section_flags (htab->elf.splt->output_section) = SHF_ALLOC + SHF_WRITE;
     }
 
-  return _bfd_elf_tls_setup (obfd, info);
+  return bfd_elf_tls_setup (obfd, info);
 }
 
 /* Return TRUE iff REL is a branch reloc with a global symbol matching
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -3596,7 +3596,7 @@ _bfd_elf_symbol_refs_local_p (struct elf
    aligned.  Returns the first TLS output section.  */
 
 struct bfd_section *
-_bfd_elf_tls_setup (bfd *obfd, struct bfd_link_info *info)
+bfd_elf_tls_setup (bfd *obfd, struct bfd_link_info *info)
 {
   struct bfd_section *sec, *tls;
   unsigned int align = 0;
@@ -3889,8 +3889,7 @@ _bfd_elf_strip_zero_sized_dynamic_sectio
     {
       /* Regenerate program headers.  */
       elf_seg_map (info->output_bfd) = NULL;
-      return _bfd_elf_map_sections_to_segments (info->output_bfd, info,
-						NULL);
+      return bfd_elf_map_sections_to_segments (info->output_bfd, info, NULL);
     }
 
   return true;
@@ -6777,7 +6776,7 @@ compute_bucket_count (struct bfd_link_in
 /* Size any SHT_GROUP section for ld -r.  */
 
 bool
-_bfd_elf_size_group_sections (struct bfd_link_info *info)
+bfd_elf_size_group_sections (struct bfd_link_info *info)
 {
   bfd *ibfd;
   asection *s;
@@ -7409,7 +7408,7 @@ bfd_elf_size_dynamic_sections (bfd *outp
     }
 
   if (bfd_link_relocatable (info)
-      && !_bfd_elf_size_group_sections (info))
+      && !bfd_elf_size_group_sections (info))
     return false;
 
   /* Determine any GNU_STACK segment requirements, after the backend
@@ -8951,8 +8950,8 @@ bfd_elf_match_symbols_in_sections (asect
 /* Return TRUE if 2 section types are compatible.  */
 
 bool
-_bfd_elf_match_sections_by_type (bfd *abfd, const asection *asec,
-				 bfd *bbfd, const asection *bsec)
+bfd_elf_match_sections_by_type (bfd *abfd, const asection *asec,
+				bfd *bbfd, const asection *bsec)
 {
   if (asec == NULL
       || bsec == NULL
--- a/ld/emultempl/genelf.em
+++ b/ld/emultempl/genelf.em
@@ -56,7 +56,7 @@ static void
 gld${EMULATION_NAME}_before_allocation (void)
 {
   if (bfd_link_relocatable (&link_info)
-      && !_bfd_elf_size_group_sections (&link_info))
+      && !bfd_elf_size_group_sections (&link_info))
     einfo (_("%X%P: can not size group sections: %E\n"));
   before_allocation_default ();
 }
--- a/ld/emultempl/loongarchelf.em
+++ b/ld/emultempl/loongarchelf.em
@@ -84,9 +84,8 @@ gld${EMULATION_NAME}_after_allocation (v
     {
       if (lang_phdr_list == NULL)
 	elf_seg_map (link_info.output_bfd) = NULL;
-      if (!_bfd_elf_map_sections_to_segments (link_info.output_bfd,
-					      &link_info,
-					      NULL))
+      if (!bfd_elf_map_sections_to_segments (link_info.output_bfd,
+					     &link_info, NULL))
 	fatal (_("%P: map sections to segments failed: %E\n"));
     }
 
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1763,7 +1763,7 @@ ldelf_before_allocation (char **audit, c
 
   if (is_elf_hash_table (link_info.hash))
     {
-      _bfd_elf_tls_setup (link_info.output_bfd, &link_info);
+      bfd_elf_tls_setup (link_info.output_bfd, &link_info);
 
       /* Make __ehdr_start hidden if it has been referenced, to
 	 prevent the symbol from being dynamic.  */
@@ -2094,8 +2094,8 @@ elf_orphan_compatible (asection *in, ase
 	  || ((elf_section_flags (out) ^ elf_section_flags (in))
 	      & (SHF_MASKPROC | SHF_MASKOS)) != 0))
     return false;
-  return _bfd_elf_match_sections_by_type (link_info.output_bfd, out,
-					  in->owner, in);
+  return bfd_elf_match_sections_by_type (link_info.output_bfd, out,
+					 in->owner, in);
 }
 
 /* Place an orphan section.  We use this to put random SHF_ALLOC
@@ -2314,8 +2314,8 @@ ldelf_place_orphan (asection *s, const c
 	    && ((nexts->flags ^ flags) & (SEC_LOAD | SEC_ALLOC)) == 0
 	    && (nexts->owner->flags & DYNAMIC) == 0
 	    && !bfd_input_just_syms (nexts->owner)
-	    && _bfd_elf_match_sections_by_type (nexts->owner, nexts,
-						s->owner, s))
+	    && bfd_elf_match_sections_by_type (nexts->owner, nexts,
+					       s->owner, s))
 	  flags = (((flags ^ SEC_READONLY)
 		    | (nexts->flags ^ SEC_READONLY))
 		   ^ SEC_READONLY);
@@ -2383,7 +2383,7 @@ ldelf_place_orphan (asection *s, const c
       if (after == NULL)
 	after
 	  = lang_output_section_find_by_flags (s, flags, &place->os,
-					       _bfd_elf_match_sections_by_type);
+					       bfd_elf_match_sections_by_type);
       if (after == NULL)
 	/* *ABS* is always the first output section statement.  */
 	after = (void *) lang_os_list.head;
--- a/ld/ldelfgen.c
+++ b/ld/ldelfgen.c
@@ -304,9 +304,8 @@ ldelf_map_segments (bool need_layout)
 	     previous linker generated program headers.  */
 	  if (lang_phdr_list == NULL)
 	    elf_seg_map (link_info.output_bfd) = NULL;
-	  if (!_bfd_elf_map_sections_to_segments (link_info.output_bfd,
-						  &link_info,
-						  &need_layout))
+	  if (!bfd_elf_map_sections_to_segments (link_info.output_bfd,
+						 &link_info, &need_layout))
 	    fatal (_("%P: map sections to segments failed: %E\n"));
 
 	  if (phdr_size != elf_program_header_size (link_info.output_bfd))
@@ -384,13 +383,13 @@ ldelf_ctf_strtab_iter_cb (uint32_t *offs
      a nonzero refcount.  */
   do
     {
-      if (arg->next_i >= _bfd_elf_strtab_len (arg->strtab))
+      if (arg->next_i >= bfd_elf_strtab_len (arg->strtab))
 	{
 	  arg->next_i = 0;
 	  return NULL;
 	}
 
-      ret = _bfd_elf_strtab_str (arg->strtab, arg->next_i++, &off);
+      ret = bfd_elf_strtab_str (arg->strtab, arg->next_i++, &off);
     }
   while (ret == NULL);
 
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -6536,7 +6536,7 @@ lang_size_sections_1
   return dot;
 }
 
-/* Callback routine that is used in _bfd_elf_map_sections_to_segments.
+/* Callback routine that is used in bfd_elf_map_sections_to_segments.
    The BFD library has set NEW_SEGMENT to TRUE iff it thinks that
    CURRENT_SECTION and PREVIOUS_SECTION ought to be placed into different
    segments.  We are allowed an opportunity to override this decision.  */



More information about the Binutils mailing list