#!/usr/bin/env python3 # # Copyright (c) 2025 Intel Corporation # # SPDX-License-Identifier: Apache-2.0 import argparse import struct from elftools.elf.elffile import ELFFile from elftools.elf.sections import SymbolTableSection def parse_args(): global args parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False, ) parser.add_argument("-k", "--kernel", required=False, help="Zephyr kernel image") parser.add_argument("-o", "--header-output", required=False, help="Header output file") parser.add_argument("-c", "--config", required=False, help="Configuration file (.config)") parser.add_argument( "-a", "--arch", required=False, help="Architecture to generate shadow stack for", choices=["x86", "x86_64"], default="x86", ) args = parser.parse_args() def get_symbols(obj): for section in obj.iter_sections(): if isinstance(section, SymbolTableSection): return {sym.name: sym for sym in section.iter_symbols()} raise LookupError("Could not find symbol table") shstk_irq_top_fmt = "