This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/2] objcopy: Add --update-section option.


Andrew Burgess <andrew.burgess@embecosm.com> writes:
> diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
> index a5bfd4c..a0ac326 100644
> --- a/binutils/doc/binutils.texi
> +++ b/binutils/doc/binutils.texi
> @@ -1091,6 +1091,7 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
>          [@option{--set-section-flags} @var{sectionpattern}=@var{flags}]
>          [@option{--add-section} @var{sectionname}=@var{filename}]
>          [@option{--dump-section} @var{sectionname}=@var{filename}]
> +        [@option{--update-section} @var{sectionname}=@var{filename}]
>          [@option{--rename-section} @var{oldname}=@var{newname}[,@var{flags}]]
>          [@option{--long-section-names} @{enable,disable,keep@}]
>          [@option{--change-leading-char}] [@option{--remove-leading-char}]
> @@ -1489,6 +1490,22 @@ that it does not create a formatted file, it just dumps the contents
>  as raw binary data, without applying any relocations.  The option can
>  be specified more than once.
>  
> +@item --update-section @var{sectionname}=@var{filename}
> +Replace the contents of section named @var{sectionname} with the
> +contents of file @var{filename}, replacing any existing section
> +contents.

Maybe: "Replace the existing contents of a section named @var{sectionname}
with the contents of file @var{filename}.

> +Note - it is possible to use @option{--rename-section} and
> +@option{--update-section} to both update and rename a section from one
> +command line.  In this case, pass the original section name to
> +@option{--update-section}, and the original, and new section names to

No comma before "and new".

> @@ -808,6 +816,25 @@ find_section_list (const char *name, bfd_boolean add, unsigned int context)
>    return p;
>  }
>  
> +/* Find entry in UPDATE_SECTIONS list matching NAME.  Return pointer to
> +   matching list entry if one is found, otherwise return NULL.  */
> +
> +static struct section_add *
> +find_section_update (const char *name)
> +{
> +  struct section_add *pupdate;
> +
> +  for (pupdate = update_sections;
> +       pupdate != NULL;
> +       pupdate = pupdate->next)
> +    {
> +      if (strcmp (pupdate->name, name) == 0)
> +        return pupdate;
> +    }
> +
> +  return NULL;
> +}
> +

Rather than add this, I think we can just replace:

> +      r = find_section_update (bfd_get_section_name (abfd, sec));
[...]
> +      if (p && r)

with:

      if (p && is_update_section (abfd, sec))

OK with those changes, thanks.  Please add a short item to binutils/NEWS.

Richard


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]