Skip to content

Commit a5a6711

Browse files
committed
Add map_sym_tab
1 parent ed37aa0 commit a5a6711

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

pythonbpf/maps_pass.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
from llvmlite import ir
33
from .type_deducer import ctypes_to_ir
44

5+
map_sym_tab = {}
6+
7+
58
def maps_proc(tree, module, chunks):
69
for func_node in chunks:
710
# Check if this function is a map
@@ -18,29 +21,31 @@ def maps_proc(tree, module, chunks):
1821

1922
def create_bpf_map(module, map_name, map_params):
2023
"""Create a BPF map in the module with the given parameters"""
21-
24+
2225
# Create the anonymous struct type for BPF map
2326
map_struct_type = ir.LiteralStructType([
2427
ir.PointerType(),
2528
ir.PointerType(),
2629
ir.PointerType(),
2730
ir.PointerType()
2831
])
29-
32+
3033
# Create the global variable
3134
map_global = ir.GlobalVariable(module, map_struct_type, name=map_name)
3235
map_global.linkage = 'dso_local'
3336
map_global.global_constant = False
34-
37+
3538
# Initialize with zeroinitializer (all null pointers)
36-
map_global.initializer = ir.Constant(map_struct_type, None) #type: ignore
37-
39+
map_global.initializer = ir.Constant(map_struct_type, None) # type: ignore
40+
3841
map_global.section = ".maps"
3942
map_global.align = 8 # type: ignore
4043

4144
print(f"Created BPF map: {map_name}")
45+
map_sym_tab[map_name] = map_global
4246
return map_global
4347

48+
4449
def process_hash_map(map_name, rval, module):
4550
print(f"Creating HashMap map: {map_name}")
4651
map_params: dict[str, object] = {"map_type": "HASH"}

0 commit comments

Comments
 (0)