Skip to content

Commit b39801f

Browse files
authored
[BOLT][Linux] Remove long-jump-labels option
1 parent fbc18b8 commit b39801f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

bolt/lib/Rewrite/LinuxKernelRewriter.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ static cl::opt<bool>
7777
cl::desc("dump Linux kernel static keys jump table"),
7878
cl::init(false), cl::Hidden, cl::cat(BoltCategory));
7979

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-
8580
static cl::opt<bool>
8681
PrintORC("print-orc",
8782
cl::desc("print ORC unwind information for instructions"),
@@ -285,11 +280,14 @@ class LinuxKernelRewriter final : public MetadataRewriter {
285280
Error rewriteStaticKeysJumpTable();
286281
Error updateStaticKeysJumpTablePostEmit();
287282

283+
bool LongJumpLabels{false};
288284
public:
289285
LinuxKernelRewriter(BinaryContext &BC)
290286
: MetadataRewriter("linux-kernel-rewriter", BC) {}
291287

292288
Error preCFGInitializer() override {
289+
LongJumpLabels = LinuxKernelVersion <= LKVersion(5, 13, 19);
290+
293291
processLKSections();
294292

295293
if (Error E = processSMPLocks())
@@ -1735,13 +1733,13 @@ Error LinuxKernelRewriter::readStaticKeysJumpTable() {
17351733
// the code, it will be converted to a different instruction in
17361734
// rewriteStaticKeysJumpTable().
17371735
//
1738-
// NB: for older kernels, under LongJumpLabels option, we create long
1736+
// NB: for older kernels (for which LongJumpLabels is true), we create long
17391737
// conditional branch to guarantee that code size estimation takes
17401738
// into account the extra bytes needed for long branch that will be used
17411739
// by the kernel patching code. Newer kernels can work with both short
17421740
// and long branches. The code for long conditional branch is larger
17431741
// than unconditional one, so we are pessimistic in our estimations.
1744-
if (opts::LongJumpLabels)
1742+
if (LongJumpLabels)
17451743
BC.MIB->createLongCondBranch(StaticKeyBranch, Target, 0, BC.Ctx.get());
17461744
else
17471745
BC.MIB->createCondBranch(StaticKeyBranch, Target, 0, BC.Ctx.get());
@@ -1768,7 +1766,7 @@ Error LinuxKernelRewriter::readStaticKeysJumpTable() {
17681766
if (!BC.MIB->getOffset(*Inst))
17691767
BC.MIB->setOffset(*Inst, JumpAddress - BF->getAddress());
17701768

1771-
if (opts::LongJumpLabels)
1769+
if (LongJumpLabels)
17721770
BC.MIB->setSize(*Inst, 5);
17731771
}
17741772

@@ -1815,7 +1813,7 @@ Error LinuxKernelRewriter::rewriteStaticKeysJumpTable() {
18151813
MCInst NewInst;
18161814
// Replace the instruction with unconditional jump even if it needs to
18171815
// be nop in the binary.
1818-
if (opts::LongJumpLabels) {
1816+
if (LongJumpLabels) {
18191817
BC.MIB->createLongUncondBranch(NewInst, Target, BC.Ctx.get());
18201818
} else {
18211819
// Newer kernels can handle short and long jumps for static keys.

0 commit comments

Comments
 (0)