From ce7b170feacb82e88766363ebb95b58412933a97 Mon Sep 17 00:00:00 2001 From: varun-r-mallya Date: Wed, 15 Oct 2025 18:19:51 +0530 Subject: [PATCH] float vmlinux_assignments_symtab --- pythonbpf/codegen.py | 4 ++-- pythonbpf/functions/functions_pass.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pythonbpf/codegen.py b/pythonbpf/codegen.py index 5db9f88..6044e56 100644 --- a/pythonbpf/codegen.py +++ b/pythonbpf/codegen.py @@ -45,14 +45,14 @@ def processor(source_code, filename, module): for func_node in bpf_chunks: logger.info(f"Found BPF function/struct: {func_node.name}") - vmlinux_proc(tree, module) + vmlinux_assignments_symtab = vmlinux_proc(tree, module) populate_global_symbol_table(tree, module) license_processing(tree, module) globals_processing(tree, module) structs_sym_tab = structs_proc(tree, module, bpf_chunks) map_sym_tab = maps_proc(tree, module, bpf_chunks) - func_proc(tree, module, bpf_chunks, map_sym_tab, structs_sym_tab) + func_proc(tree, module, bpf_chunks, map_sym_tab, structs_sym_tab, vmlinux_assignments_symtab) globals_list_creation(tree, module) diff --git a/pythonbpf/functions/functions_pass.py b/pythonbpf/functions/functions_pass.py index 8d0bce1..647fb41 100644 --- a/pythonbpf/functions/functions_pass.py +++ b/pythonbpf/functions/functions_pass.py @@ -311,7 +311,7 @@ def process_stmt( def process_func_body( - module, builder, func_node, func, ret_type, map_sym_tab, structs_sym_tab + module, builder, func_node, func, ret_type, map_sym_tab, structs_sym_tab, vmlinux_assignments_symtab ): """Process the body of a bpf function""" # TODO: A lot. We just have print -> bpf_trace_printk for now @@ -350,7 +350,7 @@ def process_func_body( builder.ret(ir.Constant(ir.IntType(64), 0)) -def process_bpf_chunk(func_node, module, return_type, map_sym_tab, structs_sym_tab): +def process_bpf_chunk(func_node, module, return_type, map_sym_tab, structs_sym_tab, vmlinux_assignments_symtab): """Process a single BPF chunk (function) and emit corresponding LLVM IR.""" func_name = func_node.name @@ -384,7 +384,7 @@ def process_bpf_chunk(func_node, module, return_type, map_sym_tab, structs_sym_t builder = ir.IRBuilder(block) process_func_body( - module, builder, func_node, func, ret_type, map_sym_tab, structs_sym_tab + module, builder, func_node, func, ret_type, map_sym_tab, structs_sym_tab, vmlinux_assignments_symtab ) return func @@ -394,7 +394,7 @@ def process_bpf_chunk(func_node, module, return_type, map_sym_tab, structs_sym_t # ============================================================================ -def func_proc(tree, module, chunks, map_sym_tab, structs_sym_tab): +def func_proc(tree, module, chunks, map_sym_tab, structs_sym_tab, vmlinux_assignments_symtab): for func_node in chunks: if is_global_function(func_node): continue @@ -407,6 +407,7 @@ def func_proc(tree, module, chunks, map_sym_tab, structs_sym_tab): ctypes_to_ir(infer_return_type(func_node)), map_sym_tab, structs_sym_tab, + vmlinux_assignments_symtab )