forked from OSchip/llvm-project
[llvm-objcopy][MachO] Remove more sections with llvm-bitcode-strip
This adds the other potential bitcode sections that can exist and should be stripped with `-r` from `llvm-bitcode-strip`. Differential Revision: https://reviews.llvm.org/D132267
This commit is contained in:
parent
065d2e1d8b
commit
d991aa91f1
|
@ -0,0 +1,29 @@
|
|||
# REQUIRES: x86-registered-target
|
||||
|
||||
## Verify llvm-bitcode-strip removes sections from object files
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t
|
||||
# RUN: llvm-bitcode-strip -r %t -o %t2
|
||||
# RUN: llvm-readobj --macho-segment --sections %t2 | FileCheck --implicit-check-not=__LLVM %s
|
||||
|
||||
# CHECK: Name: __text
|
||||
# CHECK-NEXT: Segment: __TEXT
|
||||
|
||||
.section __LLVM,__bundle
|
||||
.asciz "test"
|
||||
|
||||
.section __LLVM,__bitcode
|
||||
.asciz "test"
|
||||
|
||||
.section __LLVM,__cmdline
|
||||
.asciz "test"
|
||||
|
||||
.section __LLVM,__swift_cmdline
|
||||
.asciz "test"
|
||||
|
||||
.section __LLVM,__asm
|
||||
.asciz "test"
|
||||
|
||||
.text
|
||||
.globl _main
|
||||
_main:
|
||||
ret
|
|
@ -1197,8 +1197,16 @@ objcopy::parseBitcodeStripOptions(ArrayRef<const char *> ArgsArr,
|
|||
|
||||
// We only support -r for now, which removes all bitcode sections and
|
||||
// the __LLVM segment if it's now empty.
|
||||
cantFail(Config.ToRemove.addMatcher(NameOrPattern::create(
|
||||
"__LLVM,__asm", MatchStyle::Literal, ErrorCallback)));
|
||||
cantFail(Config.ToRemove.addMatcher(NameOrPattern::create(
|
||||
"__LLVM,__bitcode", MatchStyle::Literal, ErrorCallback)));
|
||||
cantFail(Config.ToRemove.addMatcher(NameOrPattern::create(
|
||||
"__LLVM,__bundle", MatchStyle::Literal, ErrorCallback)));
|
||||
cantFail(Config.ToRemove.addMatcher(NameOrPattern::create(
|
||||
"__LLVM,__cmdline", MatchStyle::Literal, ErrorCallback)));
|
||||
cantFail(Config.ToRemove.addMatcher(NameOrPattern::create(
|
||||
"__LLVM,__swift_cmdline", MatchStyle::Literal, ErrorCallback)));
|
||||
MachOConfig.EmptySegmentsToRemove.insert("__LLVM");
|
||||
|
||||
DC.CopyConfigs.push_back(std::move(ConfigMgr));
|
||||
|
|
Loading…
Reference in New Issue