def qurt_image_build(argv):
  try:
    if argv[1] == 'build_eip':
      return ElfInfoPatch().Build_Asm(argv[2], int(argv[3]), argv[4:])
    infilenames, outfilename, physaddr = parse_args(argv)
    ''' Create a list of dictionaries, one for each of the input files '''
    infiles=[Elf_File(infile=f) for f in infilenames]
    for f in infiles:
      read_elf_info(f)
    patcher = QurtElfPatch()
    patcher.startr(infiles[0].file)
    ElfInfoPatch().Parse(patcher, infiles[0].start_addr, infiles[0].start_size)
    patcher.read_phys_island()
    do_fixups(patcher, infiles, physaddr)
    ''' Now figure out our basic relocation information '''
    process_input_files(infiles, physaddr)
    outfile = Elf_File(outfile=outfilename)
    ''' Populate the output file structure '''
    populate_output_file(outfile, infiles)
    dump_output_file(outfile, infiles)
    patcher.ProcessFile(physaddr, outfilename, infiles)
    if not no_adjust:
      for i in infiles:
        adjust_input_file(i, rename_input_file)
    return 0
  except Exception, err:
    from traceback import format_exc as tbstr
    print tbstr()
    print >> sys.stderr, "%s: %s" % (argv[0], str(err))
    return 1
def qurt_image_build(argv):
    try:
        if argv[1] == 'build_eip':
            return ElfInfoPatch().Build_Asm(argv[2], int(argv[3]), argv[4:])
        infilenames, outfilename, physaddr = parse_args(argv)
        ''' Create a list of dictionaries, one for each of the input files '''
        infiles = [Elf_File(infile=f) for f in infilenames]
        for f in infiles:
            read_elf_info(f)
        patcher = QurtElfPatch()
        patcher.startr(infiles[0].file)
        ElfInfoPatch().Parse(patcher, infiles[0].start_addr,
                             infiles[0].start_size)
        patcher.read_phys_island()
        do_fixups(patcher, infiles, physaddr)
        ''' Now figure out our basic relocation information '''
        process_input_files(infiles, physaddr)
        outfile = Elf_File(outfile=outfilename)
        ''' Populate the output file structure '''
        populate_output_file(outfile, infiles)
        dump_output_file(outfile, infiles)
        patcher.ProcessFile(physaddr, outfilename, infiles)
        if not no_adjust:
            for i in infiles:
                adjust_input_file(i, rename_input_file)
        return 0
    except Exception, err:
        from traceback import format_exc as tbstr
        print tbstr()
        print >> sys.stderr, "%s: %s" % (argv[0], str(err))
        return 1
 def run_command(self, argv):
     from traceback import format_exc as tbstr
     progname = argv[0]
     try:
         print ' '.join(argv)
         raw_args = argv[1:]
         args = [s for s in raw_args if not s == '--traceback']
         if args == raw_args:
             tbstr = None
         try:
             subfunc = getattr(self, '%s_subcommand' % args[0])
         except StandardError:
             self.usage()
         return subfunc(args[1:])
     except (SystemExit, KeyboardInterrupt):
         raise
     except Exception, err:
         if tbstr:
             print tbstr()
         print '%s: Error:\n*** %s' % (progname, err)
 def run_command(self, argv):
     from traceback import format_exc as tbstr
     progname = argv[0]
     try:
         print ' '.join(argv)
         raw_args = argv[1:]
         args = [s for s in raw_args if not s == '--traceback']
         if args == raw_args:
             tbstr = None
         try:
             subfunc = getattr(self, '%s_subcommand' % args[0])
         except StandardError:
             self.usage()
         return subfunc(args[1:])
     except (SystemExit, KeyboardInterrupt):
         raise
     except Exception, err:
         if tbstr:
             print tbstr()
         print '%s: Error:\n*** %s' % (progname, err)