@@ -77,11 +77,6 @@ static cl::opt<bool>
77
77
cl::desc (" dump Linux kernel static keys jump table" ),
78
78
cl::init(false ), cl::Hidden, cl::cat(BoltCategory));
79
79
80
- static cl::opt<bool > LongJumpLabels (
81
- " long-jump-labels" ,
82
- cl::desc (" always use long jumps/nops for Linux kernel static keys" ),
83
- cl::init(false ), cl::Hidden, cl::cat(BoltCategory));
84
-
85
80
static cl::opt<bool >
86
81
PrintORC (" print-orc" ,
87
82
cl::desc (" print ORC unwind information for instructions" ),
@@ -285,11 +280,14 @@ class LinuxKernelRewriter final : public MetadataRewriter {
285
280
Error rewriteStaticKeysJumpTable ();
286
281
Error updateStaticKeysJumpTablePostEmit ();
287
282
283
+ bool LongJumpLabels{false };
288
284
public:
289
285
LinuxKernelRewriter (BinaryContext &BC)
290
286
: MetadataRewriter(" linux-kernel-rewriter" , BC) {}
291
287
292
288
Error preCFGInitializer () override {
289
+ LongJumpLabels = LinuxKernelVersion <= LKVersion (5 , 13 , 19 );
290
+
293
291
processLKSections ();
294
292
295
293
if (Error E = processSMPLocks ())
@@ -1735,13 +1733,13 @@ Error LinuxKernelRewriter::readStaticKeysJumpTable() {
1735
1733
// the code, it will be converted to a different instruction in
1736
1734
// rewriteStaticKeysJumpTable().
1737
1735
//
1738
- // NB: for older kernels, under LongJumpLabels option , we create long
1736
+ // NB: for older kernels (for which LongJumpLabels is true) , we create long
1739
1737
// conditional branch to guarantee that code size estimation takes
1740
1738
// into account the extra bytes needed for long branch that will be used
1741
1739
// by the kernel patching code. Newer kernels can work with both short
1742
1740
// and long branches. The code for long conditional branch is larger
1743
1741
// than unconditional one, so we are pessimistic in our estimations.
1744
- if (opts:: LongJumpLabels)
1742
+ if (LongJumpLabels)
1745
1743
BC.MIB ->createLongCondBranch (StaticKeyBranch, Target, 0 , BC.Ctx .get ());
1746
1744
else
1747
1745
BC.MIB ->createCondBranch (StaticKeyBranch, Target, 0 , BC.Ctx .get ());
@@ -1768,7 +1766,7 @@ Error LinuxKernelRewriter::readStaticKeysJumpTable() {
1768
1766
if (!BC.MIB ->getOffset (*Inst))
1769
1767
BC.MIB ->setOffset (*Inst, JumpAddress - BF->getAddress ());
1770
1768
1771
- if (opts:: LongJumpLabels)
1769
+ if (LongJumpLabels)
1772
1770
BC.MIB ->setSize (*Inst, 5 );
1773
1771
}
1774
1772
@@ -1815,7 +1813,7 @@ Error LinuxKernelRewriter::rewriteStaticKeysJumpTable() {
1815
1813
MCInst NewInst;
1816
1814
// Replace the instruction with unconditional jump even if it needs to
1817
1815
// be nop in the binary.
1818
- if (opts:: LongJumpLabels) {
1816
+ if (LongJumpLabels) {
1819
1817
BC.MIB ->createLongUncondBranch (NewInst, Target, BC.Ctx .get ());
1820
1818
} else {
1821
1819
// Newer kernels can handle short and long jumps for static keys.
0 commit comments