[PATCH v5 1/3] bfd: properly use bfd_get_symbol_leading_char in peXXigen.
Jan Beulich
jbeulich@suse.com
Thu Apr 3 08:46:52 GMT 2025
On 03.04.2025 00:52, Jeremy Drake wrote:
> This function returns the leading char to use, so we cannot just assume
> it will always be '_' or '\0'.
>
> Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
> ---
> bfd/peXXigen.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
> index 29012688adf..29831d4caaa 100644
> --- a/bfd/peXXigen.c
> +++ b/bfd/peXXigen.c
> @@ -4403,6 +4403,7 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo)
> struct coff_link_hash_entry *h1;
> struct bfd_link_info *info = pfinfo->info;
> bool result = true;
> + char name[20];
>
> /* There are a few fields that need to be filled in now while we
> have symbol table access.
> @@ -4540,10 +4541,9 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo)
> }
> }
>
> - h1 = coff_link_hash_lookup (coff_hash_table (info),
> - (bfd_get_symbol_leading_char (abfd) != 0
> - ? "__tls_used" : "_tls_used"),
> - false, false, true);
> + name[0] = bfd_get_symbol_leading_char (abfd);
> + strcpy (name + !!name[0], "_tls_used");
> + h1 = coff_link_hash_lookup (coff_hash_table (info), name, false, false, true);
> if (h1 != NULL)
> {
> if ((h1->root.type == bfd_link_hash_defined
> @@ -4558,8 +4558,8 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo)
> else
> {
> _bfd_error_handler
> - (_("%pB: unable to fill in DataDictionary[9] because __tls_used is missing"),
> - abfd);
> + (_("%pB: unable to fill in DataDictionary[%d]: %s not defined correctly"),
> + abfd, PE_TLS_TABLE, name);
Oh, actually (no idea why I didn't spot this much earlier): Can you please
replace DataDictionary by DataDirectory here and also in the messages the
subsequent patch adds (which actually is where I noticed it)?
Jan
More information about the Binutils
mailing list