[PATCH v5] objcopy: add option to specify custom prefix for symbol of binary input
Alan Modra
amodra@gmail.com
Wed Oct 29 02:07:32 GMT 2025
On Mon, Oct 27, 2025 at 03:53:48PM +0200, Alon Bar-Lev wrote:
> --- a/bfd/bfd.c
> +++ b/bfd/bfd.c
> @@ -105,6 +105,9 @@ CODE_FRAGMENT
> . {* The filename the application opened the BFD with. *}
> . const char *filename;
> .
> +. {* The symbol name for the file or NULL. *}
> +. const char *binary_symbol_prefix;
> +.
Move this to binary.c line 44, without the special markup, and better
call the variable _bfd_binary_symbol_prefix. We're just giving a side
channel from binutils/objcopy.c to bfd/binary.c. (See for example
_bfd_srec_len.) No need for any bfd.c changes. I don't think it
makes sense to add a pointer to every bfd opened just for a "clean"
interface. Yes, it would be nice to tidy these some day, and get rid
of most libbfd static variables too, but that's probably a job for a
global maintainer.
> diff --git a/binutils/objcopy.c b/binutils/objcopy.c
> index 9373b75d6ed..6613af01bab 100644
> --- a/binutils/objcopy.c
> +++ b/binutils/objcopy.c
> @@ -334,6 +334,7 @@ enum command_line_switch
> OPTION_HEAP,
> OPTION_IMAGE_BASE,
> OPTION_IMPURE,
> + OPTION_INPUT_SYMBOL,
> OPTION_INTERLEAVE_WIDTH,
> OPTION_KEEPGLOBAL_SYMBOLS,
> OPTION_KEEP_FILE_SYMBOLS,
Let's make that enum better match the changed option name. You can
simplify your objcopy.c patch too, just write directly to
_bfd_binary_symbol_prefix in copy_main.
--
Alan Modra
More information about the Binutils
mailing list