mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +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):
|
elif VmlinuxHandlerRegistry.is_vmlinux_struct(call_type):
|
||||||
# When calling struct_name(pointer), we're doing a cast, not construction
|
# When calling struct_name(pointer), we're doing a cast, not construction
|
||||||
# So we allocate as a pointer (i64) not as the actual struct
|
# 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
|
var.align = 8
|
||||||
local_sym_tab[var_name] = LocalSymbol(
|
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(
|
logger.info(
|
||||||
f"Pre-allocated {var_name} for vmlinux struct pointer cast to {call_type}"
|
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__}")
|
logger.error(f"Unsupported boolean operator: {type(expr.op).__name__}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# VMLinux casting
|
# VMLinux casting
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
|
||||||
def _handle_vmlinux_cast(
|
def _handle_vmlinux_cast(
|
||||||
func,
|
func,
|
||||||
module,
|
module,
|
||||||
@ -603,7 +605,9 @@ def eval_expr(
|
|||||||
elif isinstance(expr, ast.Constant):
|
elif isinstance(expr, ast.Constant):
|
||||||
return _handle_constant_expr(module, builder, expr)
|
return _handle_constant_expr(module, builder, expr)
|
||||||
elif isinstance(expr, ast.Call):
|
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(
|
return _handle_vmlinux_cast(
|
||||||
func,
|
func,
|
||||||
module,
|
module,
|
||||||
|
|||||||
Reference in New Issue
Block a user