[PATCH] D130071: [BOLT] Adapted policy checks for stripped binaries
Huan Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 28 17:42:22 PDT 2022
nhuhuan updated this revision to Diff 448494.
nhuhuan added a comment.
Updated comment
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130071/new/
https://reviews.llvm.org/D130071
Files:
bolt/lib/Core/BinaryContext.cpp
bolt/lib/Core/BinaryFunction.cpp
Index: bolt/lib/Core/BinaryFunction.cpp
===================================================================
--- bolt/lib/Core/BinaryFunction.cpp
+++ bolt/lib/Core/BinaryFunction.cpp
@@ -1602,10 +1602,10 @@
if (!getSecondaryEntryPointSymbol(Label))
continue;
- // In non-relocation mode there's potentially an external undetectable
- // reference to the entry point and hence we cannot move this entry
- // point. Optimizing without moving could be difficult.
- if (!BC.HasRelocations)
+ // Stripped binaries mostly don't have .rela.text section
+ // Without .rela.text, BOLT cannot reliably move code
+ // Temporarily relax this check for stripped binaries
+ if (!BC.IsStripped && !BC.HasRelocations)
setSimple(false);
const uint32_t Offset = KV.first;
Index: bolt/lib/Core/BinaryContext.cpp
===================================================================
--- bolt/lib/Core/BinaryContext.cpp
+++ bolt/lib/Core/BinaryContext.cpp
@@ -1119,14 +1119,19 @@
bool BinaryContext::registerFragment(BinaryFunction &TargetFunction,
BinaryFunction &Function) const {
- if (!isPotentialFragmentByName(TargetFunction, Function))
+ // Only use symbol name matching for non-stripped binaries
+ if (!IsStripped && !isPotentialFragmentByName(TargetFunction, Function))
return false;
assert(TargetFunction.isFragment() && "TargetFunction must be a fragment");
if (TargetFunction.isParentFragment(&Function))
return true;
TargetFunction.addParentFragment(Function);
Function.addFragment(TargetFunction);
- if (!HasRelocations) {
+
+ // Stripped binaries mostly don't have .rela.text section
+ // Without .rela.text, BOLT cannot reliably move code
+ // Temporarily relax this check for stripped binaries
+ if (!IsStripped && !HasRelocations) {
TargetFunction.setSimple(false);
Function.setSimple(false);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130071.448494.patch
Type: text/x-patch
Size: 1925 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220729/ef701a75/attachment.bin>
More information about the llvm-commits
mailing list