binutils/
* doc/binutils.texi (objcopy): Add --strip-dwo, --extract-dwo options. (strip): Add --strip-dwo option. * objcopy.c (enum strip_action): Add STRIP_DWO, STRIP_NONDWO. (enum command_line_switch): Add OPTION_EXTRACT_DWO, OPTION_STRIP_DWO. (strip_options): Add --strip-dwo option. (copy_options): Add --extract-dwo, --strip-dwo options. (copy_usage): Likewise. (strip_usage): Add --strip-dwo option. (is_dwo_section): New function. (is_strip_section_1): Check for DWO sections. (copy_object): Check for --strip-dwo, --extract-dwo options. (copy_relocations_in_section): Discard relocations for DWO sections. Discard entire relocation section when no relocations. (strip_main): Add --strip-dwo option. (copy_main): Add --strip-dwo, --extract-dwo options.
This commit is contained in:
parent
2d16d28e5c
commit
96109726a4
|
@ -1,3 +1,21 @@
|
||||||
|
2012-05-08 Cary Coutant <ccoutant@google.com>
|
||||||
|
|
||||||
|
* doc/binutils.texi (objcopy): Add --strip-dwo, --extract-dwo options.
|
||||||
|
(strip): Add --strip-dwo option.
|
||||||
|
* objcopy.c (enum strip_action): Add STRIP_DWO, STRIP_NONDWO.
|
||||||
|
(enum command_line_switch): Add OPTION_EXTRACT_DWO, OPTION_STRIP_DWO.
|
||||||
|
(strip_options): Add --strip-dwo option.
|
||||||
|
(copy_options): Add --extract-dwo, --strip-dwo options.
|
||||||
|
(copy_usage): Likewise.
|
||||||
|
(strip_usage): Add --strip-dwo option.
|
||||||
|
(is_dwo_section): New function.
|
||||||
|
(is_strip_section_1): Check for DWO sections.
|
||||||
|
(copy_object): Check for --strip-dwo, --extract-dwo options.
|
||||||
|
(copy_relocations_in_section): Discard relocations for DWO sections.
|
||||||
|
Discard entire relocation section when no relocations.
|
||||||
|
(strip_main): Add --strip-dwo option.
|
||||||
|
(copy_main): Add --strip-dwo, --extract-dwo options.
|
||||||
|
|
||||||
2012-05-08 Alan Modra <amodra@gmail.com>
|
2012-05-08 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* Makefile.am (check_DEJAGNU): Export LC_ALL=C in place of other
|
* Makefile.am (check_DEJAGNU): Export LC_ALL=C in place of other
|
||||||
|
|
|
@ -1094,6 +1094,8 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
|
||||||
[@option{--add-gnu-debuglink=}@var{path-to-file}]
|
[@option{--add-gnu-debuglink=}@var{path-to-file}]
|
||||||
[@option{--keep-file-symbols}]
|
[@option{--keep-file-symbols}]
|
||||||
[@option{--only-keep-debug}]
|
[@option{--only-keep-debug}]
|
||||||
|
[@option{--strip-dwo}]
|
||||||
|
[@option{--extract-dwo}]
|
||||||
[@option{--extract-symbol}]
|
[@option{--extract-symbol}]
|
||||||
[@option{--writable-text}]
|
[@option{--writable-text}]
|
||||||
[@option{--readonly-text}]
|
[@option{--readonly-text}]
|
||||||
|
@ -1664,6 +1666,21 @@ currently only supports the presence of one filename containing
|
||||||
debugging information, not multiple filenames on a one-per-object-file
|
debugging information, not multiple filenames on a one-per-object-file
|
||||||
basis.
|
basis.
|
||||||
|
|
||||||
|
@item --strip-dwo
|
||||||
|
Remove the contents of all DWARF .dwo sections, leaving the
|
||||||
|
remaining debugging sections and all symbols intact.
|
||||||
|
This option is intended for use by the compiler as part of
|
||||||
|
the @option{-gsplit-dwarf} option, which splits debug information
|
||||||
|
between the .o file and a separate .dwo file. The compiler
|
||||||
|
generates all debug information in the same file, then uses
|
||||||
|
the @option{--extract-dwo} option to copy the .dwo sections to
|
||||||
|
the .dwo file, then the @option{--strip-dwo} option to remove
|
||||||
|
those sections from the original .o file.
|
||||||
|
|
||||||
|
@item --extract-dwo
|
||||||
|
Extract the contents of all DWARF .dwo sections. See the
|
||||||
|
@option{--strip-dwo} option for more information.
|
||||||
|
|
||||||
@item --file-alignment @var{num}
|
@item --file-alignment @var{num}
|
||||||
Specify the file alignment. Sections in the file will always begin at
|
Specify the file alignment. Sections in the file will always begin at
|
||||||
file offsets which are multiples of this number. This defaults to
|
file offsets which are multiples of this number. This defaults to
|
||||||
|
@ -2680,6 +2697,7 @@ strip [@option{-F} @var{bfdname} |@option{--target=}@var{bfdname}]
|
||||||
[@option{-O} @var{bfdname} |@option{--output-target=}@var{bfdname}]
|
[@option{-O} @var{bfdname} |@option{--output-target=}@var{bfdname}]
|
||||||
[@option{-s}|@option{--strip-all}]
|
[@option{-s}|@option{--strip-all}]
|
||||||
[@option{-S}|@option{-g}|@option{-d}|@option{--strip-debug}]
|
[@option{-S}|@option{-g}|@option{-d}|@option{--strip-debug}]
|
||||||
|
[@option{--strip-dwo}]
|
||||||
[@option{-K} @var{symbolname} |@option{--keep-symbol=}@var{symbolname}]
|
[@option{-K} @var{symbolname} |@option{--keep-symbol=}@var{symbolname}]
|
||||||
[@option{-N} @var{symbolname} |@option{--strip-symbol=}@var{symbolname}]
|
[@option{-N} @var{symbolname} |@option{--strip-symbol=}@var{symbolname}]
|
||||||
[@option{-w}|@option{--wildcard}]
|
[@option{-w}|@option{--wildcard}]
|
||||||
|
@ -2748,6 +2766,12 @@ Remove all symbols.
|
||||||
@itemx --strip-debug
|
@itemx --strip-debug
|
||||||
Remove debugging symbols only.
|
Remove debugging symbols only.
|
||||||
|
|
||||||
|
@item --strip-dwo
|
||||||
|
Remove the contents of all DWARF .dwo sections, leaving the
|
||||||
|
remaining debugging sections and all symbols intact.
|
||||||
|
See the description of this option in the @command{objcopy} section
|
||||||
|
for more information.
|
||||||
|
|
||||||
@item --strip-unneeded
|
@item --strip-unneeded
|
||||||
Remove all symbols that are not needed for relocation processing.
|
Remove all symbols that are not needed for relocation processing.
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,8 @@ enum strip_action
|
||||||
STRIP_DEBUG, /* Strip all debugger symbols. */
|
STRIP_DEBUG, /* Strip all debugger symbols. */
|
||||||
STRIP_UNNEEDED, /* Strip unnecessary symbols. */
|
STRIP_UNNEEDED, /* Strip unnecessary symbols. */
|
||||||
STRIP_NONDEBUG, /* Strip everything but debug info. */
|
STRIP_NONDEBUG, /* Strip everything but debug info. */
|
||||||
|
STRIP_DWO, /* Strip all DWO info. */
|
||||||
|
STRIP_NONDWO, /* Strip everything but DWO info. */
|
||||||
STRIP_ALL /* Strip all symbols. */
|
STRIP_ALL /* Strip all symbols. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -314,7 +316,9 @@ enum command_line_switch
|
||||||
OPTION_SECTION_ALIGNMENT,
|
OPTION_SECTION_ALIGNMENT,
|
||||||
OPTION_STACK,
|
OPTION_STACK,
|
||||||
OPTION_INTERLEAVE_WIDTH,
|
OPTION_INTERLEAVE_WIDTH,
|
||||||
OPTION_SUBSYSTEM
|
OPTION_SUBSYSTEM,
|
||||||
|
OPTION_EXTRACT_DWO,
|
||||||
|
OPTION_STRIP_DWO
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Options to handle if running as "strip". */
|
/* Options to handle if running as "strip". */
|
||||||
|
@ -339,6 +343,7 @@ static struct option strip_options[] =
|
||||||
{"remove-section", required_argument, 0, 'R'},
|
{"remove-section", required_argument, 0, 'R'},
|
||||||
{"strip-all", no_argument, 0, 's'},
|
{"strip-all", no_argument, 0, 's'},
|
||||||
{"strip-debug", no_argument, 0, 'S'},
|
{"strip-debug", no_argument, 0, 'S'},
|
||||||
|
{"strip-dwo", no_argument, 0, OPTION_STRIP_DWO},
|
||||||
{"strip-unneeded", no_argument, 0, OPTION_STRIP_UNNEEDED},
|
{"strip-unneeded", no_argument, 0, OPTION_STRIP_UNNEEDED},
|
||||||
{"strip-symbol", required_argument, 0, 'N'},
|
{"strip-symbol", required_argument, 0, 'N'},
|
||||||
{"target", required_argument, 0, 'F'},
|
{"target", required_argument, 0, 'F'},
|
||||||
|
@ -374,6 +379,7 @@ static struct option copy_options[] =
|
||||||
{"discard-all", no_argument, 0, 'x'},
|
{"discard-all", no_argument, 0, 'x'},
|
||||||
{"discard-locals", no_argument, 0, 'X'},
|
{"discard-locals", no_argument, 0, 'X'},
|
||||||
{"enable-deterministic-archives", no_argument, 0, 'D'},
|
{"enable-deterministic-archives", no_argument, 0, 'D'},
|
||||||
|
{"extract-dwo", no_argument, 0, OPTION_EXTRACT_DWO},
|
||||||
{"extract-symbol", no_argument, 0, OPTION_EXTRACT_SYMBOL},
|
{"extract-symbol", no_argument, 0, OPTION_EXTRACT_SYMBOL},
|
||||||
{"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},
|
||||||
|
@ -420,6 +426,7 @@ static struct option copy_options[] =
|
||||||
{"srec-forceS3", no_argument, 0, OPTION_SREC_FORCES3},
|
{"srec-forceS3", no_argument, 0, OPTION_SREC_FORCES3},
|
||||||
{"strip-all", no_argument, 0, 'S'},
|
{"strip-all", no_argument, 0, 'S'},
|
||||||
{"strip-debug", no_argument, 0, 'g'},
|
{"strip-debug", no_argument, 0, 'g'},
|
||||||
|
{"strip-dwo", no_argument, 0, OPTION_STRIP_DWO},
|
||||||
{"strip-unneeded", no_argument, 0, OPTION_STRIP_UNNEEDED},
|
{"strip-unneeded", no_argument, 0, OPTION_STRIP_UNNEEDED},
|
||||||
{"strip-unneeded-symbol", required_argument, 0, OPTION_STRIP_UNNEEDED_SYMBOL},
|
{"strip-unneeded-symbol", required_argument, 0, OPTION_STRIP_UNNEEDED_SYMBOL},
|
||||||
{"strip-unneeded-symbols", required_argument, 0, OPTION_STRIP_UNNEEDED_SYMBOLS},
|
{"strip-unneeded-symbols", required_argument, 0, OPTION_STRIP_UNNEEDED_SYMBOLS},
|
||||||
|
@ -490,12 +497,14 @@ copy_usage (FILE *stream, int exit_status)
|
||||||
-R --remove-section <name> Remove section <name> from the output\n\
|
-R --remove-section <name> Remove section <name> from the output\n\
|
||||||
-S --strip-all Remove all symbol and relocation information\n\
|
-S --strip-all Remove all symbol and relocation information\n\
|
||||||
-g --strip-debug Remove all debugging symbols & sections\n\
|
-g --strip-debug Remove all debugging symbols & sections\n\
|
||||||
|
--strip-dwo Remove all DWO sections\n\
|
||||||
--strip-unneeded Remove all symbols not needed by relocations\n\
|
--strip-unneeded Remove all symbols not needed by relocations\n\
|
||||||
-N --strip-symbol <name> Do not copy symbol <name>\n\
|
-N --strip-symbol <name> Do not copy symbol <name>\n\
|
||||||
--strip-unneeded-symbol <name>\n\
|
--strip-unneeded-symbol <name>\n\
|
||||||
Do not copy symbol <name> unless needed by\n\
|
Do not copy symbol <name> unless needed by\n\
|
||||||
relocations\n\
|
relocations\n\
|
||||||
--only-keep-debug Strip everything but the debug information\n\
|
--only-keep-debug Strip everything but the debug information\n\
|
||||||
|
--extract-dwo Copy only DWO sections\n\
|
||||||
--extract-symbol Remove section contents but keep symbols\n\
|
--extract-symbol Remove section contents but keep symbols\n\
|
||||||
-K --keep-symbol <name> Do not strip symbol <name>\n\
|
-K --keep-symbol <name> Do not strip symbol <name>\n\
|
||||||
--keep-file-symbols Do not strip file symbol(s)\n\
|
--keep-file-symbols Do not strip file symbol(s)\n\
|
||||||
|
@ -598,6 +607,7 @@ strip_usage (FILE *stream, int exit_status)
|
||||||
-R --remove-section=<name> Remove section <name> from the output\n\
|
-R --remove-section=<name> Remove section <name> from the output\n\
|
||||||
-s --strip-all Remove all symbol and relocation information\n\
|
-s --strip-all Remove all symbol and relocation information\n\
|
||||||
-g -S -d --strip-debug Remove all debugging symbols & sections\n\
|
-g -S -d --strip-debug Remove all debugging symbols & sections\n\
|
||||||
|
--strip-dwo Remove all DWO sections\n\
|
||||||
--strip-unneeded Remove all symbols not needed by relocations\n\
|
--strip-unneeded Remove all symbols not needed by relocations\n\
|
||||||
--only-keep-debug Strip everything but the debug information\n\
|
--only-keep-debug Strip everything but the debug information\n\
|
||||||
-N --strip-symbol=<name> Do not copy symbol <name>\n\
|
-N --strip-symbol=<name> Do not copy symbol <name>\n\
|
||||||
|
@ -932,6 +942,17 @@ group_signature (asection *group)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return TRUE if the section is a DWO section. */
|
||||||
|
|
||||||
|
static bfd_boolean
|
||||||
|
is_dwo_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
|
||||||
|
{
|
||||||
|
const char *name = bfd_get_section_name (abfd, sec);
|
||||||
|
int len = strlen (name);
|
||||||
|
|
||||||
|
return strncmp (name + len - 4, ".dwo", 4) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* See if a non-group section is being removed. */
|
/* See if a non-group section is being removed. */
|
||||||
|
|
||||||
static bfd_boolean
|
static bfd_boolean
|
||||||
|
@ -958,10 +979,16 @@ is_strip_section_1 (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
|
||||||
|| convert_debugging)
|
|| convert_debugging)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
if (strip_symbols == STRIP_DWO)
|
||||||
|
return is_dwo_section (abfd, sec);
|
||||||
|
|
||||||
if (strip_symbols == STRIP_NONDEBUG)
|
if (strip_symbols == STRIP_NONDEBUG)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strip_symbols == STRIP_NONDWO)
|
||||||
|
return !is_dwo_section (abfd, sec);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1849,6 +1876,8 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
|
||||||
|| strip_symbols == STRIP_ALL
|
|| strip_symbols == STRIP_ALL
|
||||||
|| strip_symbols == STRIP_UNNEEDED
|
|| strip_symbols == STRIP_UNNEEDED
|
||||||
|| strip_symbols == STRIP_NONDEBUG
|
|| strip_symbols == STRIP_NONDEBUG
|
||||||
|
|| strip_symbols == STRIP_DWO
|
||||||
|
|| strip_symbols == STRIP_NONDWO
|
||||||
|| discard_locals != LOCALS_UNDEF
|
|| discard_locals != LOCALS_UNDEF
|
||||||
|| localize_hidden
|
|| localize_hidden
|
||||||
|| htab_elements (strip_specific_htab) != 0
|
|| htab_elements (strip_specific_htab) != 0
|
||||||
|
@ -2656,8 +2685,8 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
|
||||||
|
|
||||||
osection = isection->output_section;
|
osection = isection->output_section;
|
||||||
|
|
||||||
/* Core files do not need to be relocated. */
|
/* Core files and DWO files do not need to be relocated. */
|
||||||
if (bfd_get_format (obfd) == bfd_core)
|
if (bfd_get_format (obfd) == bfd_core || strip_symbols == STRIP_NONDWO)
|
||||||
relsize = 0;
|
relsize = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2678,7 +2707,10 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relsize == 0)
|
if (relsize == 0)
|
||||||
bfd_set_reloc (obfd, osection, NULL, 0);
|
{
|
||||||
|
bfd_set_reloc (obfd, osection, NULL, 0);
|
||||||
|
osection->flags &= ~SEC_RELOC;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
relpp = (arelent **) xmalloc (relsize);
|
relpp = (arelent **) xmalloc (relsize);
|
||||||
|
@ -3022,6 +3054,9 @@ strip_main (int argc, char *argv[])
|
||||||
case 'd': /* Historic BSD alias for -g. Used by early NetBSD. */
|
case 'd': /* Historic BSD alias for -g. Used by early NetBSD. */
|
||||||
strip_symbols = STRIP_DEBUG;
|
strip_symbols = STRIP_DEBUG;
|
||||||
break;
|
break;
|
||||||
|
case OPTION_STRIP_DWO:
|
||||||
|
strip_symbols = STRIP_DWO;
|
||||||
|
break;
|
||||||
case OPTION_STRIP_UNNEEDED:
|
case OPTION_STRIP_UNNEEDED:
|
||||||
strip_symbols = STRIP_UNNEEDED;
|
strip_symbols = STRIP_UNNEEDED;
|
||||||
break;
|
break;
|
||||||
|
@ -3352,6 +3387,10 @@ copy_main (int argc, char *argv[])
|
||||||
strip_symbols = STRIP_DEBUG;
|
strip_symbols = STRIP_DEBUG;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPTION_STRIP_DWO:
|
||||||
|
strip_symbols = STRIP_DWO;
|
||||||
|
break;
|
||||||
|
|
||||||
case OPTION_STRIP_UNNEEDED:
|
case OPTION_STRIP_UNNEEDED:
|
||||||
strip_symbols = STRIP_UNNEEDED;
|
strip_symbols = STRIP_UNNEEDED;
|
||||||
break;
|
break;
|
||||||
|
@ -3813,6 +3852,10 @@ copy_main (int argc, char *argv[])
|
||||||
bfd_flags_to_set &= ~D_PAGED;
|
bfd_flags_to_set &= ~D_PAGED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPTION_EXTRACT_DWO:
|
||||||
|
strip_symbols = STRIP_NONDWO;
|
||||||
|
break;
|
||||||
|
|
||||||
case OPTION_EXTRACT_SYMBOL:
|
case OPTION_EXTRACT_SYMBOL:
|
||||||
extract_symbol = TRUE;
|
extract_symbol = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue