<div dir="ltr">Hello,<div><br></div><div>I am on the hook to analyze a piece of LLVM IR code with a single giant function produced by some other languages. So basically I will need to recover some CG and CFG information from that giant function following some knowledge on function entry points. </div><div><br></div><div>While in general that works for me, one problem is to analyze the JumpTable. So basically I am having a lot of basic blocks that end with or start from a JumpTable entry, something like:</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;white-space:inherit">.473: ; preds = %.461, %JumpTable
call void @check(i64* %gas.ptr, i64 12, i8* %jmpBuf)
%210 = getelementptr i256, i256* %sp.473, i64 -2
%211 = load i256, i256* %210, align 16
%212 = getelementptr i256, i256* %sp.473, i64 -1
%213 = load i256, i256* %212, align 16
%214 = getelementptr i256, i256* %sp.473, i64 -2
store i256 %213, i256* %214, align 16
br label %JumpTable
.348: ; preds = %.347, %JumpTable
call void @check(i64* %gas.ptr, i64 9, i8* %jmpBuf)
%133 = getelementptr i256, i256* %sp.348, i64 -1
%134 = load i256, i256* %133, align 16
br label %JumpTable</code></pre></div><div><br></div><div>And here is how my JumpTable looks like:</div><div><pre style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241);color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;white-space:inherit">JumpTable: ; preds = %.473, %.348
%target = phi i256 [ %134, %.348 ], [ %211, %.473 ]
switch i256 %target, label %Exit [
i256 66, label %.66
i256 68, label %.68
i256 79, label %.79
i256 81, label %.81
i256 92, label %.92
i256 188, label %.188
i256 202, label %.202
i256 347, label %.347
i256 348, label %.348
i256 350, label %.350
i256 432, label %.432
i256 461, label %.461
i256 473, label %.473
]</code></pre></div><div><br></div><div>The problem is that right now when I traverse on the CFG, the succeeding blocks of the jump table would include ALL the basic blocks reachable by the JumpTable. In other words, I might get a very imprecise analysis results (yes, of course that's "sound").</div><div><br></div><div>So I am writing to ask whether it is feasible to do any "range" analysis to infer the value stored in the JumpTable index? For instance when traversing to BB .<span style="font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;background-color:rgb(239,240,241);color:rgb(36,39,41);font-size:13px">348, </span><font face="arial, helvetica, sans-serif"><span style="font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;background-color:rgb(255,255,255)"><font color="#000000" style="">it would be great to know that pointer %</font></span><span style="font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;background-color:rgb(239,240,241);color:rgb(36,39,41);font-size:13px">134 </span><span style="font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;font-weight:inherit;white-space:inherit;color:rgb(36,39,41);font-size:13px;background-color:rgb(255,255,255)">can only be 5, or 6. Something like this.</span></font></div><div><br></div><div>Am I clear on this? Thank you for your help, and wish you a Happy New Year!</div><div><br></div><div>Best,</div><div>Irene</div><div><br></div><div><br></div><div><br></div></div>