From ba90af9ff214cd4be26b1cfbe080c01828c1f286 Mon Sep 17 00:00:00 2001 From: Pragyansh Chaturvedi Date: Thu, 25 Sep 2025 22:24:55 +0530 Subject: [PATCH] Allocate space for string consts --- pythonbpf/functions_pass.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pythonbpf/functions_pass.py b/pythonbpf/functions_pass.py index 7a261e4..bbe636a 100644 --- a/pythonbpf/functions_pass.py +++ b/pythonbpf/functions_pass.py @@ -370,8 +370,14 @@ def allocate_mem(module, builder, body, func, ret_type, map_sym_tab, local_sym_t var.align = ir_type.width // 8 print( f"Pre-allocated variable {var_name} of type c_int64") + elif isinstance(rval.value, str): + ir_type = ir.PointerType(ir.IntType(8)) + var = builder.alloca(ir_type, name=var_name) + var.align = 8 + print( + f"Pre-allocated variable {var_name} of type string") else: - print("Unsupported constant type") + print(f"Unsupported constant type") continue elif isinstance(rval, ast.BinOp): # Assume c_int64 for now