[PATCH] D142686: [BOLT] Reintroduce allow-stripped

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 6 18:08:32 PST 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc8482da779a9: [BOLT] Reintroduce allow-stripped (authored by Amir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142686

Files:
  bolt/lib/Rewrite/RewriteInstance.cpp
  bolt/test/X86/broken_dynsym.test
  bolt/test/X86/is-strip.s


Index: bolt/test/X86/is-strip.s
===================================================================
--- bolt/test/X86/is-strip.s
+++ bolt/test/X86/is-strip.s
@@ -4,7 +4,8 @@
 # RUN: llvm-bolt %t -o %t.out 2>&1 | FileCheck %s -check-prefix=CHECK-NOSTRIP
 # RUN: cp %t %t.stripped
 # RUN: llvm-strip -s %t.stripped
-# RUN: llvm-bolt %t.stripped -o %t.out 2>&1 | FileCheck %s -check-prefix=CHECK-STRIP
+# RUN: not llvm-bolt %t.stripped -o %t.out 2>&1 | FileCheck %s -check-prefix=CHECK-STRIP
+# RUN: llvm-bolt %t.stripped -o %t.out --allow-stripped 2>&1 | FileCheck %s -check-prefix=CHECK-NOSTRIP
 
-# CHECK-NOSTRIP-NOT: BOLT-INFO: input binary is stripped. The support is limited and is considered experimental.
-# CHECK-STRIP: BOLT-INFO: input binary is stripped. The support is limited and is considered experimental.
+# CHECK-NOSTRIP-NOT: BOLT-ERROR: stripped binaries are not supported.
+# CHECK-STRIP: BOLT-ERROR: stripped binaries are not supported.
Index: bolt/test/X86/broken_dynsym.test
===================================================================
--- bolt/test/X86/broken_dynsym.test
+++ bolt/test/X86/broken_dynsym.test
@@ -3,6 +3,6 @@
 
 # RUN: yaml2obj %p/Inputs/broken_dynsym.yaml -o %t
 # RUN: llvm-strip -s %t
-# RUN: llvm-bolt %t -o %t.bolt | FileCheck %s
+# RUN: llvm-bolt %t -o %t.bolt --allow-stripped | FileCheck %s
 
 # CHECK-NOT: section index out of bounds 
Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -82,6 +82,10 @@
 extern cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions;
 extern cl::opt<bool> TimeBuild;
 
+cl::opt<bool> AllowStripped("allow-stripped",
+                            cl::desc("allow processing of stripped binaries"),
+                            cl::Hidden, cl::cat(BoltCategory));
+
 static cl::opt<bool> ForceToDataRelocations(
     "force-data-relocations",
     cl::desc("force relocations to data sections to always be processed"),
@@ -1662,6 +1666,12 @@
 
   BC->IsStripped = !HasSymbolTable;
 
+  if (BC->IsStripped && !opts::AllowStripped) {
+    errs() << "BOLT-ERROR: stripped binaries are not supported. If you know "
+              "what you're doing, use --allow-stripped to proceed";
+    exit(1);
+  }
+
   // Force non-relocation mode for heatmap generation
   if (opts::HeatmapMode)
     BC->HasRelocations = false;
@@ -1670,10 +1680,6 @@
     outs() << "BOLT-INFO: enabling " << (opts::StrictMode ? "strict " : "")
            << "relocation mode\n";
 
-  if (BC->IsStripped)
-    outs() << "BOLT-INFO: input binary is stripped. The support is limited and "
-           << "is considered experimental.\n";
-
   // Read EH frame for function boundaries info.
   Expected<const DWARFDebugFrame *> EHFrameOrError = BC->DwCtx->getEHFrame();
   if (!EHFrameOrError)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142686.495342.patch
Type: text/x-patch
Size: 2895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230207/9ae09f49/attachment.bin>


More information about the llvm-commits mailing list