1414
1515def load_entries (file_path ):
1616 signatures = {}
17- vtables = {}
17+ offsets = {}
1818 with open (file_path ) as f :
1919 for name , entry in commentjson .load (f ).items ():
2020 if not isinstance (entry , dict ):
@@ -27,32 +27,30 @@ def load_entries(file_path):
2727 signatures [name ] = {"lib" : lib , "linux" : sig ["linux" ]}
2828 continue
2929
30- vt = entry .get ("vtable" )
31- if vt and vt .get ("binary" ) and vt .get ("class" ) and vt .get ("linux" ) is not None :
32- vtables [name ] = {
33- "binary" : vt ["binary" ],
34- "class" : vt ["class" ],
35- "offset" : vt ["linux" ],
36- }
37- return signatures , vtables
30+ off = entry .get ("offsets" )
31+ lib = entry .get ("library" ) or entry .get ("lib" )
32+ cls = entry .get ("class" )
33+ if off and lib and cls and off .get ("linux" ) is not None :
34+ offsets [name ] = {"lib" : lib , "class" : cls , "offset" : off ["linux" ]}
35+ return signatures , offsets
3836
3937
40- def check_vtable (set_name , name , vt ):
38+ def check_offset (set_name , name , off ):
4139 result = {
4240 "set" : set_name ,
4341 "signature" : name ,
4442 "kind" : "vtable" ,
45- "class" : vt ["class" ],
46- "offset" : vt ["offset" ],
43+ "class" : off ["class" ],
44+ "offset" : off ["offset" ],
4745 "count" : None ,
4846 "ok" : False ,
4947 }
5048 try :
51- result ["count" ] = s2binlib .get_vfunc_count (vt [ "binary " ], vt ["class" ])
49+ result ["count" ] = s2binlib .get_vfunc_count (off [ "lib " ], off ["class" ])
5250 except Exception as error :
5351 result ["error" ] = str (error )
5452 return result
55- result ["ok" ] = 0 <= vt ["offset" ] < result ["count" ]
53+ result ["ok" ] = 0 <= off ["offset" ] < result ["count" ]
5654 return result
5755
5856
@@ -71,7 +69,7 @@ def main():
7169 if not path .exists (file_path ):
7270 print (f"[skip] missing { file_path } " , flush = True )
7371 continue
74- signatures , vtables = load_entries (file_path )
72+ signatures , offsets = load_entries (file_path )
7573 for name , sig in signatures .items ():
7674 _ , count = s2binlib .pattern_scan (sig ["lib" ], sig ["linux" ])
7775 results .append (
@@ -80,11 +78,11 @@ def main():
8078 "signature" : name ,
8179 "kind" : "signature" ,
8280 "count" : count ,
83- "ok" : count = = 1 ,
81+ "ok" : count > = 1 ,
8482 }
8583 )
86- for name , vt in vtables .items ():
87- results .append (check_vtable (set_name , name , vt ))
84+ for name , off in offsets .items ():
85+ results .append (check_offset (set_name , name , off ))
8886
8987 broken = [r for r in results if not r ["ok" ]]
9088 result = {
0 commit comments