Esempio n. 1
0
def HasBitcodeInputs(inputs):
  for f in inputs:
    if ldtools.IsFlag(f):
      continue
    elif filetype.IsLLVMBitcode(f) or filetype.IsBitcodeArchive(f):
      return True
  return False
Esempio n. 2
0
def CheckInputsArch(inputs):
  count = 0
  for f in inputs:
    if ldtools.IsFlag(f):
      continue
    elif filetype.IsLLVMBitcode(f) or filetype.IsBitcodeArchive(f):
      pass
    elif filetype.IsNative(f):
      ArchMerge(f, True)
    else:
      Log.Fatal("%s: Unexpected type of file for linking (%s)",
                pathtools.touser(f), filetype.FileType(f))
    count += 1

  if count == 0:
    Log.Fatal("no input files")
Esempio n. 3
0
def FindFile(search_names, search_dirs, acceptable_types):
  for curdir in search_dirs:
    for name in search_names:
      path = pathtools.join(curdir, name)
      if pathtools.exists(path):
        if acceptable_types == LibraryTypes.ANY:
          return path
        # Linker scripts aren't classified as Native or Bitcode.
        if filetype.IsLinkerScript(path):
          return path
        if (acceptable_types == LibraryTypes.NATIVE and
            filetype.IsNative(path)):
          return path
        if (acceptable_types == LibraryTypes.BITCODE and
            (filetype.IsLLVMBitcode(path) or
             filetype.IsBitcodeArchive(path))):
          return path
  return None
Esempio n. 4
0
def main(argv):
    env.update(EXTRA_ENV)
    driver_tools.ParseArgs(argv, StripPatterns)
    inputs = env.get('INPUTS')
    output = env.getone('OUTPUT')
    for path in inputs + [output]:
        driver_tools.CheckPathLength(path)

    if len(inputs) > 1 and output != '':
        Log.Fatal('Cannot have -o with multiple inputs')

    if '--info' in env.get('STRIP_FLAGS'):
        code, _, _ = driver_tools.Run('${STRIP} ${STRIP_FLAGS}')
        return code

    for f in inputs:
        if output != '':
            f_output = output
        else:
            f_output = f
        if filetype.IsPNaClBitcode(f):
            # PNaCl-format bitcode has no symbols, i.e. it is already stripped.
            if f != f_output:
                shutil.copyfile(f, f_output)
        elif filetype.IsLLVMBitcode(f):
            driver_tools.RunWithEnv('${RUN_OPT}', input=f, output=f_output)
        elif filetype.IsELF(f) or filetype.IsNativeArchive(f):
            driver_tools.RunWithEnv('${RUN_STRIP}', input=f, output=f_output)
        elif filetype.IsBitcodeArchive(f):
            # The strip tool supports native archives, but it does not support the
            # LLVM gold plugin so cannot handle bitcode.  There is also no bitcode
            # tool like opt that support archives.
            Log.Fatal('%s: strip does not support bitcode archives',
                      pathtools.touser(f))
        else:
            Log.Fatal('%s: File is neither ELF, nor bitcode',
                      pathtools.touser(f))
    return 0