[PATCH] D132267: [llvm-objcopy][MachO] Remove more sections with llvm-bitcode-strip

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 16:09:23 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd991aa91f1bd: [llvm-objcopy][MachO] Remove more sections with llvm-bitcode-strip (authored by keith).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132267/new/

https://reviews.llvm.org/D132267

Files:
  llvm/test/tools/llvm-objcopy/MachO/bitcode-strip-object.s
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp


Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===================================================================
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -1197,8 +1197,16 @@
 
   // 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));
Index: llvm/test/tools/llvm-objcopy/MachO/bitcode-strip-object.s
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objcopy/MachO/bitcode-strip-object.s
@@ -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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132267.454645.patch
Type: text/x-patch
Size: 1963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220822/3d8d3362/attachment.bin>


More information about the llvm-commits mailing list