|
OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
|
Functions | |
| objects (build_dir) | |
| parse (readelf, path) | |
| ret_class (k) | |
| param_class (k) | |
| differs (defn, decl) | |
| main () | |
Variables | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| DIE = re.compile(r'^\s*<(\d+)><([0-9a-f]+)>: Abbrev Number: \d+ \((DW_TAG_\w+)\)') | |
| ATTR = re.compile(r'^\s*<[0-9a-f]+>\s+(DW_AT_\w+)\s*:\s*(.*)$') | |
Lists the engine functions called with another type than they are defined.
python3 scripts/check_c_decls.py <build_dir> [--readelf READELF] [--allowlist FILE] [-v]
(MinGW: --readelf i686-w64-mingw32-objdump)
The engine's sources have C linkage and declare what they call with their own
`extern` lines, so nothing checks a declaration against the definition in
another file. On i386 a wrong return type breaks the call: a function that
returns nothing but is declared float leaves the caller popping an empty x87
stack, a float declared int leaves one on it, a bool (al) read as an int takes
the rest of eax. This reads the DWARF of the build's objects (they are built
with -g): the declarations a compiler records are those of the functions an
object calls. For each function defined with C linkage it compares the return
type and the parameters' sizes and kinds with every declaration of it in
another object, and lists the differences. Exits with 0 when every difference
is in the allowlist (one name per line, # comments; default
test/c_decls_allowlist.txt), and lists the allowlist's names that no longer
differ, so the list only shrinks.
| check_c_decls.differs | ( | defn, | |
| decl ) |
Why a call through decl breaks with the definition, or None.
| check_c_decls.main | ( | ) |
| check_c_decls.objects | ( | build_dir | ) |
The engine's objects of compile_commands.json (stale ones from another configuration are left out), without CoD2rev-Plus's C++ targets.
| check_c_decls.param_class | ( | k | ) |
How a parameter of kind k sits on the stack.
| check_c_decls.parse | ( | readelf, | |
| path ) |
[(name, is_declaration, signature)] of the object's C functions.
| check_c_decls.ret_class | ( | k | ) |
Where i386 returns a value of kind k.
| check_c_decls.ATTR = re.compile(r'^\s*<[0-9a-f]+>\s+(DW_AT_\w+)\s*:\s*(.*)$') |
| check_c_decls.DIE = re.compile(r'^\s*<(\d+)><([0-9a-f]+)>: Abbrev Number: \d+ \((DW_TAG_\w+)\)') |
| check_c_decls.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |