[binutils-gdb] bfd/COFF: drop link_add_one_symbol() hook
Jan Beulich
jbeulich@sourceware.org
Mon Apr 7 10:48:18 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0b4a7d8c8a037a671e588db9a190c0194dd1ec43
commit 0b4a7d8c8a037a671e588db9a190c0194dd1ec43
Author: Jan Beulich <jbeulich@suse.com>
Date: Mon Apr 7 12:46:16 2025 +0200
bfd/COFF: drop link_add_one_symbol() hook
The need for this has disappeared with dc12032bca08 ("Remove m68k-aout
and m68k-coff support"); avoid the unnecessary indirection.
Sadly, with ld/pe-dll.c using the wrapper, the removal requires moving
the declaration out of libcoff.h, to properly export the underlying BFD
function.
Diff:
---
bfd/bfd-in2.h | 12 ++++++++++++
bfd/coff-alpha.c | 2 +-
bfd/coff-arm.c | 12 ++++++------
bfd/coff-mips.c | 2 +-
bfd/coff-rs6000.c | 2 --
bfd/coff-sh.c | 2 +-
bfd/coff64-rs6000.c | 2 --
bfd/coffcode.h | 21 ++++-----------------
bfd/cofflink.c | 2 +-
bfd/libbfd-in.h | 6 ------
bfd/libbfd.h | 6 ------
bfd/libcoff.h | 9 ---------
bfd/linker.c | 20 +++++++++++++++++++-
ld/pe-dll.c | 6 +++---
14 files changed, 48 insertions(+), 56 deletions(-)
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 7a8318e19af..ec60f23f61b 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -2913,6 +2913,18 @@ const char *bfd_format_string (bfd_format format);
&& bfd_is_abs_section ((H)->u.def.section) \
&& !(H)->rel_from_abs)
+bool _bfd_generic_link_add_one_symbol
+ (struct bfd_link_info *info,
+ bfd *abfd,
+ const char *name,
+ flagword flags,
+ asection *section,
+ bfd_vma value,
+ const char *string,
+ bool copy,
+ bool collect,
+ struct bfd_link_hash_entry **hashp);
+
bool bfd_link_align_section (asection *, unsigned int);
bool bfd_link_split_section (bfd *abfd, asection *sec);
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index 2798efd299a..e2f1a4d2808 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -2359,7 +2359,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data =
alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
_bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL
+ NULL, NULL, NULL,
},
/* Supported architecture. */
bfd_arch_alpha,
diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c
index ab5f7b0663f..ee574518b77 100644
--- a/bfd/coff-arm.c
+++ b/bfd/coff-arm.c
@@ -1876,8 +1876,8 @@ record_arm_to_thumb_glue (struct bfd_link_info * info,
it. */
bh = NULL;
val = globals->arm_glue_size + 1;
- bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
- BSF_GLOBAL, s, val, NULL, true, false, &bh);
+ _bfd_generic_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
+ BSF_GLOBAL, s, val, NULL, true, false, &bh);
free (tmp_name);
@@ -1929,8 +1929,8 @@ record_thumb_to_arm_glue (struct bfd_link_info * info,
bh = NULL;
val = globals->thumb_glue_size + 1;
- bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
- BSF_GLOBAL, s, val, NULL, true, false, &bh);
+ _bfd_generic_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
+ BSF_GLOBAL, s, val, NULL, true, false, &bh);
/* If we mark it 'thumb', the disassembler will do a better job. */
myh = (struct coff_link_hash_entry *) bh;
@@ -1952,8 +1952,8 @@ record_thumb_to_arm_glue (struct bfd_link_info * info,
bh = NULL;
val = globals->thumb_glue_size + (globals->support_old_code ? 8 : 4);
- bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
- BSF_LOCAL, s, val, NULL, true, false, &bh);
+ _bfd_generic_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
+ BSF_LOCAL, s, val, NULL, true, false, &bh);
free (tmp_name);
diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c
index e2c632c8a0b..8c4d4f7bf73 100644
--- a/bfd/coff-mips.c
+++ b/bfd/coff-mips.c
@@ -1316,7 +1316,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
_bfd_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags,
_bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL
+ NULL, NULL,
},
/* Supported architecture. */
bfd_arch_mips,
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 7a20dba5d9c..ae9a0f613ab 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -4584,7 +4584,6 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
xcoff_ppc_relocate_section,
coff_rtype_to_howto,
NULL, /* _bfd_coff_adjust_symndx */
- _bfd_generic_link_add_one_symbol,
coff_link_output_has_begun,
coff_final_link_postscript,
NULL /* print_pdata. */
@@ -4774,7 +4773,6 @@ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data =
xcoff_ppc_relocate_section,
coff_rtype_to_howto,
NULL, /* _bfd_coff_adjust_symndx */
- _bfd_generic_link_add_one_symbol,
coff_link_output_has_begun,
coff_final_link_postscript,
NULL /* print_pdata. */
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c
index 275c4f5c2b5..c3e0e420230 100644
--- a/bfd/coff-sh.c
+++ b/bfd/coff-sh.c
@@ -3108,7 +3108,7 @@ static const bfd_coff_backend_data bfd_coff_small_swap_table =
coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
coff_classify_symbol, coff_compute_section_file_positions,
coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
- coff_adjust_symndx, coff_link_add_one_symbol,
+ coff_adjust_symndx,
coff_link_output_has_begun, coff_final_link_postscript,
bfd_pe_print_pdata
};
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 5a4bcbf206a..ec7ed08d3d0 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -2495,7 +2495,6 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
xcoff64_ppc_relocate_section,
coff_rtype_to_howto,
NULL, /* _bfd_coff_adjust_symndx */
- _bfd_generic_link_add_one_symbol,
coff_link_output_has_begun,
coff_final_link_postscript,
NULL /* print_pdata. */
@@ -2768,7 +2767,6 @@ static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data =
xcoff64_ppc_relocate_section,
coff_rtype_to_howto,
NULL, /* _bfd_coff_adjust_symndx */
- _bfd_generic_link_add_one_symbol,
coff_link_output_has_begun,
coff_final_link_postscript,
NULL /* print_pdata. */
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 325a8ab1b2f..bd0374fbfdd 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -1516,11 +1516,6 @@ CODE_FRAGMENT
. (bfd *, struct bfd_link_info *, bfd *, asection *,
. struct internal_reloc *, bool *);
.
-. bool (*_bfd_coff_link_add_one_symbol)
-. (struct bfd_link_info *, bfd *, const char *, flagword,
-. asection *, bfd_vma, const char *, bool, bool,
-. struct bfd_link_hash_entry **);
-.
. bool (*_bfd_coff_link_output_has_begun)
. (bfd *, struct coff_final_link_info *);
.
@@ -1659,10 +1654,6 @@ INTERNAL
.#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
. ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
. (obfd, info, ibfd, sec, rel, adjustedp))
-.#define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
-. value, string, cp, coll, hashp)\
-. ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
-. (info, abfd, name, flags, section, value, string, cp, coll, hashp))
.
.#define bfd_coff_link_output_has_begun(a,p) \
. ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p))
@@ -5513,10 +5504,6 @@ dummy_reloc16_extra_cases (bfd *abfd ATTRIBUTE_UNUSED,
#define coff_adjust_symndx NULL
#endif
-#ifndef coff_link_add_one_symbol
-#define coff_link_add_one_symbol _bfd_generic_link_add_one_symbol
-#endif
-
#ifndef coff_link_output_has_begun
static bool
@@ -5615,7 +5602,7 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table ATTRIBUTE_UNUSED =
coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
coff_classify_symbol, coff_compute_section_file_positions,
coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
- coff_adjust_symndx, coff_link_add_one_symbol,
+ coff_adjust_symndx,
coff_link_output_has_begun, coff_final_link_postscript,
bfd_pe_print_pdata
};
@@ -5656,7 +5643,7 @@ static const bfd_coff_backend_data ticoff0_swap_table =
coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
coff_classify_symbol, coff_compute_section_file_positions,
coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
- coff_adjust_symndx, coff_link_add_one_symbol,
+ coff_adjust_symndx,
coff_link_output_has_begun, coff_final_link_postscript,
bfd_pe_print_pdata
};
@@ -5698,7 +5685,7 @@ static const bfd_coff_backend_data ticoff1_swap_table =
coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
coff_classify_symbol, coff_compute_section_file_positions,
coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
- coff_adjust_symndx, coff_link_add_one_symbol,
+ coff_adjust_symndx,
coff_link_output_has_begun, coff_final_link_postscript,
bfd_pe_print_pdata /* huh */
};
@@ -5941,7 +5928,7 @@ static const bfd_coff_backend_data bigobj_swap_table =
coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate,
coff_classify_symbol, coff_compute_section_file_positions,
coff_start_final_link, coff_relocate_section, coff_rtype_to_howto,
- coff_adjust_symndx, coff_link_add_one_symbol,
+ coff_adjust_symndx,
coff_link_output_has_begun, coff_final_link_postscript,
bfd_pe_print_pdata /* huh */
};
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 876aed7a0d2..501731bd811 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -445,7 +445,7 @@ coff_link_add_symbols (bfd *abfd,
if (addit)
{
- if (! (bfd_coff_link_add_one_symbol
+ if (! (_bfd_generic_link_add_one_symbol
(info, abfd, name, flags, section, value,
(const char *) NULL, copy, false,
(struct bfd_link_hash_entry **) sym_hash)))
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index b2f70fbfdac..ae6d3039017 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -645,12 +645,6 @@ extern bool _bfd_generic_link_add_archive_symbols
/* Forward declaration to avoid prototype errors. */
typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
-/* Generic routine to add a single symbol. */
-extern bool _bfd_generic_link_add_one_symbol
- (struct bfd_link_info *, bfd *, const char *name, flagword,
- asection *, bfd_vma, const char *, bool copy,
- bool constructor, struct bfd_link_hash_entry **) ATTRIBUTE_HIDDEN;
-
/* Generic routine to mark section as supplying symbols only. */
extern void _bfd_generic_link_just_syms
(asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 4f6f5ea2f8a..d367fea33d3 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -651,12 +651,6 @@ extern bool _bfd_generic_link_add_archive_symbols
/* Forward declaration to avoid prototype errors. */
typedef struct bfd_link_hash_entry _bfd_link_hash_entry;
-/* Generic routine to add a single symbol. */
-extern bool _bfd_generic_link_add_one_symbol
- (struct bfd_link_info *, bfd *, const char *name, flagword,
- asection *, bfd_vma, const char *, bool copy,
- bool constructor, struct bfd_link_hash_entry **) ATTRIBUTE_HIDDEN;
-
/* Generic routine to mark section as supplying symbols only. */
extern void _bfd_generic_link_just_syms
(asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN;
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
index d0cfd09709a..05ebe358363 100644
--- a/bfd/libcoff.h
+++ b/bfd/libcoff.h
@@ -864,11 +864,6 @@ typedef struct
(bfd *, struct bfd_link_info *, bfd *, asection *,
struct internal_reloc *, bool *);
- bool (*_bfd_coff_link_add_one_symbol)
- (struct bfd_link_info *, bfd *, const char *, flagword,
- asection *, bfd_vma, const char *, bool, bool,
- struct bfd_link_hash_entry **);
-
bool (*_bfd_coff_link_output_has_begun)
(bfd *, struct coff_final_link_info *);
@@ -1005,10 +1000,6 @@ typedef struct
#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
(obfd, info, ibfd, sec, rel, adjustedp))
-#define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\
- value, string, cp, coll, hashp)\
- ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
- (info, abfd, name, flags, section, value, string, cp, coll, hashp))
#define bfd_coff_link_output_has_begun(a,p) \
((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p))
diff --git a/bfd/linker.c b/bfd/linker.c
index 2a4b8f02fe6..a9a23e5b9de 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1378,7 +1378,25 @@ hash_entry_bfd (struct bfd_link_hash_entry *h)
/*NOTREACHED*/
}
-/* Add a symbol to the global hash table.
+/*
+FUNCTION
+ _bfd_generic_link_add_one_symbol
+
+SYNOPSIS
+ bool _bfd_generic_link_add_one_symbol
+ (struct bfd_link_info *info,
+ bfd *abfd,
+ const char *name,
+ flagword flags,
+ asection *section,
+ bfd_vma value,
+ const char *string,
+ bool copy,
+ bool collect,
+ struct bfd_link_hash_entry **hashp);
+
+DESCRIPTION
+ Add a symbol to the global hash table.
ABFD is the BFD the symbol comes from.
NAME is the name of the symbol.
FLAGS is the BSF_* bits associated with the symbol.
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index de1cfafb65b..4a2ea036518 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -2639,9 +2639,9 @@ make_import_fixup_mark (arelent *rel, char *name)
memcpy (fixup_name, buf, prefix_len);
bh = NULL;
- bfd_coff_link_add_one_symbol (&link_info, abfd, fixup_name, BSF_GLOBAL,
- current_sec, /* sym->section, */
- rel->address, NULL, true, false, &bh);
+ _bfd_generic_link_add_one_symbol (&link_info, abfd, fixup_name, BSF_GLOBAL,
+ current_sec, /* sym->section, */
+ rel->address, NULL, true, false, &bh);
return bh->root.string;
}
More information about the Binutils-cvs
mailing list