vlk-analysis 0.3.0

Lifting, SSA and simplification passes of the vlk decompiler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
//! Lifting of one function and recovery of its signature, before optimization.

use std::collections::HashSet;

use vlk_base::error::LiftError;
use vlk_base::target::Isa;
use vlk_ir::ir::{Block, Expr, FunctionIr, Operation, Stmt};
use vlk_loader::loader::{Function, Image, NameSource};
use vlk_program::program::Program;
use vlk_types::types::{
    AbiLocation, CType, Convention, Passing, Precision, SignatureAbi, StackParam, Structure,
    ValueAbi,
};

use super::dead_code::drop_unreached;
use super::exceptions::{exception_starts, receive_exceptions};
use super::float_result::{float_result_of, float_return_slot};
use super::go_entry::{drop_stack_growth_check, initialize_go_registers};
use super::mips_calls::keep_registers_read_after_calls;
use super::{UNKNOWN_SIZE, abi, go_types, indirect, jump_table, results, signature, summary};
use crate::lift;

/// The function's IR before any optimization pass, with its recovered signature.
pub(super) struct Lifted {
    pub(super) ir: FunctionIr,
    pub(super) has_jump_tables: bool,
    pub(super) types: Option<vlk_loader::loader::dwarf::FunctionTypes>,
}

/// Folds the cases of jump tables back into their functions where the
/// prologue scan took a case, which follows a return like a new function
/// would, for a function start. Each pass widens the functions it merges,
/// which may expose further tables.
pub fn absorb_jump_table_cases(program: &mut Program) {
    for _ in 0..4 {
        let functions: Vec<_> = program
            .image
            .functions
            .values()
            .filter(|function| {
                function
                    .sources
                    .contains(&vlk_loader::loader::NameSource::Prologue)
            })
            .collect();
        let found = vlk_base::parallel::map(&functions, |function| {
            let mut cases = HashSet::new();
            let size = function.size.unwrap_or(UNKNOWN_SIZE);
            // Function extents are still settling, so no callee is summarized yet.
            let Ok(blocks) =
                lift::lift_with(program, function.addr, size, &HashSet::new(), &|_| {
                    vlk_loader::loader::Summary::default()
                })
            else {
                return cases;
            };
            let reach = function.addr..function.addr.saturating_add(0x1_0000);
            for table in jump_table::recover(&blocks, program, reach) {
                cases.extend(
                    table
                        .targets()
                        .into_iter()
                        .filter(|target| *target != function.addr),
                );
            }
            cases
        });
        let mut cases = HashSet::new();
        for found in found {
            cases.extend(found);
        }
        if !program
            .image
            .drop_scanned_starts(&cases, crate::lift::scan(program.image.isa))
        {
            return;
        }
    }
}

/// The results the function at `addr` returns past its stack arguments,
/// under Go's assembly ABI, as it finds them when it returns.
pub(super) fn stack_results(program: &Program, addr: u64) -> Vec<vlk_ir::ir::Expr> {
    let image = &program.image;
    let convention = crate::lift::convention_of(image, addr);
    let Some(start) = convention.stack_arguments() else {
        return Vec::new();
    };
    let sp = vlk_arch::arch::stack_pointer(image.isa);
    summary::summary(program, addr)
        .stack_results
        .iter()
        .take_while(|(_, width)| *width != 0)
        .map(|(offset, width)| vlk_ir::ir::Expr::Load {
            addr: Box::new(vlk_ir::ir::Expr::bin(
                vlk_ir::ir::BinOp::Add,
                vlk_ir::ir::Expr::reg(sp, 64),
                vlk_ir::ir::Expr::Const(start as u64 + u64::from(*offset)),
            )),
            width: *width,
            signed: false,
        })
        .collect()
}

/// Takes a jump through a pointer read from memory, or through a register
/// the block never sets, as a call that ends the function: a tail call, as
/// through a table of functions. A jump to an address the block computes
/// otherwise, as an unrecovered jump table's, stays a jump, as does one
/// made with the stack away from its height on entry.
pub(super) fn tail_calls_through_pointers(
    blocks: &mut [vlk_ir::ir::Block],
    switched: &HashSet<u64>,
    image: &Image,
) {
    let heights = crate::lift::stack_heights(blocks, image.isa);
    for (block, height) in blocks.iter_mut().zip(heights) {
        if switched.contains(&block.start) || height.is_some_and(|height| height != 0) {
            continue;
        }
        let Some(Stmt::BrIndirect { target, .. }) = block.stmts.last() else {
            continue;
        };
        // A copy of such a register is one too, as an argument moved aside
        // for the arguments the callee takes.
        let mut pointer = matches!(target, Expr::Load { .. });
        let mut copied = target;
        let mut earlier = block.stmts.iter().rev().skip(1);
        loop {
            if image.isa == vlk_base::target::Isa::Arm32
                && let Expr::Bin {
                    op: vlk_ir::ir::BinOp::And,
                    lhs,
                    rhs,
                } = copied
                && matches!(rhs.as_ref(), Expr::Const(0xffff_ffff | 0xffff_fffe))
            {
                copied = lhs;
                continue;
            }
            let Expr::Reg { index, .. } = copied else {
                break;
            };
            match earlier.find_map(|stmt| match stmt {
                Stmt::Assign { dest, value, .. } if dest.index == *index => Some(value),
                _ => None,
            }) {
                None | Some(Expr::Load { .. }) => {
                    pointer = true;
                    break;
                }
                Some(value) => copied = value,
            }
        }
        if !pointer {
            continue;
        }
        let through = target.clone();
        let at = block.stmts.pop().and_then(|stmt| stmt.origin());
        block.stmts.push(Stmt::Call {
            kind: vlk_types::types::CallKind::Tail,
            target: None,
            through: Some(through),
            convention: vlk_types::types::Convention::of(image.isa, image.format, image.go),
            args: None,
            floats_named: false,
            abi: None,
            clobbers: None,
            outputs: vlk_ir::ir::fallback_call_outputs(
                vlk_types::types::Convention::of(image.isa, image.format, image.go),
                None,
            ),
            via: None,
            at,
        });
        block.stmts.push(Stmt::Ret {
            value: Expr::reg(vlk_arch::arch::RETURN, 64),
            at: None,
        });
    }
}

/// The jump tables of `blocks`. On MIPS a table's address may be kept in a
/// frame slot, which is read as the address once the tables found so far
/// say where the other jumps through a register go: then the tables are
/// looked for again.
pub(super) fn recover_tables(
    program: &Program,
    blocks: &mut [vlk_ir::ir::Block],
    extent: std::ops::Range<u64>,
) -> Vec<jump_table::Recovered> {
    let image = &program.image;
    let mut tables = jump_table::recover(blocks, program, extent.clone());
    if image.isa == vlk_base::target::Isa::Mips32 {
        for _ in 0..4 {
            let known: Vec<(u64, Vec<u64>)> = tables
                .iter()
                .map(|table| (table.block_start, table.targets()))
                .collect();
            if !lift::mips32::fold_table_slots(image, blocks, &HashSet::new(), &known) {
                break;
            }
            tables = jump_table::recover(blocks, program, extent.clone());
        }
    }
    tables
}

/// Lifts the function and recovers its jump tables. Cases start blocks of
/// their own, which may hold further tables: the function is lifted again
/// while new cases turn up. `starts` are the block starts known beforehand.
fn lift_with_tables(
    program: &Program,
    function: &Function,
    size: u64,
    starts: HashSet<u64>,
) -> Result<(Vec<Block>, Vec<jump_table::Recovered>), LiftError> {
    let extent = function.addr..function.addr.saturating_add(size);
    let mut blocks = match lift::lift(program, function.addr, size, &starts) {
        Ok(blocks) => blocks,
        Err(error) => return Err(error),
    };
    let mut tables = recover_tables(program, &mut blocks, extent.clone());
    let mut targets = starts;
    for _ in 0..4 {
        let found: HashSet<u64> = tables
            .iter()
            .flat_map(jump_table::Recovered::targets)
            .collect();
        if found.is_subset(&targets) {
            break;
        }
        targets.extend(found);
        blocks = match lift::lift(program, function.addr, size, &targets) {
            Ok(blocks) => blocks,
            Err(error) => return Err(error),
        };
        tables = recover_tables(program, &mut blocks, extent.clone());
    }
    Ok((blocks, tables))
}

/// Makes every return of `blocks` return `returned`.
pub(super) fn set_returns(blocks: &mut [Block], returned: &Expr) {
    for stmt in blocks.iter_mut().flat_map(|block| &mut block.stmts) {
        if let Stmt::Ret { value, .. } = stmt {
            *value = returned.clone();
        }
    }
}

/// What a function returns in registers.
struct RegisterReturn {
    float: Option<Precision>,
    /// Whether the function returns nothing its callers use.
    ignored: bool,
}

/// Decides what the function returns in registers and makes its returns
/// say so. `declared` is the return type the debug information, a
/// definition or the Go runtime gives; `stack_results` says whether the
/// function returns through the stack instead.
fn settle_register_return(
    program: &Program,
    function: &Function,
    blocks: &mut [Block],
    declared: Option<&CType>,
    stack_results: bool,
) -> RegisterReturn {
    let image = &program.image;
    if vlk_arch::arch::pointer_bytes(image.isa) == 4 && declared.is_some_and(lift::pairs32::wide) {
        let (low, high) = lift::pairs32::result_registers(image);
        set_returns(
            blocks,
            &lift::pairs32::join(Expr::reg(low, 32), Expr::reg(high, 32)),
        );
    }
    // A function returning a float returns it in xmm0 or v0.
    let float = match declared {
        Some(ret) => ret.precision(),
        None if stack_results => None,
        None => float_result_of(blocks, program, function.addr, &|target| {
            summary::summary(program, target).float_return
        }),
    };
    // Without debug info, a function whose callers all ignore what is left
    // in the return register returns nothing either. A linkage stub returns
    // what the library function does, whatever these callers make of it.
    // So does one that returns on some path with the register unset.
    // A Go function returns as many values as its callers read.
    let further = if (image.go || declared.is_none()) && float.is_none() && !stack_results {
        results::further_results(program, function.addr)
    } else {
        0
    };
    // A Go method returns what the method table of its type says.
    let listed = if float.is_none() && !stack_results {
        results::method_results(image, function.addr)
    } else {
        None
    };
    let ignored = declared.is_none()
        && float.is_none()
        && !stack_results
        && further == 0
        && !function.sources.contains(&NameSource::Plt)
        && match listed {
            Some(results) => results == 0,
            None => {
                results::ignored_by_callers(program, function.addr)
                    || results::returns_unset(blocks, lift::convention_of(image, function.addr))
            }
        };
    // A function the debug info says returns nothing returns no register.
    if declared == Some(&CType::Void) || ignored {
        set_returns(blocks, &Expr::constant(0));
    }
    if let (Some(precision), Some(slot)) = (float, float_return_slot(image.isa)) {
        set_returns(blocks, &Expr::reg(slot, precision.bits()));
    }
    if further > 0 {
        let convention = Convention::of(image.isa, image.format, image.go);
        let returned: Vec<Expr> = convention.results()[..=further]
            .iter()
            .map(|register| Expr::reg(*register, 64))
            .collect();
        for stmt in blocks.iter_mut().flat_map(|block| &mut block.stmts) {
            if let Stmt::Ret { value, .. } = stmt
                && matches!(value, Expr::Reg { .. })
            {
                *value = Expr::Apply {
                    op: Operation::Results,
                    args: returned.clone(),
                };
            }
        }
    }
    RegisterReturn { float, ignored }
}

/// The value a function with a declared signature returns, where `binding`
/// places its result. None when a piece of the result is on the stack.
fn declared_return(binding: &SignatureAbi) -> Option<Expr> {
    match binding.result.as_ref().map(|value| &value.passing) {
        Some(Passing::Direct(pieces)) => {
            let values: Option<Vec<_>> = pieces
                .iter()
                .map(|piece| match piece.location {
                    AbiLocation::Register(register) => Some(Expr::reg(register, 64)),
                    AbiLocation::Stack(_) => None,
                })
                .collect();
            values.map(|args| Expr::Apply {
                op: Operation::Results,
                args,
            })
        }
        Some(Passing::Indirect {
            returned_pointer, ..
        }) => Some(
            returned_pointer.map_or_else(|| Expr::constant(0), |register| Expr::reg(register, 64)),
        ),
        None => Some(Expr::constant(0)),
    }
}

/// The signature of `function` from its body, less the registers Go says
/// pass no argument.
fn recover_signature(
    image: &Image,
    function: &Function,
    blocks: &[Block],
    landing_pads: &[(u64, Vec<(u64, u64)>)],
) -> signature::Signature {
    let mut signature = signature::recover_for(image, function, blocks, landing_pads);
    // Go lists the registers that pass a function's arguments: one read
    // past them, as one handed on to a callee is, is no parameter.
    if let Some(listed) = vlk_loader::loader::go::argument_registers(image, function.addr) {
        let arguments = lift::convention_of(image, function.addr).arguments();
        signature.params.retain(|param| {
            param.name == "closure"
                || arguments
                    .iter()
                    .position(|register| *register == param.index)
                    .is_none_or(|position| position < listed)
        });
    }
    signature
}

/// The parameters passed on the stack, which follow the register ones, and
/// the structure they make up when registers are left free.
fn stack_parameters(
    signature: &signature::Signature,
    function: &Function,
    isa: Isa,
) -> (Vec<StackParam>, Vec<Structure>) {
    match (signature.aggregate, signature.stack.first()) {
        (true, Some(first)) => {
            let position = signature.params.len();
            let name = format!(
                "{}_a{position}",
                vlk_types::types::structure_prefix(function.name.as_deref(), function.addr)
            );
            let structure = Structure {
                name: name.clone(),
                fields: signature
                    .stack
                    .iter()
                    .map(|offset| ((offset - first) as u64, CType::I64))
                    .collect(),
                size: None,
                elements: Vec::new(),
            };
            let stack_param = StackParam {
                offset: *first,
                size: 8 * signature.stack.len() as u64,
                name: format!("a{position}"),
                ty: CType::Named(format!("struct {name}")),
                position,
            };
            (vec![stack_param], vec![structure])
        }
        _ => {
            let stack_params = signature
                .stack
                .iter()
                .enumerate()
                .map(|(slot, offset)| {
                    let position = signature.params.len() + slot;
                    // Only the low bytes of a packed argument are read, as they are.
                    let ty = match signature.stack_widths.get(slot) {
                        Some(width) if *width < 8 => CType::int(*width, false),
                        _ => CType::I64,
                    };
                    StackParam {
                        offset: *offset,
                        size: u64::from(vlk_arch::arch::pointer_bytes(isa)),
                        name: format!("a{position}"),
                        ty,
                        position,
                    }
                })
                .collect();
            (stack_params, Vec::new())
        }
    }
}

/// A declared result returned through memory takes a register for its
/// address: that register is a parameter, and without a register that
/// returns the address the function returns nothing.
fn add_indirect_result_parameter(ir: &mut FunctionIr) {
    let Some(Ok(binding)) = ir
        .declared_signature
        .as_ref()
        .map(|signature| &signature.abi)
    else {
        return;
    };
    let Some(ValueAbi {
        passing:
            Passing::Indirect {
                pointer: AbiLocation::Register(register),
                returned_pointer,
            },
        ..
    }) = &binding.result
    else {
        return;
    };
    let (register, returns_pointer) = (*register, returned_pointer.is_some());
    if !ir.params.iter().any(|param| param.index == register) {
        let mut position = ir.params.len();
        while ir
            .params
            .iter()
            .any(|param| param.name == format!("a{position}"))
        {
            position += 1;
        }
        ir.params.push(vlk_types::types::Param {
            index: register,
            name: format!("a{position}"),
            ty: CType::U64,
        });
    }
    if !returns_pointer {
        ir.ret_type = CType::Void;
    }
}

/// Lifts `function` and recovers its jump tables, what it returns and its
/// parameters.
pub(super) fn lift_function(program: &Program, function: &Function) -> Result<Lifted, LiftError> {
    let image = &program.image;
    let size = function.size.unwrap_or(UNKNOWN_SIZE);
    let extent = function.addr..function.addr.saturating_add(size);
    let landing_pads = image.landing_pads_of(extent.clone());
    let pads: HashSet<u64> = landing_pads.iter().map(|(pad, _)| *pad).collect();
    let starts = exception_starts(&landing_pads, extent);
    let (mut blocks, tables) = match lift_with_tables(program, function, size, starts) {
        Ok(lifted) => lifted,
        Err(error) => return Err(error),
    };
    if image.go {
        drop_stack_growth_check(&mut blocks, image);
        initialize_go_registers(&mut blocks, image.isa);
    }
    receive_exceptions(&mut blocks, &pads, image.isa);
    let switched: HashSet<u64> = tables.iter().map(|table| table.block_start).collect();
    tail_calls_through_pointers(&mut blocks, &switched, image);
    indirect::resolve(&mut blocks, &landing_pads, program);
    if image.isa == Isa::Mips32 {
        keep_registers_read_after_calls(&mut blocks);
    }
    let types = vlk_loader::loader::dwarf::function_types(image, function.addr);
    let declared_signature = types.as_ref().and_then(abi::declaration);
    let inferred = if types.is_none() {
        lift::pairs32::definition_types(program, function.addr)
    } else {
        None
    };
    let runtime = go_types::runtime(image, function.addr);
    let declared = types
        .as_ref()
        .and_then(|types| types.ret.as_ref())
        .or_else(|| inferred.as_ref().map(|(_, ret)| ret))
        .or_else(|| runtime.map(|prototype| &prototype.ret));
    // A function of Go's assembly ABI returns what it writes past its
    // arguments.
    let stack_results = stack_results(program, function.addr);
    let RegisterReturn {
        float: float_return,
        ignored,
    } = settle_register_return(
        program,
        function,
        &mut blocks,
        declared,
        !stack_results.is_empty(),
    );
    if let Some(Ok(binding)) = declared_signature.as_ref().map(|signature| &signature.abi)
        && let Some(returned) = declared_return(binding)
    {
        set_returns(&mut blocks, &returned);
    }
    // The signature reads the returns as they now are, and the cases
    // through the switches.
    jump_table::apply(&mut blocks, &tables);
    jump_table::drop_data(&mut blocks, &tables, &landing_pads);
    // Without landing pads, code no path reaches is dead; so is a linkage
    // stub's code for binding its import on first use.
    if image.go
        || (landing_pads.is_empty() && image.exception_handlers.is_empty())
        || function.sources.contains(&NameSource::Plt)
    {
        drop_unreached(&mut blocks);
    }
    let mut signature = recover_signature(image, function, &blocks, &landing_pads);
    // Read only now, the results are no arguments to the signature.
    if let Some(first) = stack_results.first() {
        let returned = match stack_results.as_slice() {
            [only] => only.clone(),
            all => Expr::Apply {
                op: Operation::Results,
                args: all.to_vec(),
            },
        };
        set_returns(&mut blocks, &returned);
        // Go's wider results are mostly `int` and `int32`, a byte one a `bool`.
        if let Expr::Load { width, .. } = first {
            signature.ret = CType::int(*width, *width > 1);
        }
    }
    let (stack_params, structures) = stack_parameters(&signature, function, image.isa);
    let mut ir = FunctionIr {
        isa: image.isa,
        convention: lift::convention_of(image, function.addr),
        params: signature.params,
        declared_signature,
        stack_params,
        stack_spills: vlk_loader::loader::go::stack_spills(image, function.addr),
        debug_globals: types
            .as_ref()
            .map(|types| types.globals.clone())
            .unwrap_or_default(),
        debug_registers: types
            .as_ref()
            .map(|types| types.registers.clone())
            .unwrap_or_default(),
        debug_locals: types
            .as_ref()
            .map(|types| types.locals.clone())
            .unwrap_or_default(),
        variadic: false,
        ret_type: match float_return {
            _ if ignored => CType::Void,
            Some(precision) => CType::Named(
                match precision {
                    Precision::Single => "float",
                    Precision::Double => "double",
                }
                .to_owned(),
            ),
            None => inferred.map_or(signature.ret, |(_, ret)| ret),
        },
        accesses: signature.accesses,
        members: Vec::new(),
        definitions: Vec::new(),
        structures,
        signed_params: signature.signed.into_iter().collect(),
        landing_pads,
        pointer_values: Vec::new(),
        saved_slots: Vec::new(),
        frame_bottom: 0,
        entry_alignment: entry_alignment(image, function.addr),
        callee_signatures: Default::default(),
        big_endian: image.byte_order() == Some(object::Endianness::Big),
        callee_results: Default::default(),
        callee_named_arguments: Default::default(),
        callee_float_returns: Default::default(),
        listed_callees: Default::default(),
        callee_floats: Default::default(),
        value_types: std::collections::BTreeMap::new(),
        variable_registers: std::collections::BTreeMap::new(),
        addr: function.addr,
        name: function.name.clone(),
        size,
        blocks,
    };
    add_indirect_result_parameter(&mut ir);
    go_types::apply_runtime_signature(&mut ir, image);
    Ok(Lifted {
        ir,
        has_jump_tables: !tables.is_empty(),
        types,
    })
}

/// The stack pointer's alignment on entry to the function at `addr`. The
/// kernel enters an ELF executable at its entry point with the stack pointer
/// at the argument count, which the x86-64 ABI aligns to 16 bytes; a raw
/// image's entry point is entered however its loader chose. Every other
/// function is called as its convention says.
pub(super) fn entry_alignment(
    image: &vlk_loader::loader::Image,
    addr: u64,
) -> Option<vlk_types::types::EntryAlignment> {
    use vlk_base::target::{Format, Isa};
    if image.entry == Some(addr) {
        match image.format {
            Format::Raw => return None,
            Format::Elf if image.isa == Isa::X86_64 => {
                return Some(vlk_types::types::EntryAlignment {
                    residue: 0,
                    modulus: 16,
                });
            }
            _ => {}
        }
    }
    crate::lift::convention_of(image, addr).entry_alignment()
}