diff options
author | Alan Modra <amodra@gmail.com> | 2018-09-10 11:57:08 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2018-09-10 13:46:37 +0930 |
commit | f9853190c8d90e9f7d43fae90478a0db291f9c03 (patch) | |
tree | abf8f9fd17f8bf6192349e1644ebef00572effe7 /binutils/doc | |
parent | 78f8307c93755eb581c20ba049f1b092f161d513 (diff) | |
download | gdb-f9853190c8d90e9f7d43fae90478a0db291f9c03.zip gdb-f9853190c8d90e9f7d43fae90478a0db291f9c03.tar.gz gdb-f9853190c8d90e9f7d43fae90478a0db291f9c03.tar.bz2 |
PR23611, objcopy is not removing executable relocatable sections
BFD handles ELF relocation sections in an executable differently to
relocation sections in a relocatable object. For a relocatable
object, BFD carries the relocations as data associated with the
section to which they apply; The relocation section doesn't appear as
a separate section. For an executable, dynamic relocation sections do
appear as separate sections. This means that objcopy needs to use
different strategies when dealing with relocations.
When --remove-relocations was added to objcopy with commit
d3e5f6c8f1e, objcopy lost the ability to remove dynamic relocation
sections such as .rela.plt from executables using the option
"--remove-section=.rela.plt". This patch reinstates that
functionality.
I thought it best to keep --remove-relocations as is, rather than
extending to handle dynamic relocations as per the patch in the PR,
because executables linked with --emit-relocs may have both dynamic
and non-dynamic relocations. In that case --remove-relocataions=* is
useful to remove all the non-dynamic relocations.
PR binutils/23611
* objcopy.c (handle_remove_section_option): Consider .rela and
.rel sections for stripping directly as well as attached to the
associated section they relocate.
* doc/binutils.texi (remove-relocations): Specify that this
option removes non-dynamic relocation sections.
* testsuite/binutils-all/objcopy.exp
(objcopy_remove_relocations_from_executable): New test.
Diffstat (limited to 'binutils/doc')
-rw-r--r-- | binutils/doc/binutils.texi | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index e40ccb0..76cbed0 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -1321,17 +1321,20 @@ will remove all sections matching the pattern '.text.*', but will not remove the section '.text.foo'. @item --remove-relocations=@var{sectionpattern} -Remove relocations from the output file for any section matching -@var{sectionpattern}. 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}. +Remove non-dynamic relocations from the output file for any section +matching @var{sectionpattern}. This option may be given more than +once. Note that using this option inappropriately may make the output +file unusable, and attempting to remove a dynamic relocation section +such as @samp{.rela.plt} from an executable or shared library with +@option{--remove-relocations=.plt} will not work. Wildcard characters +are accepted in @var{sectionpattern}. For example: @smallexample --remove-relocations=.text.* @end smallexample -will remove the relocations for all sections matching the patter +will remove the relocations for all sections matching the pattern '.text.*'. If the first character of @var{sectionpattern} is the exclamation |