uroboros-diversification/src/postprocess/compile_process.py
def modifyARM():
    """
    Fix errors:
    - branch out of range
    - selected processor does not support `XXX' in Thumb mode
    - too large for field
    - co-processor offset out of range
    """
    reassemble(True)
    if not os.path.isfile('final.error'): return True
    with open('final.error') as f:
        lines = f.readlines()
    cbz = filter(lambda l: 'branch out of range' in l, lines)
    bad = filter(lambda l: 'processor does not support' in l, lines)
    tbb = filter(lambda l: 'too large for field of 1 bytes at' in l, lines)
    outrange = filter(lambda l: 'co-processor offset out of range' in l, lines)
    if sum(map(len, (cbz, bad, tbb, outrange))) == 0: return True
    patt = re.compile('final\.s\:([0-9]+)\:', re.I)
    errors = {}
    if len(cbz) > 0:
        cbz = map(lambda l: int(patt.match(l).group(1))-1, cbz)
        for c in cbz:
            errors[c] = cbzmapper()
    if len(bad) > 0:
        bpatt = re.compile("final\.s\:([0-9]+)\:[^`]+`([^']+)'", re.I)
        bad = map(lambda l: bpatt.match(l).groups(), bad)
        for b in bad:
            errors[int(b[0])-1] = badinstrmapper(b[1])
    if len(outrange) > 0:
        outrange = map(lambda l: int(patt.match(l).group(1))-1, outrange)
        for o in outrange:
            errors[o] = outofrangemapper()
    if len(tbb) > 0:
        tbb = map(lambda l: int(patt.match(l).group(1))-1, tbb)
        adjusttbb(tbb)
    with open('final.s') as f:
        lines = f.readlines()
    for c in sorted(errors.keys()):
        lines[c] = errors[c](lines[c])
    with open('final.s', 'w') as f:
        f.writelines(lines)

    return False

    Fix errors:
    - branch out of range
    - selected processor does not support `XXX' in Thumb mode
    - too large for field
    - co-processor offset out of range
    
Fix errors:
branch out of range
selected processor does not support `XXX' in Thumb mode
too large for field
co-processor offset out of range
Fix errors : branch out of range selected processor does not support ` XXX ' in Thumb mode too large for field co - processor offset out of range
def modifyARM():
    reassemble(True)
    if not os.path.isfile('final.error'): return True
    with open('final.error') as f:
        lines = f.readlines()
    cbz = filter(lambda l: 'branch out of range' in l, lines)
    bad = filter(lambda l: 'processor does not support' in l, lines)
    tbb = filter(lambda l: 'too large for field of 1 bytes at' in l, lines)
    outrange = filter(lambda l: 'co-processor offset out of range' in l, lines)
    if sum(map(len, (cbz, bad, tbb, outrange))) == 0: return True
    patt = re.compile('final\.s\:([0-9]+)\:', re.I)
    errors = {}
    if len(cbz) > 0:
        cbz = map(lambda l: int(patt.match(l).group(1))-1, cbz)
        for c in cbz:
            errors[c] = cbzmapper()
    if len(bad) > 0:
        bpatt = re.compile("final\.s\:([0-9]+)\:[^`]+`([^']+)'", re.I)
        bad = map(lambda l: bpatt.match(l).groups(), bad)
        for b in bad:
            errors[int(b[0])-1] = badinstrmapper(b[1])
    if len(outrange) > 0:
        outrange = map(lambda l: int(patt.match(l).group(1))-1, outrange)
        for o in outrange:
            errors[o] = outofrangemapper()
    if len(tbb) > 0:
        tbb = map(lambda l: int(patt.match(l).group(1))-1, tbb)
        adjusttbb(tbb)
    with open('final.s') as f:
        lines = f.readlines()
    for c in sorted(errors.keys()):
        lines[c] = errors[c](lines[c])
    with open('final.s', 'w') as f:
        f.writelines(lines)
    return False
def modifyARM ( ) : reassemble ( True ) if not os . path . isfile ( 'final.error' ) : return True with open ( 'final.error' ) as f : lines = f . readlines ( ) cbz = filter ( lambda l : 'branch out of range' in l , lines ) bad = filter ( lambda l : 'processor does not support' in l , lines ) tbb = filter ( lambda l : 'too large for field of 1 bytes at' in l , lines ) outrange = filter ( lambda l : 'co-processor offset out of range' in l , lines ) if sum ( map ( len , ( cbz , bad , tbb , outrange ) ) ) == 0 : return True patt = re . compile ( 'final\.s\:([0-9]+)\:' , re . I ) errors = { } if len ( cbz ) > 0 : cbz = map ( lambda l : int ( patt . match ( l ) . group ( 1 ) ) - 1 , cbz ) for c in cbz : errors [ c ] = cbzmapper ( ) if len ( bad ) > 0 : bpatt = re . compile ( "final\.s\:([0-9]+)\:[^`]+`([^']+)'" , re . I ) bad = map ( lambda l : bpatt . match ( l ) . groups ( ) , bad ) for b in bad : errors [ int ( b [ 0 ] ) - 1 ] = badinstrmapper ( b [ 1 ] ) if len ( outrange ) > 0 : outrange = map ( lambda l : int ( patt . match ( l ) . group ( 1 ) ) - 1 , outrange ) for o in outrange : errors [ o ] = outofrangemapper ( ) if len ( tbb ) > 0 : tbb = map ( lambda l : int ( patt . match ( l ) . group ( 1 ) ) - 1 , tbb ) adjusttbb ( tbb ) with open ( 'final.s' ) as f : lines = f . readlines ( ) for c in sorted ( errors . keys ( ) ) : lines [ c ] = errors [ c ] ( lines [ c ] ) with open ( 'final.s' , 'w' ) as f : f . writelines ( lines ) return False
Fix errors:
 branch out of range
 selected processor does not support `XXX' in Thumb mode
 too large for field
 co-processor offset out of range
Fix errors : branch out of range selected processor does not support ` XXX ' in Thumb mode too large for field co - processor offset out of range
"""
    Fix errors:
    - branch out of range
    - selected processor does not support `XXX' in Thumb mode
    - too large for field
    - co-processor offset out of range
    """