]> granicus.if.org Git - llvm/commit
[llvm-objcopy]Don't implicitly strip sections in segments
authorJames Henderson <jh7370@my.bristol.ac.uk>
Thu, 14 Mar 2019 11:47:41 +0000 (11:47 +0000)
committerJames Henderson <jh7370@my.bristol.ac.uk>
Thu, 14 Mar 2019 11:47:41 +0000 (11:47 +0000)
commitd5ba5901b903e6fa04a632131eedf3101c489c81
tree08d5603cfc5bb7875f6caf3012230692ec2d429d
parentb425d6d63ac80ca6f2a5c5942d48ae0f7b9cefd9
[llvm-objcopy]Don't implicitly strip sections in segments

This patch changes llvm-objcopy's behaviour to not strip sections that
are in segments, if they otherwise would be due to a stripping operation
(--strip-all, --strip-sections, --strip-non-alloc). This preserves the
segment contents. It does not change the behaviour of --strip-all-gnu
(although we could choose to do so), because GNU objcopy's behaviour in
this case seems to be to strip the section, nor does it prevent removing
of sections in segments with --remove-section (if a user REALLY wants to
remove a section, we should probably let them, although I could be
persuaded that warning might be appropriate). Tests have been added to
show this latter behaviour.

This fixes https://bugs.llvm.org/show_bug.cgi?id=41006.

Reviewed by: grimar, rupprecht, jakehehrlich

Differential Revision: https://reviews.llvm.org/D59293

This is a reland of r356129, attempting to fix greendragon failures
due to a suspected compatibility issue with od on the greendragon bots
versus other versions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356136 91177308-0d34-0410-b5e6-96231b3b80d8
test/tools/llvm-objcopy/ELF/remove-section-in-segment.test [new file with mode: 0644]
test/tools/llvm-objcopy/ELF/strip-all-gnu.test
test/tools/llvm-objcopy/ELF/strip-all.test
test/tools/llvm-objcopy/ELF/strip-non-alloc.test
test/tools/llvm-objcopy/ELF/strip-sections.test
tools/llvm-objcopy/ELF/ELFObjcopy.cpp
tools/llvm-objcopy/ObjcopyOpts.td
tools/llvm-objcopy/StripOpts.td