use copy_private_symbol_data in objcopy

Message ID ZieeeYlWq8PFbe7l@squeak.grove.modra.org
State New
Headers
Series use copy_private_symbol_data in objcopy |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 warning Patch is already merged
linaro-tcwg-bot/tcwg_binutils_check--master-arm warning Patch is already merged

Commit Message

Alan Modra April 23, 2024, 11:41 a.m. UTC
  osympp appearing twice here is not a bug.

	PR 14493
	* objcopy.c (copy_object): Run the symbols through
	bfd_copy_private_symbol_data.
  

Comments

H.J. Lu April 23, 2024, 1:58 p.m. UTC | #1
On Tue, Apr 23, 2024 at 4:42 AM Alan Modra <amodra@gmail.com> wrote:
>
> osympp appearing twice here is not a bug.
>
>         PR 14493
>         * objcopy.c (copy_object): Run the symbols through
>         bfd_copy_private_symbol_data.
>
> diff --git a/binutils/objcopy.c b/binutils/objcopy.c
> index d91ba123c01..634ebae3fc3 100644
> --- a/binutils/objcopy.c
> +++ b/binutils/objcopy.c
> @@ -3380,6 +3380,13 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
>        symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
>      }
>
> +  for (i = 0; i < symcount; i++)

This failed to compile with GCC 14 on 32-bit hosts:

/export/gnu/import/git/sources/binutils-gdb/binutils/objcopy.c: In
function ‘copy_object’:
/export/gnu/import/git/sources/binutils-gdb/binutils/objcopy.c:3383:17:
error: comparison of integer expressions of different signedness:
‘unsigned int’ and ‘long int’ [-Werror=sign-compare]
 3383 |   for (i = 0; i < symcount; i++)
      |                 ^

> +    if (!bfd_copy_private_symbol_data (ibfd, osympp[i], obfd, osympp[i]))
> +      {
> +       status = 1;
> +       return false;
> +      }
> +
>    if (dhandle != NULL)
>      {
>        bool res;
>
> --
> Alan Modra
> Australia Development Lab, IBM
  

Patch

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index d91ba123c01..634ebae3fc3 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3380,6 +3380,13 @@  copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
       symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
     }
 
+  for (i = 0; i < symcount; i++)
+    if (!bfd_copy_private_symbol_data (ibfd, osympp[i], obfd, osympp[i]))
+      {
+	status = 1;
+	return false;
+      }
+
   if (dhandle != NULL)
     {
       bool res;