PR binutils/15033

* objcopy.c (enum change_action): Delete.
	(struct section_list): Delete remove, copy, change_vma, change_lma
	and set_flags fields.  Add context field.
	(find_section_list): Add a context parameter.  Add support for
	wildcard characters in section names.
	(is_strip_section): Check for sections being both  copied and
	removed.
	(copy_object): Pass context to find_section_list.
	(setup_section): Likewise.
	(copy_section): Likewise.
	(copy_main): Likewise.
	* doc/binutils: Document the new behaviour.
	* NEWS: Mention the new feature
This commit is contained in:
Nick Clifton
2013-02-15 09:32:31 +00:00
parent 796cb314e7
commit 2e62b7218b
4 changed files with 265 additions and 162 deletions

View File

@@ -1065,8 +1065,8 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
[@option{-b} @var{byte}|@option{--byte=}@var{byte}]
[@option{-i} [@var{breadth}]|@option{--interleave}[=@var{breadth}]]
[@option{--interleave-width=}@var{width}]
[@option{-j} @var{sectionname}|@option{--only-section=}@var{sectionname}]
[@option{-R} @var{sectionname}|@option{--remove-section=}@var{sectionname}]
[@option{-j} @var{sectionpattern}|@option{--only-section=}@var{sectionpattern}]
[@option{-R} @var{sectionpattern}|@option{--remove-section=}@var{sectionpattern}]
[@option{-p}|@option{--preserve-dates}]
[@option{-D}|@option{--enable-deterministic-archives}]
[@option{-U}|@option{--disable-deterministic-archives}]
@@ -1076,11 +1076,11 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
[@option{--set-start=}@var{val}]
[@option{--adjust-start=}@var{incr}]
[@option{--change-addresses=}@var{incr}]
[@option{--change-section-address} @var{section}@{=,+,-@}@var{val}]
[@option{--change-section-lma} @var{section}@{=,+,-@}@var{val}]
[@option{--change-section-vma} @var{section}@{=,+,-@}@var{val}]
[@option{--change-section-address} @var{sectionpattern}@{=,+,-@}@var{val}]
[@option{--change-section-lma} @var{sectionpattern}@{=,+,-@}@var{val}]
[@option{--change-section-vma} @var{sectionpattern}@{=,+,-@}@var{val}]
[@option{--change-warnings}] [@option{--no-change-warnings}]
[@option{--set-section-flags} @var{section}=@var{flags}]
[@option{--set-section-flags} @var{sectionpattern}=@var{flags}]
[@option{--add-section} @var{sectionname}=@var{filename}]
[@option{--rename-section} @var{oldname}=@var{newname}[,@var{flags}]]
[@option{--long-section-names} @{enable,disable,keep@}]
@@ -1204,17 +1204,21 @@ called _binary_@var{objfile}_start, _binary_@var{objfile}_end and
_binary_@var{objfile}_size. e.g. you can transform a picture file into
an object file and then access it in your code using these symbols.
@item -j @var{sectionname}
@itemx --only-section=@var{sectionname}
Copy only the named section from the input file to the output file.
@item -j @var{sectionpattern}
@itemx --only-section=@var{sectionpattern}
Copy only the indicated sections from the input file to the output file.
This option may be given more than once. Note that using this option
inappropriately may make the output file unusable.
inappropriately may make the output file unusable. Wildcard
characters are accepted in @var{sectionpattern}.
@item -R @var{sectionname}
@itemx --remove-section=@var{sectionname}
Remove any section named @var{sectionname} from the output file. This
option may be given more than once. Note that using this option
inappropriately may make the output file unusable.
@item -R @var{sectionpattern}
@itemx --remove-section=@var{sectionpattern}
Remove any section matching @var{sectionpattern} from the output file.
This option may be given more than once. Note that using this option
inappropriately may make the output file unusable. Wildcard
characters are accepted in @var{sectionpattern}. Using both the
@option{-j} and @option{-R} options together results in undefined
behaviour.
@item -S
@itemx --strip-all
@@ -1396,65 +1400,68 @@ relocate the sections; if the program expects sections to be loaded at a
certain address, and this option is used to change the sections such
that they are loaded at a different address, the program may fail.
@item --change-section-address @var{section}@{=,+,-@}@var{val}
@itemx --adjust-section-vma @var{section}@{=,+,-@}@var{val}
@item --change-section-address @var{sectionpattern}@{=,+,-@}@var{val}
@itemx --adjust-section-vma @var{sectionpattern}@{=,+,-@}@var{val}
@cindex changing section address
Set or change both the VMA address and the LMA address of the named
@var{section}. If @samp{=} is used, the section address is set to
@var{val}. Otherwise, @var{val} is added to or subtracted from the
section address. See the comments under @option{--change-addresses},
above. If @var{section} does not exist in the input file, a warning will
be issued, unless @option{--no-change-warnings} is used.
Set or change both the VMA address and the LMA address of any section
matching @var{sectionpattern}. If @samp{=} is used, the section
address is set to @var{val}. Otherwise, @var{val} is added to or
subtracted from the section address. See the comments under
@option{--change-addresses}, above. If @var{sectionpattern} does not
match any sections in the input file, a warning will be issued, unless
@option{--no-change-warnings} is used.
@item --change-section-lma @var{section}@{=,+,-@}@var{val}
@item --change-section-lma @var{sectionpattern}@{=,+,-@}@var{val}
@cindex changing section LMA
Set or change the LMA address of the named @var{section}. The LMA
address is the address where the section will be loaded into memory at
program load time. Normally this is the same as the VMA address, which
is the address of the section at program run time, but on some systems,
Set or change the LMA address of any sections matching
@var{sectionpattern}. The LMA address is the address where the
section will be loaded into memory at program load time. Normally
this is the same as the VMA address, which is the address of the
section at program run time, but on some systems, especially those
where a program is held in ROM, the two can be different. If @samp{=}
is used, the section address is set to @var{val}. Otherwise,
@var{val} is added to or subtracted from the section address. See the
comments under @option{--change-addresses}, above. If
@var{sectionpattern} does not match any sections in the input file, a
warning will be issued, unless @option{--no-change-warnings} is used.
@item --change-section-vma @var{sectionpattern}@{=,+,-@}@var{val}
@cindex changing section VMA
Set or change the VMA address of any section matching
@var{sectionpattern}. The VMA address is the address where the
section will be located once the program has started executing.
Normally this is the same as the LMA address, which is the address
where the section will be loaded into memory, but on some systems,
especially those where a program is held in ROM, the two can be
different. If @samp{=} is used, the section address is set to
@var{val}. Otherwise, @var{val} is added to or subtracted from the
section address. See the comments under @option{--change-addresses},
above. If @var{section} does not exist in the input file, a warning
will be issued, unless @option{--no-change-warnings} is used.
@item --change-section-vma @var{section}@{=,+,-@}@var{val}
@cindex changing section VMA
Set or change the VMA address of the named @var{section}. The VMA
address is the address where the section will be located once the
program has started executing. Normally this is the same as the LMA
address, which is the address where the section will be loaded into
memory, but on some systems, especially those where a program is held in
ROM, the two can be different. If @samp{=} is used, the section address
is set to @var{val}. Otherwise, @var{val} is added to or subtracted
from the section address. See the comments under
@option{--change-addresses}, above. If @var{section} does not exist in
the input file, a warning will be issued, unless
above. If @var{sectionpattern} does not match any sections in the
input file, a warning will be issued, unless
@option{--no-change-warnings} is used.
@item --change-warnings
@itemx --adjust-warnings
If @option{--change-section-address} or @option{--change-section-lma} or
@option{--change-section-vma} is used, and the named section does not
exist, issue a warning. This is the default.
@option{--change-section-vma} is used, and the section pattern does not
match any sections, issue a warning. This is the default.
@item --no-change-warnings
@itemx --no-adjust-warnings
Do not issue a warning if @option{--change-section-address} or
@option{--adjust-section-lma} or @option{--adjust-section-vma} is used, even
if the named section does not exist.
if the section pattern does not match any sections.
@item --set-section-flags @var{section}=@var{flags}
Set the flags for the named section. The @var{flags} argument is a
comma separated string of flag names. The recognized names are
@samp{alloc}, @samp{contents}, @samp{load}, @samp{noload},
@samp{readonly}, @samp{code}, @samp{data}, @samp{rom}, @samp{share}, and
@samp{debug}. You can set the @samp{contents} flag for a section which
does not have contents, but it is not meaningful to clear the
@samp{contents} flag of a section which does have contents--just remove
the section instead. Not all flags are meaningful for all object file
formats.
@item --set-section-flags @var{sectionpattern}=@var{flags}
Set the flags for any sections matching @var{sectionpattern}. The
@var{flags} argument is a comma separated string of flag names. The
recognized names are @samp{alloc}, @samp{contents}, @samp{load},
@samp{noload}, @samp{readonly}, @samp{code}, @samp{data}, @samp{rom},
@samp{share}, and @samp{debug}. You can set the @samp{contents} flag
for a section which does not have contents, but it is not meaningful
to clear the @samp{contents} flag of a section which does have
contents--just remove the section instead. Not all flags are
meaningful for all object file formats.
@item --add-section @var{sectionname}=@var{filename}
Add a new section named @var{sectionname} while copying the file. The
@@ -2787,7 +2794,9 @@ Replace @var{objfile} with a file in the output format @var{bfdname}.
@itemx --remove-section=@var{sectionname}
Remove any section named @var{sectionname} from the output file. This
option may be given more than once. Note that using this option
inappropriately may make the output file unusable.
inappropriately may make the output file unusable. The wildcard
character @samp{*} may be given at the end of @var{sectionname}. If
so, then any section starting with @var{sectionname} will be removed.
@item -s
@itemx --strip-all