mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-02-12 16:10:59 +00:00
make pointer allocation feasible but subverting LLC
This commit is contained in:
@ -121,10 +121,10 @@ def _allocate_for_call(
|
||||
elif VmlinuxHandlerRegistry.is_vmlinux_struct(call_type):
|
||||
# When calling struct_name(pointer), we're doing a cast, not construction
|
||||
# So we allocate as a pointer (i64) not as the actual struct
|
||||
var = builder.alloca(ir.PointerType(), name=var_name)
|
||||
var = builder.alloca(ir.IntType(64), name=var_name)
|
||||
var.align = 8
|
||||
local_sym_tab[var_name] = LocalSymbol(
|
||||
var, ir.PointerType(), VmlinuxHandlerRegistry.get_struct_type(call_type)
|
||||
var, ir.IntType(64), VmlinuxHandlerRegistry.get_struct_type(call_type)
|
||||
)
|
||||
logger.info(
|
||||
f"Pre-allocated {var_name} for vmlinux struct pointer cast to {call_type}"
|
||||
|
||||
@ -524,10 +524,12 @@ def _handle_boolean_op(
|
||||
logger.error(f"Unsupported boolean operator: {type(expr.op).__name__}")
|
||||
return None
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# VMLinux casting
|
||||
# ============================================================================
|
||||
|
||||
|
||||
def _handle_vmlinux_cast(
|
||||
func,
|
||||
module,
|
||||
@ -603,7 +605,9 @@ def eval_expr(
|
||||
elif isinstance(expr, ast.Constant):
|
||||
return _handle_constant_expr(module, builder, expr)
|
||||
elif isinstance(expr, ast.Call):
|
||||
if isinstance(expr.func, ast.Name) and VmlinuxHandlerRegistry.is_vmlinux_struct(expr.func.id):
|
||||
if isinstance(expr.func, ast.Name) and VmlinuxHandlerRegistry.is_vmlinux_struct(
|
||||
expr.func.id
|
||||
):
|
||||
return _handle_vmlinux_cast(
|
||||
func,
|
||||
module,
|
||||
|
||||
Reference in New Issue
Block a user