[PATCH] objcopy: add option to specify custom symbol name for binary input

Alon Bar-Lev alon.barlev@gmail.com
Mon Oct 27 09:42:22 GMT 2025


On Mon, 27 Oct 2025 at 10:51, Jan Beulich <jbeulich@suse.com> wrote:

> On 25.10.2025 05:25, Alon Bar-Lev wrote:
> > When using --input-target=binary, objcopy currently derives symbol names
> from
> > a mangled version of the input file name.  This approach can lead to
> > unpredictable results, as the generated symbols depend on the file path
> and
> > working directory.
> >
> > This patch introduces a new option:
> >
> >   --input-symbol <name>    Use <name> as the base symbol name for the
> input file
> >                            (default: derived from file name)
> >
> > It allows specifying an explicit symbol name, while preserving the
> existing
> > behavior as a fallback.
> >
> > Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
> > ---
> >  bfd/bfd-in2.h                               | 15 ++++++++
> >  bfd/bfd.c                                   | 15 ++++++++
> >  bfd/binary.c                                |  7 +++-
> >  binutils/doc/binutils.texi                  | 15 ++++++++
> >  binutils/objcopy.c                          | 23 ++++++++----
> >  binutils/testsuite/binutils-all/objcopy.exp | 39 +++++++++++++++++++++
> >  6 files changed, 107 insertions(+), 7 deletions(-)
>
> I have a total of 4 patches with the same title in my inbox. Which one is
> newest?
> Judging from time, was this one perhaps meant to be tagged v4?
>
>
Hi Jan,

Yes... all are the same implementation, the tests were improved over the
revisions.

Before I perform the changes Alan requested, please let me know what
implementation you prefer.

I put the symbol name in bfd so that in future other binary sections could
have a symbol attached.

Thanks,
Alon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20251027/40698e70/attachment.htm>


More information about the Binutils mailing list