[PATCH v4 2/2] bfd: properly use bfd_get_symbol_leading_char in peXXigen.
Jan Beulich
jbeulich@suse.com
Tue Apr 1 07:06:52 GMT 2025
On 01.04.2025 02:31, Jeremy Drake wrote:
> This function returns the leading char to use, so we cannot just assume
> it will always be '_' or '\0'.
Thanks for doing this. I think though that this wants to be patch 1, such
that code you add in what right now is patch 1 is added correctly right
away.
> --- a/bfd/peXXigen.c
> +++ b/bfd/peXXigen.c
> @@ -4405,6 +4405,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 buf[20];
>
> /* There are a few fields that need to be filled in now while we
> have symbol table access.
> @@ -4542,10 +4543,10 @@ _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);
> + buf[0] = bfd_get_symbol_leading_char (abfd);
> + buf[1] = '\0';
> + strcat(buf, "_tls_used");
This then also wants using in the diagnostics mentioning the symbol name (see
my respective comment on patch 1).
Also, it looks cheaper to me to simply do
buf[0] = bfd_get_symbol_leading_char (abfd);
strcpy (buf + !!buf[0], "_tls_used");
? (Further note the blank before the opening parenthesis.)
Finally, instead of naming the buffer "buf" (very unspecific), please consider
using "name" or "symname" or some such.
Jan
More information about the Binutils
mailing list