#!/usr/bin/env python3 """Execute selected original timer instructions under Unicorn with scripted MMIO. No native target, driver or GPU execution. Regenerates independent Rust vectors. """ import argparse,hashlib,json,struct,warnings from pathlib import Path warnings.filterwarnings('ignore', category=UserWarning, module='unicorn') from elftools.elf.elffile import ELFFile from unicorn import Uc,UC_ARCH_X86,UC_MODE_64,UC_HOOK_CODE from unicorn.x86_const import * parser=argparse.ArgumentParser();parser.add_argument('--check',action='store_true');options=parser.parse_args() R=Path(__file__).resolve().parents[1] P=Path('/home/geodd/nvidia-driver/analysis-580.178.04/extracted/kernel/nvidia/nv-kernel.o_binary') TEXT=0x10000000;DATA=0x30000000;STACK=0x40000000;STUB=0x50000000;STOP=0x60000000 names=['_nv059597rm','_nv059609rm','_nv059606rm','_nv059608rm','_nv059605rm'] hooks={};functions={} with P.open('rb') as stream: e=ELFFile(stream);symbols=list(e.get_section_by_name('.symtab').iter_symbols());defined={s.name:s for s in symbols};text=bytearray(e.get_section_by_name('.text').data());text_index=e.get_section_index('.text');undefined={} for name in names: s=defined[name];functions[name]=(s['st_value'],s['st_size']) for rel in e.get_section_by_name('.rela.text').iter_relocations(): off=rel['r_offset'] if not any(start<=off