Based on patch from H. Peter Anvin <hpa@transmeta.com>:
* objcopy.c (struct section_list): Add copy field. (sections_copied): New static variable. (copy_options): Add "only-section". (copy_usage): Mention -j and --only-section. (find_section_list): Initialize copy field. (is_strip_section): Check for copying sections. (copy_object): Check sections_copied when calling filter_symbols. (setup_section): Check for copying sections. (copy_section): Likewise. (copy_main): Handle -j/--only-section. * binutils.texi, objcopy.1: Document -j/--only-section.
This commit is contained in:
parent
f353eb8a51
commit
f91ea84976
@ -1,5 +1,18 @@
|
|||||||
1999-06-12 Ian Lance Taylor <ian@zembu.com>
|
1999-06-12 Ian Lance Taylor <ian@zembu.com>
|
||||||
|
|
||||||
|
Based on patch from H. Peter Anvin <hpa@transmeta.com>:
|
||||||
|
* objcopy.c (struct section_list): Add copy field.
|
||||||
|
(sections_copied): New static variable.
|
||||||
|
(copy_options): Add "only-section".
|
||||||
|
(copy_usage): Mention -j and --only-section.
|
||||||
|
(find_section_list): Initialize copy field.
|
||||||
|
(is_strip_section): Check for copying sections.
|
||||||
|
(copy_object): Check sections_copied when calling filter_symbols.
|
||||||
|
(setup_section): Check for copying sections.
|
||||||
|
(copy_section): Likewise.
|
||||||
|
(copy_main): Handle -j/--only-section.
|
||||||
|
* binutils.texi, objcopy.1: Document -j/--only-section.
|
||||||
|
|
||||||
* configure.in: If frexp is not available, check in -lm.
|
* configure.in: If frexp is not available, check in -lm.
|
||||||
* configure: Rebuild.
|
* configure: Rebuild.
|
||||||
|
|
||||||
|
@ -18,6 +18,9 @@ Changes in binutils 2.10:
|
|||||||
* dlltool now takes --export-all-symbols, --no-export-all-symbols,
|
* dlltool now takes --export-all-symbols, --no-export-all-symbols,
|
||||||
--exclude-symbols, and --no-default-excludes options.
|
--exclude-symbols, and --no-default-excludes options.
|
||||||
|
|
||||||
|
* objcopy now takes a -j/--only-section option to copy only the specified
|
||||||
|
sections.
|
||||||
|
|
||||||
Changes in binutils 2.9:
|
Changes in binutils 2.9:
|
||||||
|
|
||||||
* Added windres program, which can be used to manipulate resources in WIN32
|
* Added windres program, which can be used to manipulate resources in WIN32
|
||||||
|
@ -837,6 +837,7 @@ objcopy [ -F @var{bfdname} | --target=@var{bfdname} ]
|
|||||||
[ -x | --discard-all ] [ -X | --discard-locals ]
|
[ -x | --discard-all ] [ -X | --discard-locals ]
|
||||||
[ -b @var{byte} | --byte=@var{byte} ]
|
[ -b @var{byte} | --byte=@var{byte} ]
|
||||||
[ -i @var{interleave} | --interleave=@var{interleave} ]
|
[ -i @var{interleave} | --interleave=@var{interleave} ]
|
||||||
|
[ -j @var{sectionname} | --only-section=@var{sectionname} ]
|
||||||
[ -R @var{sectionname} | --remove-section=@var{sectionname} ]
|
[ -R @var{sectionname} | --remove-section=@var{sectionname} ]
|
||||||
[ -p | --preserve-dates ] [ --debugging ]
|
[ -p | --preserve-dates ] [ --debugging ]
|
||||||
[ --gap-fill=@var{val} ] [ --pad-to=@var{address} ]
|
[ --gap-fill=@var{val} ] [ --pad-to=@var{address} ]
|
||||||
@ -905,6 +906,12 @@ Use @var{bfdname} as the object format for both the input and the output
|
|||||||
file; i.e., simply transfer data from source to destination with no
|
file; i.e., simply transfer data from source to destination with no
|
||||||
translation. @xref{Target Selection}, for more information.
|
translation. @xref{Target Selection}, for more information.
|
||||||
|
|
||||||
|
@item -j @var{sectionname}
|
||||||
|
@itemx --only-section=@var{sectionname}
|
||||||
|
Copy only the named section 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.
|
||||||
|
|
||||||
@item -R @var{sectionname}
|
@item -R @var{sectionname}
|
||||||
@itemx --remove-section=@var{sectionname}
|
@itemx --remove-section=@var{sectionname}
|
||||||
Remove any section named @var{sectionname} from the output file. This
|
Remove any section named @var{sectionname} from the output file. This
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.\" Copyright (c) 1991, 93, 94, 95, 96, 97, 1998 Free Software Foundation
|
.\" Copyright (c) 1991, 93, 94, 95, 96, 97, 98, 1999 Free Software Foundation
|
||||||
.\" See section COPYING for conditions for redistribution
|
.\" See section COPYING for conditions for redistribution
|
||||||
.TH objcopy 1 "October 1994" "cygnus support" "GNU Development Tools"
|
.TH objcopy 1 "October 1994" "cygnus support" "GNU Development Tools"
|
||||||
.de BP
|
.de BP
|
||||||
@ -18,6 +18,7 @@ objcopy \- copy and translate object files
|
|||||||
.RB "[\|" \-F\ \fIbfdname\fR\ |\ \fB\-\-target=\fIbfdname\fR "\|]"
|
.RB "[\|" \-F\ \fIbfdname\fR\ |\ \fB\-\-target=\fIbfdname\fR "\|]"
|
||||||
.RB "[\|" \-I\ \fIbfdname\fR\ |\ \fB\-\-input\-target=\fIbfdname\fR "\|]"
|
.RB "[\|" \-I\ \fIbfdname\fR\ |\ \fB\-\-input\-target=\fIbfdname\fR "\|]"
|
||||||
.RB "[\|" \-O\ \fIbfdname\fR\ |\ \fB\-\-output\-target=\fIbfdname\fR "\|]"
|
.RB "[\|" \-O\ \fIbfdname\fR\ |\ \fB\-\-output\-target=\fIbfdname\fR "\|]"
|
||||||
|
.RB "[\|" \-j\ \fIsectionname\fR\ |\ \fB\-\-only\-section=\fIsectionname\fR "\|]"
|
||||||
.RB "[\|" \-R\ \fIsectionname\fR\ |\ \fB\-\-remove\-section=\fIsectionname\fR "\|]"
|
.RB "[\|" \-R\ \fIsectionname\fR\ |\ \fB\-\-remove\-section=\fIsectionname\fR "\|]"
|
||||||
.RB "[\|" \-S\fR\ |\ \fB\-\-strip\-all\fR "\|]"
|
.RB "[\|" \-S\fR\ |\ \fB\-\-strip\-all\fR "\|]"
|
||||||
.RB "[\|" \-g\fR\ |\ \fB\-\-strip\-debug\fR "\|]"
|
.RB "[\|" \-g\fR\ |\ \fB\-\-strip\-debug\fR "\|]"
|
||||||
@ -123,6 +124,12 @@ Use
|
|||||||
as the object format for both the input and the output file; i.e.
|
as the object format for both the input and the output file; i.e.
|
||||||
simply transfer data from source to destination with no translation.
|
simply transfer data from source to destination with no translation.
|
||||||
.TP
|
.TP
|
||||||
|
.B \-j \fIsectionname\fR, \fB\-\-only\-section=\fIsectionname
|
||||||
|
Copy only the named section from the input file to the output file,
|
||||||
|
discarding all other sections. This option may be given more than
|
||||||
|
once. Note that using this option inappropriately may make the output
|
||||||
|
file unusable.
|
||||||
|
.TP
|
||||||
.B \-R \fIsectionname\fR, \fB\-\-remove-section=\fIsectionname
|
.B \-R \fIsectionname\fR, \fB\-\-remove-section=\fIsectionname
|
||||||
Remove the named section from the file. This option may be given more
|
Remove the named section from the file. This option may be given more
|
||||||
than once. Note that using this option inappropriately may make the
|
than once. Note that using this option inappropriately may make the
|
||||||
@ -301,7 +308,7 @@ The GNU Binary Utilities\c
|
|||||||
\&, Roland H. Pesch (June 1993).
|
\&, Roland H. Pesch (June 1993).
|
||||||
|
|
||||||
.SH COPYING
|
.SH COPYING
|
||||||
Copyright (c) 1993, 94, 95, 96, 1997 Free Software Foundation, Inc.
|
Copyright (c) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
|
||||||
.PP
|
.PP
|
||||||
Permission is granted to make and distribute verbatim copies of
|
Permission is granted to make and distribute verbatim copies of
|
||||||
this manual provided the copyright notice and this permission notice
|
this manual provided the copyright notice and this permission notice
|
||||||
|
@ -111,6 +111,7 @@ struct section_list
|
|||||||
const char * name; /* Section name. */
|
const char * name; /* Section name. */
|
||||||
boolean used; /* Whether this entry was used. */
|
boolean used; /* Whether this entry was used. */
|
||||||
boolean remove; /* Whether to remove this section. */
|
boolean remove; /* Whether to remove this section. */
|
||||||
|
boolean copy; /* Whether to copy this section. */
|
||||||
enum change_action change_vma;/* Whether to change or set VMA. */
|
enum change_action change_vma;/* Whether to change or set VMA. */
|
||||||
bfd_vma vma_val; /* Amount to change by or set to. */
|
bfd_vma vma_val; /* Amount to change by or set to. */
|
||||||
enum change_action change_lma;/* Whether to change or set LMA. */
|
enum change_action change_lma;/* Whether to change or set LMA. */
|
||||||
@ -121,6 +122,7 @@ struct section_list
|
|||||||
|
|
||||||
static struct section_list *change_sections;
|
static struct section_list *change_sections;
|
||||||
static boolean sections_removed;
|
static boolean sections_removed;
|
||||||
|
static boolean sections_copied;
|
||||||
|
|
||||||
/* Changes to the start address. */
|
/* Changes to the start address. */
|
||||||
static bfd_vma change_start = 0;
|
static bfd_vma change_start = 0;
|
||||||
@ -246,6 +248,7 @@ static struct option copy_options[] =
|
|||||||
{"debugging", no_argument, 0, OPTION_DEBUGGING},
|
{"debugging", no_argument, 0, OPTION_DEBUGGING},
|
||||||
{"discard-all", no_argument, 0, 'x'},
|
{"discard-all", no_argument, 0, 'x'},
|
||||||
{"discard-locals", no_argument, 0, 'X'},
|
{"discard-locals", no_argument, 0, 'X'},
|
||||||
|
{"only-section", required_argument, 0, 'j'},
|
||||||
{"format", required_argument, 0, 'F'}, /* Obsolete */
|
{"format", required_argument, 0, 'F'}, /* Obsolete */
|
||||||
{"gap-fill", required_argument, 0, OPTION_GAP_FILL},
|
{"gap-fill", required_argument, 0, OPTION_GAP_FILL},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
@ -292,10 +295,12 @@ copy_usage (stream, exit_status)
|
|||||||
{
|
{
|
||||||
fprintf (stream, _("\
|
fprintf (stream, _("\
|
||||||
Usage: %s [-vVSpgxX] [-I bfdname] [-O bfdname] [-F bfdname] [-b byte]\n\
|
Usage: %s [-vVSpgxX] [-I bfdname] [-O bfdname] [-F bfdname] [-b byte]\n\
|
||||||
[-R section] [-i interleave] [--interleave=interleave] [--byte=byte]\n\
|
[-j section] [-R section]\n\
|
||||||
|
[-i interleave] [--interleave=interleave] [--byte=byte]\n\
|
||||||
[--input-target=bfdname] [--output-target=bfdname] [--target=bfdname]\n\
|
[--input-target=bfdname] [--output-target=bfdname] [--target=bfdname]\n\
|
||||||
[--strip-all] [--strip-debug] [--strip-unneeded] [--discard-all]\n\
|
[--strip-all] [--strip-debug] [--strip-unneeded] [--discard-all]\n\
|
||||||
[--discard-locals] [--debugging] [--remove-section=section]\n"),
|
[--discard-locals] [--debugging]\n\
|
||||||
|
[--only-section=section] [--remove-section=section]\n"),
|
||||||
program_name);
|
program_name);
|
||||||
fprintf (stream, _("\
|
fprintf (stream, _("\
|
||||||
[--gap-fill=val] [--pad-to=address] [--preserve-dates]\n\
|
[--gap-fill=val] [--pad-to=address] [--preserve-dates]\n\
|
||||||
@ -411,6 +416,7 @@ find_section_list (name, add)
|
|||||||
p->name = name;
|
p->name = name;
|
||||||
p->used = false;
|
p->used = false;
|
||||||
p->remove = false;
|
p->remove = false;
|
||||||
|
p->copy = false;
|
||||||
p->change_vma = CHANGE_IGNORE;
|
p->change_vma = CHANGE_IGNORE;
|
||||||
p->change_lma = CHANGE_IGNORE;
|
p->change_lma = CHANGE_IGNORE;
|
||||||
p->vma_val = 0;
|
p->vma_val = 0;
|
||||||
@ -474,10 +480,15 @@ is_strip_section (abfd, sec)
|
|||||||
|| convert_debugging))
|
|| convert_debugging))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (! sections_removed)
|
if (! sections_removed && ! sections_copied)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
p = find_section_list (bfd_get_section_name (abfd, sec), false);
|
p = find_section_list (bfd_get_section_name (abfd, sec), false);
|
||||||
return p != NULL && p->remove ? true : false;
|
if (sections_removed && p != NULL && p->remove)
|
||||||
|
return true;
|
||||||
|
if (sections_copied && (p == NULL || ! p->copy))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Choose which symbol entries to copy; put the result in OSYMS.
|
/* Choose which symbol entries to copy; put the result in OSYMS.
|
||||||
@ -816,6 +827,7 @@ copy_object (ibfd, obfd)
|
|||||||
|| localize_specific_list != NULL
|
|| localize_specific_list != NULL
|
||||||
|| weaken_specific_list != NULL
|
|| weaken_specific_list != NULL
|
||||||
|| sections_removed
|
|| sections_removed
|
||||||
|
|| sections_copied
|
||||||
|| convert_debugging
|
|| convert_debugging
|
||||||
|| change_leading_char
|
|| change_leading_char
|
||||||
|| remove_leading_char
|
|| remove_leading_char
|
||||||
@ -1127,7 +1139,9 @@ setup_section (ibfd, isection, obfdarg)
|
|||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
p->used = true;
|
p->used = true;
|
||||||
|
|
||||||
if (p != NULL && p->remove)
|
if (sections_removed && p != NULL && p->remove)
|
||||||
|
return;
|
||||||
|
if (sections_copied && (p == NULL || ! p->copy))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
osection = bfd_make_section_anyway (obfd, bfd_section_name (ibfd, isection));
|
osection = bfd_make_section_anyway (obfd, bfd_section_name (ibfd, isection));
|
||||||
@ -1256,7 +1270,9 @@ copy_section (ibfd, isection, obfdarg)
|
|||||||
|
|
||||||
p = find_section_list (bfd_section_name (ibfd, isection), false);
|
p = find_section_list (bfd_section_name (ibfd, isection), false);
|
||||||
|
|
||||||
if (p != NULL && p->remove)
|
if (sections_removed && p != NULL && p->remove)
|
||||||
|
return;
|
||||||
|
if (sections_copied && (p == NULL || ! p->copy))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
osection = isection->output_section;
|
osection = isection->output_section;
|
||||||
@ -1657,7 +1673,7 @@ copy_main (argc, argv)
|
|||||||
struct section_list *p;
|
struct section_list *p;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
while ((c = getopt_long (argc, argv, "b:i:I:K:N:s:O:d:F:L:R:SpgxXVvW:",
|
while ((c = getopt_long (argc, argv, "b:i:I:j:K:N:s:O:d:F:L:R:SpgxXVvW:",
|
||||||
copy_options, (int *) 0)) != EOF)
|
copy_options, (int *) 0)) != EOF)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
@ -1683,8 +1699,17 @@ copy_main (argc, argv)
|
|||||||
case 'F':
|
case 'F':
|
||||||
input_target = output_target = optarg;
|
input_target = output_target = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'j':
|
||||||
|
p = find_section_list (optarg, true);
|
||||||
|
if (p->remove)
|
||||||
|
fatal (_("%s both copied and removed"), optarg);
|
||||||
|
p->copy = true;
|
||||||
|
sections_copied = true;
|
||||||
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
p = find_section_list (optarg, true);
|
p = find_section_list (optarg, true);
|
||||||
|
if (p->copy)
|
||||||
|
fatal (_("%s both copied and removed"), optarg);
|
||||||
p->remove = true;
|
p->remove = true;
|
||||||
sections_removed = true;
|
sections_removed = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user