Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import sys
import os
sys.path.append('/Users/dmlockhart/vc/git-brg/parc/pymtl')
import pisa.elf as elf
import pisa.pisa_encoding as pisa_encoding
# Load the elf file
source_elf = sys.argv[1]
path, file_ = os.path.split( source_elf )
dest_elf = file_+'-new'
mem_image = None
with open(source_elf,'rb') as file_obj:
mem_image = elf.elf_reader( file_obj )
# Add a bootstrap section at address 0x400
bootstrap_asm = """
lui r29, 0x0007
ori r29, r0, 0xfffc
j 0x1000
"""
bootstrap_mem_image = pisa_encoding.assemble( bootstrap_asm )
bootstrap_bytes = bootstrap_mem_image.get_section(".text").data
mem_image.add_section( ".bootstrap", 0x400, bootstrap_bytes )
import struct
print len( bootstrap_bytes )
for i in [0, 4, 8]: