# SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2026 Open-IOV contributors # Ghidra script to extract version from .fwversion section of GSP binary # Usage: analyzeHeadless ... -postScript extract_gsp_version.py import sys # Get the current program program = getCurrentProgram() # Get the .fwversion section fwversion_section = program.getSection(".fwversion") if fwversion_section: # Get the data from the section data = getBytes(fwversion_section.getStart(), fwversion_section.getLength()) version_str = data.decode('ascii').strip('\x00') print(f"GSP Firmware Version: {version_str}") # Also save to a file with open("/home/rmcore/Git/integdev_gpu_drv/open-iov/tools/ghidra/gsp-tu104-570.144/gsp_version.txt", "w") as f: f.write(version_str) else: print("No .fwversion section found") # Try to find version in memory listing = program.getListing() for i in range(listing.getNumAddresses()): addr = listing.getAddress(i) data = getBytes(addr, 32) if data and b"570.144" in data: print(f"Found version at {addr}: {data}") break