Log date · Mon
Can call graphs improve binary function similarity?
Call context can add clues, but gains depend on the task. A Java bytecode example shows why, and how to evaluate your own builds.
What can call context tell us?
Call relationships can add useful evidence to function analysis, but whether they improve similarity detection must be tested on the task. We wrote two Java wrappers with the same three bytecode instruction types but different callees: on input 10, one returns 17 and the other 3. Looking only at instruction types misses the difference.
At 11:44 UTC on 2026-08-03, arXiv received v1 of “Pretraining on Call Graphs: When Binary Analysis Tasks Profit From Context”, in the primary category cs.SE. The paper found that similarity gains from call-graph-enhanced embeddings do not necessarily transfer to other tasks. [1]
| Question | Result |
|---|---|
| Instructions in each wrapper? | Three, with the same instruction types. |
| Same callee? | No: tax versus fee. |
| Result for input 10? | 17 and 3 respectively. |
| A model accuracy result? | No; this is a sample illustrating call context. |
Sample and scope
We compiled our own Java class with javac 17.0.19 and -g:none, ran it, and inspected the class file with javap. This JVM bytecode comparison illustrates context; it is not a replication of the paper’s native-binary models, training or dataset, and does not measure retrieval accuracy. [2][3]
static int tax(int x) { return x + 7; }
static int fee(int x) { return x - 7; }
static int invoice(int x) { return tax(x); }
static int refund(int x) { return fee(x); }The wrappers pass their argument unchanged to different callees. tax adds 7 and fee subtracts 7; each wrapper’s opcode sequence is load, invoke, return. The -g:none option omits debugging information, but does not remove these Java method names or call targets, so it is not equivalent to stripping symbols from a native binary.
Reading calls in bytecode
The javap -c option prints bytecode, and -private includes all members. [2] In the verbatim excerpt below, the invokestatic constant-pool references and comments already distinguish the targets; inspecting the callees reveals addition versus subtraction. The names are readable clues here, not hidden identifiers.
static int invoice(int);
Code:
0: iload_0
1: invokestatic #7 // Method tax:(I)I
4: ireturn
static int refund(int);
Code:
0: iload_0
1: invokestatic #13 // Method fee:(I)I
4: ireturnIf a comparison uses only the three opcodes as features, these methods tie; adding the targets and their contents provides information that separates them. Conversely, sharing a callee does not prove semantic equivalence: arguments, branches and other calls may change the result. A static call graph can also miss actual targets reached through dynamic dispatch or reflection, so inspect edge quality as well.
invoice(10)=17
refund(10)=3What the paper actually evaluated
The paper extracts functions and a call graph from binaries, generates initial embeddings with CLAP and jTrans, then aggregates callee information using averaging and two graph neural network variants. It compares call depths one through five and evaluates binary code similarity, function labeling and compiler optimization detection. [4] Those learned representations differ from our manual inspection.
The authors report improved embedding robustness, especially where the backbone struggled, and a larger benefit for namespace-related functions than for functions expressing individual logic. They also associate semantic-similarity optimization with worse syntactic task performance. The paper’s dataset, disassembly and task choices bound those findings; they are not guarantees for every tool or application. [1][4]
This distinction matters when evaluating a tool or a protection change. Retrieving a known function pair does not establish reliable vulnerability detection, function labeling or compiler-option identification. Define the question first, then build labeled cases and metrics for that question. A leaderboard score is not a measurement of the time required to understand business logic.
How to evaluate your own builds
These are engineering recommendations, not effects measured by our sample. Use builds you are authorized to inspect, retain build identifiers and known function correspondences, and report each configuration separately.
| Goal | Recommendation |
|---|---|
| Find equivalent functions | Measure retrieval recall and false positives on known positive and negative pairs. |
| Compare compiler settings | Hold source fixed; record optimization level and architecture separately. |
| Evaluate a transformation | Compare the same task before and after it and check behavior and build differences. |
| Reduce exposure | Review release symbols; consider server-side execution for sensitive online rules. |
Use builds of the same source function as candidate positives and confusable but non-equivalent functions as negatives. Verify labels before splitting training and evaluation, so related builds do not leak across the split. Record the search scope, candidate-set size, threshold, recall and false-positive count; review false positives manually where needed. Scores at different candidate sizes or thresholds are not directly comparable.
For a repeat test, hold candidates and labels fixed while changing one build factor. Investigate whether a false match comes from a common library, a similar wrapper or a wrong call edge before adding more context. Record functional regressions, performance and release size too, rather than optimizing one retrieval number alone.
Check your own application
Run these commands in the sample directory first. For your own Java build, substitute the class path and class name; select a class whose calls you know, compare the targets in the output, and check them against source or build records. [2][3]
javac -g:none -d build ContextDemo.java
java -cp build ContextDemo
javap -classpath build -c -private ContextDemo
# Replace with your own class path and class.
javap -classpath path/to/classes -c -private com.example.YourClassFor a native release, use analysis tools appropriate to the target platform and known mappings to check actual functions and call edges; inlining, indirect calls and optimization can change graph structure. Preserve reproducible build settings and repeat the same evaluation after changing protection or compiler options.
Your checklist
- Record source, build settings, version and architecture.
- Prepare verified positive and negative function pairs for the task.
- Inspect call edges, including effects of indirect calls and optimization.
- Record candidate set, threshold, recall and false positives.
- Repeat the same evaluation and functional checks after transformation.
Primary sources
- arXiv: Pretraining on Call Graphs: When Binary Analysis Tasks Profit From Context (2608.02084) · Source date 2026-08-03 · Checked 2026-10-12
- Oracle: javap command · Checked 2026-11-11
- Oracle: javac command · Checked 2026-11-11
- Pretraining on Call Graphs: full paper, v1 · Source date 2026-08-03 · Checked 2026-11-11