def assemble_common(input, output, add_startup_code): src = sys.stdin if input == "-" else open(input) dst = sys.stdout if output == "-" else open(output, "wb") unit = a32.UnitParse(src, add_startup_code) for sym in unit.symbols: assert sym.section, f"undefined symbol: {sym}" # print(unit) exe = a32.Assemble(unit, True) # for phdr in exe.segments: # print(phdr) # for sec in phdr.sections: # print(sec) print("WRITING EXE") exe.save(dst) if output != "-": os.chmod(output, stat.S_IREAD | stat.S_IEXEC | stat.S_IWRITE)
def lint(input): src = sys.stdin if input == "-" else open(input) print("UNIT", a32.UnitParse(src, False))