@@ -79,11 +79,6 @@ static cl::opt<bool>
7979 cl::desc (" dump Linux kernel static keys jump table" ),
8080 cl::init(false ), cl::Hidden, cl::cat(BoltCategory));
8181
82- static cl::opt<bool > LongJumpLabels (
83- " long-jump-labels" ,
84- cl::desc (" always use long jumps/nops for Linux kernel static keys" ),
85- cl::init(false ), cl::Hidden, cl::cat(BoltCategory));
86-
8782static cl::opt<bool >
8883 PrintORC (" print-orc" ,
8984 cl::desc (" print ORC unwind information for instructions" ),
@@ -237,6 +232,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
237232 // / Static key entries that need nop conversion.
238233 DenseSet<uint32_t > NopIDs;
239234
235+ // / Use long jumps/nops for Linux kernel static keys.
236+ bool LongJumpLabels{false };
237+
240238 // / Section containing static call table.
241239 ErrorOr<BinarySection &> StaticCallSection = std::errc::bad_address;
242240 uint64_t StaticCallTableAddress = 0 ;
@@ -351,6 +349,8 @@ class LinuxKernelRewriter final : public MetadataRewriter {
351349 if (Error E = detectLinuxKernelVersion ())
352350 return E;
353351
352+ LongJumpLabels = LinuxKernelVersion < LKVersion (5 , 14 , 0 );
353+
354354 processLKSections ();
355355
356356 if (Error E = processSMPLocks ())
@@ -1799,13 +1799,13 @@ Error LinuxKernelRewriter::readStaticKeysJumpTable() {
17991799 // the code, it will be converted to a different instruction in
18001800 // rewriteStaticKeysJumpTable().
18011801 //
1802- // NB: for older kernels, under LongJumpLabels option , we create long
1802+ // NB: for older kernels (for which LongJumpLabels is true) , we create long
18031803 // conditional branch to guarantee that code size estimation takes
18041804 // into account the extra bytes needed for long branch that will be used
18051805 // by the kernel patching code. Newer kernels can work with both short
18061806 // and long branches. The code for long conditional branch is larger
18071807 // than unconditional one, so we are pessimistic in our estimations.
1808- if (opts:: LongJumpLabels)
1808+ if (LongJumpLabels)
18091809 BC.MIB ->createLongCondBranch (StaticKeyBranch, Target, 0 , BC.Ctx .get ());
18101810 else
18111811 BC.MIB ->createCondBranch (StaticKeyBranch, Target, 0 , BC.Ctx .get ());
@@ -1832,7 +1832,7 @@ Error LinuxKernelRewriter::readStaticKeysJumpTable() {
18321832 if (!BC.MIB ->getOffset (*Inst))
18331833 BC.MIB ->setOffset (*Inst, JumpAddress - BF->getAddress ());
18341834
1835- if (opts:: LongJumpLabels)
1835+ if (LongJumpLabels)
18361836 BC.MIB ->setSize (*Inst, 5 );
18371837 }
18381838
@@ -1879,7 +1879,7 @@ Error LinuxKernelRewriter::rewriteStaticKeysJumpTable() {
18791879 MCInst NewInst;
18801880 // Replace the instruction with unconditional jump even if it needs to
18811881 // be nop in the binary.
1882- if (opts:: LongJumpLabels) {
1882+ if (LongJumpLabels) {
18831883 BC.MIB ->createLongUncondBranch (NewInst, Target, BC.Ctx .get ());
18841884 } else {
18851885 // Newer kernels can handle short and long jumps for static keys.
0 commit comments