def qsr20_builder(env, target, source, **kwargs): import os, sys, inspect sys.path += [env.subst("${BUILD_SCRIPTS_ROOT}/../../../qshrink/src")] sys.path += [env.subst("${BUILD_ROOT}/scripts/myps/qshrink")] sys.path += [ os.path.abspath( os.path.split( inspect.getframeinfo(inspect.currentframe()).filename)[0]) ] from QShrinkElf import runQShrink inputFile = env.RealPath(str(source[0])) hashFile = env.RealPath(str(source[1])) buildOutputPath = "" logFile = "" anomalyListFile = "" buildOutputPath = env.RealPath("${BUILD_ROOT}/build/myps/qshrink") outputFile = env.RealPath(str(target[0])) if len(target) == 1: qdbFile = "" else: qdbFile = env.RealPath(str(target[1])) replace_only = 1 use_linker_end_symbol = 1 runQShrink(inputFile, outputFile, buildOutputPath, hashFile, qdbFile, logFile, anomalyListFile, replace_only, use_linker_end_symbol) return None
def qsr20_builder(env, target, source, **kwargs): import sys sys.path += [env.subst("${BUILD_SCRIPTS_ROOT}/../../../qshrink/src")] sys.path += [env.subst("${BUILD_ROOT}/build/myps/qshrink")] from QShrinkElf import runQShrink inputFile = env.RealPath(str(source[0])) hashFile = env.RealPath(str(source[1])) outputFile = env.RealPath(str(target[0])) if len(target) == 1: qdbFile = "" else: qdbFile = env.RealPath(str(target[1])) logFile = re.split('\msg_hash.txt', hashFile)[0] + "qsr2" anomalyListFile = re.split('\msg_hash.txt', hashFile)[0] + "qsr2_an" replace_only = 1 use_linker_end_symbol = 1 runQShrink(inputFile, outputFile, hashFile, qdbFile, logFile, anomalyListFile, replace_only, use_linker_end_symbol) return None
def qsr20_builder(env, target, source, **kwargs): import sys sys.path += [ env.subst("${BUILD_SCRIPTS_ROOT}/../../../../qdsp6/qshrink/src") ] #from QShrinkElf import runQshrink30 from QShrinkElf import runQShrink from QShrinkElf import loadMapFileForMemLog inputFile = env.RealPath(str(source[0])) outputFile = env.RealPath(str(target[0])) hashFile = env.RealPath(str(source[1])) #ssHashFile = re.split('\msg_hash.txt', hashFile)[0] +"ss_hash.txt" logFile = re.split('\msg_hash.txt', hashFile)[0] + "qsr2" anomalyListFile = re.split('\msg_hash.txt', hashFile)[0] + "qsr2_an" replace_only = 1 memLog = 0 sclFile = "" mapFile = "" runQShrink(inputFile, outputFile, hashFile, sclFile, mapFile, logFile, anomalyListFile, replace_only, memLog) return None
def main(): from QShrinkElf import runQShrink from QShrinkElf import loadMapFileForMemLog opts, args = getopt.gnu_getopt(sys.argv[1:], "", [ 'output=', 'hashfile=', 'scl=', 'mapFile=', 'log=', 'discovery', 'discover_only', 'validate', 'memLog' ]) optDict = { '--output': [], '--hashfile': [], '--scl': [], '--mapFile': [], '--log': [], '--discovery': [], '--discover_only': [], '--validate': [], '--memLog': [] } if len(args) == 0: print 'Usage:\n + Qshrink20.py "inputElfFile"' print '\t --output="outElfFile"' print '\t --hashfile="msg hashfile"' print '\t --scl="scl_file"' print '\t --log="logfile"' print '\t --discovery discover and replace mode flag, else just replacement mode' print '\t --discover_only discover new strings, Elf file not modified' print '\t --memLog generate memory size log file from Mapfile' print '\t --mapFile="Map file, used with --memLog option"' print '\t --validate validate changes made' exit() for i in opts: optDict[i[0]].append(i[1]) for k in optDict: assert len(optDict[k]) <= 1 output = args[0] + ".shrunk" if len(optDict['--output']) == 1: output = optDict['--output'][0] hashFile = "msg_hash.txt" if len(optDict['--hashfile']) == 1: hashFile = optDict['--hashfile'][0] sclFile = re.split('\.', args[0])[0] + ".scl" if len(optDict['--scl']) == 1: sclFile = optDict['--scl'][0] mapFile = re.split('\.', args[0])[0] + ".map" if len(optDict['--mapFile']) == 1: mapFile = optDict['--mapFile'][0] logFile = "qsr2_" + re.split('\.', args[0])[0] if len(optDict['--log']) == 1: logFile = optDict['--log'][0] anomalyListFile = logFile + "_" + "qsr2_anlist" replace_only = 1 if len(optDict['--discovery']) == 1: replace_only = 0 if len(optDict['--discover_only']) == 1: replace_only = 2 memLog = 0 if len(optDict['--memLog']) == 1: memLog = 1 validate = 0 if len(optDict['--validate']) == 1: validate = 1 runQShrink(elfFile=args[0], outputFile=output, hashFile=hashFile, sclFile=sclFile, mapFile=mapFile, logFile=logFile, anomalyListFile=anomalyListFile, replace_only_mode=replace_only, memLog=memLog) if validate == 1: from QElfValidation import validateStructs validateStructs(outputFile=output, hashFile=hashFile)
def main(): from QShrinkElf import runQShrink opts, args = getopt.gnu_getopt(sys.argv[1:], "", [ 'output=', 'buildOutputPath=', 'hashfile=', 'qdbFile=', 'log=', 'discovery', 'discover_only', 'update_linker_script', 'mapFile=', 'lcsFile=', 'image_end_from_elfheader', 'validate' ]) optDict = { '--output': [], '--buildOutputPath': [], '--hashfile': [], '--qdbFile': [], '--log': [], '--discovery': [], '--discover_only': [], '--update_linker_script': [], '--mapFile': [], '--lcsFile': [], '--image_end_from_elfheader': [], '--validate': [] } for i in opts: optDict[i[0]].append(i[1]) update_linker_script_opt = 0 if len(opts) != 0: if len(optDict['--update_linker_script']) == 1: update_linker_script_opt = 1 if ((len(optDict['--mapFile']) != 1) or (len(optDict['--lcsFile']) != 1)): print 'Usage:\n + Qshrink20.py --update_linker_script --mapFile=<mapFile> --lcsFile=<lcsFile>' print '\t PS: Input elf file not needed' exit() else: if len(optDict['--update_linker_script']) == 1: mapFile = optDict['--mapFile'][0] lcsFile = optDict['--lcsFile'][0] from QElfValidation import updateLinkerScripts updateLinkerScripts(mapFile=mapFile, lcsFile=lcsFile) exit(0) if (update_linker_script_opt == 0) and len(args) == 0: print 'Usage:\n + Qshrink20.py "inputElfFile"' print '\t --output="outElfFile"' print '\t --buildOutputPath="output Directory for logs,generated hashfile"' print '\t --hashfile="msg hashfile"' print '\t --qdbFile="Qshrink DB loaded in device"' print '\t --log="logfile"' print '\t --discovery discover and replace mode flag, else just replacement mode' print '\t --discover_only discover new strings for QShrink 2.0/3.0, Elf file not modified' print '\t --update_linker_script Option for updating linker script using mapfile, linker script as input' print '\t --image_end_from_elfheader calculate image end address from elf file, else from linker end symbol' print '\t --validate validate changes made' exit() for k in optDict: assert len(optDict[k]) <= 1 output = args[0] + ".shrunk" if len(optDict['--output']) == 1: output = optDict['--output'][0] hashFile = "msg_hash.txt" if len(optDict['--hashfile']) == 1: hashFile = optDict['--hashfile'][0] qdbFile = "" if len(optDict['--qdbFile']) == 1: qdbFile = optDict['--qdbFile'][0] logFile = "" if len(optDict['--log']) == 1: logFile = optDict['--log'][0] buildOutputPath = "" if len(optDict['--buildOutputPath']) == 1: buildOutputPath = optDict['--buildOutputPath'][0] anomalyListFile = "" replace_only = 1 if len(optDict['--discovery']) == 1: replace_only = 0 if len(optDict['--discover_only']) == 1: replace_only = 2 linker_end_symbol = 1 if len(optDict['--image_end_from_elfheader']) == 1: linker_end_symbol = 0 validate = 0 if len(optDict['--validate']) == 1: validate = 1 runQShrink(elfFile=args[0], outputFile=output, buildOutputPath=buildOutputPath, hashFile=hashFile, qdbFile=qdbFile, logFile=logFile, anomalyListFile=anomalyListFile, replace_only_mode=replace_only, use_linker_end_symbol=linker_end_symbol) if validate == 1: from QElfValidation import validateStructs validateStructs(outputFile=output, hashFile=hashFile, qdbFile=qdbFile)
def main(): from QShrinkElf import runQShrink opts, args = getopt.gnu_getopt(sys.argv[1:], "", [ 'output=', 'hashfile=', 'qdbFile=', 'log=', 'discovery', 'discover_only', 'image_end_from_elfheader', 'validate' ]) optDict = { '--output': [], '--hashfile': [], '--qdbFile': [], '--log': [], '--discovery': [], '--discover_only': [], '--image_end_from_elfheader': [], '--validate': [] } if len(args) == 0: print 'Usage:\n + Qshrink20.py "inputElfFile"' print '\t --output="outElfFile"' print '\t --hashfile="msg hashfile"' print '\t --qdbFile="Qshrink DB loaded in device"' print '\t --log="logfile"' print '\t --discovery discover and replace mode flag, else just replacement mode' print '\t --discover_only discover new strings, Elf file not modified' print '\t --image_end_from_elfheader calculate image end address from elf file, else from linker end symbol' print '\t --validate validate changes made' exit() for i in opts: optDict[i[0]].append(i[1]) for k in optDict: assert len(optDict[k]) <= 1 output = args[0] + ".shrunk" if len(optDict['--output']) == 1: output = optDict['--output'][0] hashFile = "msg_hash.txt" if len(optDict['--hashfile']) == 1: hashFile = optDict['--hashfile'][0] qdbFile = "" if len(optDict['--qdbFile']) == 1: qdbFile = optDict['--qdbFile'][0] logFile = "qsr2_" + re.split('\.', args[0])[0] if len(optDict['--log']) == 1: logFile = optDict['--log'][0] anomalyListFile = logFile + "_" + "qsr2_anlist" replace_only = 1 if len(optDict['--discovery']) == 1: replace_only = 0 if len(optDict['--discover_only']) == 1: replace_only = 2 linker_end_symbol = 1 if len(optDict['--image_end_from_elfheader']) == 1: linker_end_symbol = 0 validate = 0 if len(optDict['--validate']) == 1: validate = 1 runQShrink(elfFile=args[0], outputFile=output, hashFile=hashFile, qdbFile=qdbFile, logFile=logFile, anomalyListFile=anomalyListFile, replace_only_mode=replace_only, use_linker_end_symbol=linker_end_symbol) if validate == 1: from QElfValidation import validateStructs validateStructs(outputFile=output, hashFile=hashFile)