tools/binary_size/libsupersize/archive.py
def CreateContainerAndSymbols(knobs=None,
                              opts=None,
                              container_name=None,
                              metadata=None,
                              map_path=None,
                              tool_prefix=None,
                              output_directory=None,
                              source_directory=None,
                              elf_path=None,
                              apk_path=None,
                              mapping_path=None,
                              resources_pathmap_path=None,
                              apk_so_path=None,
                              pak_files=None,
                              pak_info_file=None,
                              linker_name=None,
                              size_info_prefix=None):
  """Creates a Container (with sections sizes) and symbols for a SizeInfo.

  Args:
    knobs: Instance of SectionSizeKnobs.
    opts: Instance of ContainerArchiveOptions.
    container_name: Name for the created Container. May be '' if only one
        Container exists.
    metadata: Metadata dict from CreateMetadata().
    map_path: Path to the linker .map(.gz) file to parse.
    tool_prefix: Prefix for c++filt & nm (required).
    output_directory: Build output directory. If None, source_paths and symbol
        alias information will not be recorded.
    source_directory: Path to source root.
    elf_path: Path to the corresponding unstripped ELF file. Used to find symbol
        aliases and inlined functions. Can be None.
    apk_path: Path to the .apk file to measure.
    mapping_path: Path to the .mapping file for DEX symbol processing.
    resources_pathmap_path: Path to the pathmap file that maps original
        resource paths to shortened resource paths.
    apk_so_path: Path to an .so file within an APK file.
    pak_files: List of paths to .pak files.
    pak_info_file: Path to a .pak.info file.
    linker_name: A coded linker name (see linker_map_parser.py).
    size_info_prefix: Path to $out/size-info/$ApkName.

  Returns:
    A tuple of (container, raw_symbols).
    containers is a Container instance that stores metadata and section_sizes
    (section_sizes maps section names to respective sizes).
    raw_symbols is a list of Symbol objects.
  """
  assert elf_path or not opts.relocations_mode, (
      '--relocations-mode requires a ELF file')

  knobs = knobs or SectionSizeKnobs()
  if apk_path and apk_so_path:
    # Extraction takes around 1 second, so do it in parallel.
    apk_elf_result = parallel.ForkAndCall(_ElfInfoFromApk,
                                          (apk_path, apk_so_path, tool_prefix))
  else:
    apk_elf_result = None

  outdir_context = None
  object_source_mapper = None
  address_source_mapper = None
  section_ranges = {}
  raw_symbols = []
  if opts.analyze_native and output_directory:
    if map_path:
      # Finds all objects passed to the linker and creates a map of .o -> .cc.
      object_source_mapper, ninja_elf_object_paths = _ParseNinjaFiles(
          output_directory, elf_path)
    else:
      ninja_elf_object_paths = None
      logging.info('Parsing source path info via dwarfdump')
      address_source_mapper = dwarfdump.CreateAddressSourceMapper(
          elf_path, tool_prefix)

    # Start by finding elf_object_paths so that nm can run on them while the
    # linker .map is being parsed.
    if ninja_elf_object_paths:
      elf_object_paths, thin_archives = ar.ExpandThinArchives(
          ninja_elf_object_paths, output_directory)
      known_inputs = set(elf_object_paths)
      known_inputs.update(ninja_elf_object_paths)
    else:
      elf_object_paths = []
      known_inputs = None
      # When we don't know which elf file is used, just search all paths.
      if opts.analyze_native and object_source_mapper:
        thin_archives = set(
            p for p in object_source_mapper.IterAllPaths() if p.endswith('.a')
            and ar.IsThinArchive(os.path.join(output_directory, p)))
      else:
        thin_archives = None

    outdir_context = _OutputDirectoryContext(
        elf_object_paths=elf_object_paths,
        known_inputs=known_inputs,
        output_directory=output_directory,
        thin_archives=thin_archives)

  if opts.analyze_native:
    section_ranges, raw_symbols, object_paths_by_name = _ParseElfInfo(
        map_path,
        elf_path,
        tool_prefix,
        opts.track_string_literals,
        outdir_context=outdir_context,
        linker_name=linker_name)

  if apk_elf_result:
    section_ranges, elf_overhead_size = _ParseApkElfSectionRanges(
        section_ranges, metadata, apk_elf_result)
  elif elf_path:
    # Strip ELF before capturing section information to avoid recording
    # debug sections.
    with tempfile.NamedTemporaryFile(suffix=os.path.basename(elf_path)) as f:
      strip_path = path_util.GetStripPath(tool_prefix)
      subprocess.run([strip_path, '-o', f.name, elf_path], check=True)
      section_ranges = readelf.SectionInfoFromElf(f.name, tool_prefix)
      elf_overhead_size = _CalculateElfOverhead(section_ranges, f.name)

  if elf_path:
    raw_symbols, other_elf_symbols = _AddUnattributedSectionSymbols(
        raw_symbols, section_ranges)

  pak_symbols_by_id = None
  other_symbols = []
  if apk_path and size_info_prefix and not opts.relocations_mode:
    # Can modify |section_ranges|.
    pak_symbols_by_id = _FindPakSymbolsFromApk(opts, section_ranges, apk_path,
                                               size_info_prefix)

    # Can modify |section_ranges|.
    dex_size, other_symbols = _ParseApkOtherSymbols(section_ranges, apk_path,
                                                    apk_so_path,
                                                    resources_pathmap_path,
                                                    size_info_prefix, metadata,
                                                    knobs)

    if opts.analyze_java:
      dex_symbols = apkanalyzer.CreateDexSymbols(apk_path, mapping_path,
                                                 size_info_prefix)

      # We can't meaningfully track section size of dex methods vs other, so
      # just fake the size of dex methods as the sum of symbols, and make
      # "dex other" responsible for any unattributed bytes.
      dex_method_size = int(
          round(
              sum(s.pss for s in dex_symbols
                  if s.section_name == models.SECTION_DEX_METHOD)))
      section_ranges[models.SECTION_DEX_METHOD] = (0, dex_method_size)
      section_ranges[models.SECTION_DEX] = (0, dex_size - dex_method_size)

      dex_other_size = int(
          round(
              sum(s.pss for s in dex_symbols
                  if s.section_name == models.SECTION_DEX)))
      unattributed_dex = section_ranges[models.SECTION_DEX][1] - dex_other_size
      # Compare against -5 instead of 0 to guard against round-off errors.
      assert unattributed_dex >= -5, ('Dex symbols take up more space than '
                                      'the dex sections have available')
      if unattributed_dex > 0:
        dex_symbols.append(
            models.Symbol(
                models.SECTION_DEX,
                unattributed_dex,
                full_name='** .dex (unattributed - includes string literals)'))
      raw_symbols.extend(dex_symbols)

  elif pak_files and pak_info_file:
    # Can modify |section_ranges|.
    pak_symbols_by_id = _FindPakSymbolsFromFiles(
        section_ranges, pak_files, pak_info_file, output_directory)

  if elf_path:
    elf_overhead_symbol = models.Symbol(
        models.SECTION_OTHER, elf_overhead_size, full_name='Overhead: ELF file')
    _ExtendSectionRange(section_ranges, models.SECTION_OTHER, elf_overhead_size)
    other_symbols.append(elf_overhead_symbol)
    other_symbols.extend(other_elf_symbols)

  if pak_symbols_by_id:
    logging.debug('Extracting pak IDs from symbol names, and creating symbols')
    object_paths_by_pak_id = {}
    if opts.analyze_native:
      object_paths_by_pak_id = _CreatePakObjectMap(object_paths_by_name)
    pak_raw_symbols = _ParsePakSymbols(
        pak_symbols_by_id, object_paths_by_pak_id)
    raw_symbols.extend(pak_raw_symbols)

  # Always have .other come last.
  other_symbols.sort(key=lambda s: (s.IsOverhead(), s.full_name.startswith(
      '**'), s.address, s.full_name))
  raw_symbols.extend(other_symbols)

  _ExtractSourcePathsAndNormalizeObjectPaths(raw_symbols, object_source_mapper,
                                             address_source_mapper)
  dir_metadata.PopulateComponents(raw_symbols, source_directory)
  logging.info('Converting excessive aliases into shared-path symbols')
  _CompactLargeAliasesIntoSharedSymbols(raw_symbols, knobs)
  logging.debug('Connecting nm aliases')
  _ConnectNmAliases(raw_symbols)

  if opts.relocations_mode:
    raw_symbols = _OverwriteSymbolSizesWithRelocationCount(
        raw_symbols, tool_prefix, elf_path)

  section_sizes = {k: size for k, (address, size) in section_ranges.items()}
  container = models.Container(name=container_name,
                               metadata=metadata,
                               section_sizes=section_sizes)
  for symbol in raw_symbols:
    symbol.container = container

  # Sorting for relocations mode causes .data and .data.rel.ro to be interleaved
  # due to setting all addresses to 0.
  if not opts.relocations_mode:
    file_format.SortSymbols(raw_symbols, check_already_mostly_sorted=True)

  return container, raw_symbols
Creates a Container (with sections sizes) and symbols for a SizeInfo.

  Args:
    knobs: Instance of SectionSizeKnobs.
    opts: Instance of ContainerArchiveOptions.
    container_name: Name for the created Container. May be '' if only one
        Container exists.
    metadata: Metadata dict from CreateMetadata().
    map_path: Path to the linker .map(.gz) file to parse.
    tool_prefix: Prefix for c++filt & nm (required).
    output_directory: Build output directory. If None, source_paths and symbol
        alias information will not be recorded.
    source_directory: Path to source root.
    elf_path: Path to the corresponding unstripped ELF file. Used to find symbol
        aliases and inlined functions. Can be None.
    apk_path: Path to the .apk file to measure.
    mapping_path: Path to the .mapping file for DEX symbol processing.
    resources_pathmap_path: Path to the pathmap file that maps original
        resource paths to shortened resource paths.
    apk_so_path: Path to an .so file within an APK file.
    pak_files: List of paths to .pak files.
    pak_info_file: Path to a .pak.info file.
    linker_name: A coded linker name (see linker_map_parser.py).
    size_info_prefix: Path to $out/size-info/$ApkName.

  Returns:
    A tuple of (container, raw_symbols).
    containers is a Container instance that stores metadata and section_sizes
    (section_sizes maps section names to respective sizes).
    raw_symbols is a list of Symbol objects.
  
Creates a Container (with sections sizes) and symbols for a SizeInfo.
Creates a Container ( with sections sizes ) and symbols for a SizeInfo .
def CreateContainerAndSymbols(knobs=None,
                              opts=None,
                              container_name=None,
                              metadata=None,
                              map_path=None,
                              tool_prefix=None,
                              output_directory=None,
                              source_directory=None,
                              elf_path=None,
                              apk_path=None,
                              mapping_path=None,
                              resources_pathmap_path=None,
                              apk_so_path=None,
                              pak_files=None,
                              pak_info_file=None,
                              linker_name=None,
                              size_info_prefix=None):
  assert elf_path or not opts.relocations_mode, (
      '--relocations-mode requires a ELF file')
  knobs = knobs or SectionSizeKnobs()
  if apk_path and apk_so_path:
    apk_elf_result = parallel.ForkAndCall(_ElfInfoFromApk,
                                          (apk_path, apk_so_path, tool_prefix))
  else:
    apk_elf_result = None
  outdir_context = None
  object_source_mapper = None
  address_source_mapper = None
  section_ranges = {}
  raw_symbols = []
  if opts.analyze_native and output_directory:
    if map_path:
      object_source_mapper, ninja_elf_object_paths = _ParseNinjaFiles(
          output_directory, elf_path)
    else:
      ninja_elf_object_paths = None
      logging.info('Parsing source path info via dwarfdump')
      address_source_mapper = dwarfdump.CreateAddressSourceMapper(
          elf_path, tool_prefix)
    if ninja_elf_object_paths:
      elf_object_paths, thin_archives = ar.ExpandThinArchives(
          ninja_elf_object_paths, output_directory)
      known_inputs = set(elf_object_paths)
      known_inputs.update(ninja_elf_object_paths)
    else:
      elf_object_paths = []
      known_inputs = None
      if opts.analyze_native and object_source_mapper:
        thin_archives = set(
            p for p in object_source_mapper.IterAllPaths() if p.endswith('.a')
            and ar.IsThinArchive(os.path.join(output_directory, p)))
      else:
        thin_archives = None
    outdir_context = _OutputDirectoryContext(
        elf_object_paths=elf_object_paths,
        known_inputs=known_inputs,
        output_directory=output_directory,
        thin_archives=thin_archives)
  if opts.analyze_native:
    section_ranges, raw_symbols, object_paths_by_name = _ParseElfInfo(
        map_path,
        elf_path,
        tool_prefix,
        opts.track_string_literals,
        outdir_context=outdir_context,
        linker_name=linker_name)
  if apk_elf_result:
    section_ranges, elf_overhead_size = _ParseApkElfSectionRanges(
        section_ranges, metadata, apk_elf_result)
  elif elf_path:
    with tempfile.NamedTemporaryFile(suffix=os.path.basename(elf_path)) as f:
      strip_path = path_util.GetStripPath(tool_prefix)
      subprocess.run([strip_path, '-o', f.name, elf_path], check=True)
      section_ranges = readelf.SectionInfoFromElf(f.name, tool_prefix)
      elf_overhead_size = _CalculateElfOverhead(section_ranges, f.name)
  if elf_path:
    raw_symbols, other_elf_symbols = _AddUnattributedSectionSymbols(
        raw_symbols, section_ranges)
  pak_symbols_by_id = None
  other_symbols = []
  if apk_path and size_info_prefix and not opts.relocations_mode:
    pak_symbols_by_id = _FindPakSymbolsFromApk(opts, section_ranges, apk_path,
                                               size_info_prefix)
    dex_size, other_symbols = _ParseApkOtherSymbols(section_ranges, apk_path,
                                                    apk_so_path,
                                                    resources_pathmap_path,
                                                    size_info_prefix, metadata,
                                                    knobs)
    if opts.analyze_java:
      dex_symbols = apkanalyzer.CreateDexSymbols(apk_path, mapping_path,
                                                 size_info_prefix)
      dex_method_size = int(
          round(
              sum(s.pss for s in dex_symbols
                  if s.section_name == models.SECTION_DEX_METHOD)))
      section_ranges[models.SECTION_DEX_METHOD] = (0, dex_method_size)
      section_ranges[models.SECTION_DEX] = (0, dex_size - dex_method_size)
      dex_other_size = int(
          round(
              sum(s.pss for s in dex_symbols
                  if s.section_name == models.SECTION_DEX)))
      unattributed_dex = section_ranges[models.SECTION_DEX][1] - dex_other_size
      assert unattributed_dex >= -5, ('Dex symbols take up more space than '
                                      'the dex sections have available')
      if unattributed_dex > 0:
        dex_symbols.append(
            models.Symbol(
                models.SECTION_DEX,
                unattributed_dex,
                full_name='** .dex (unattributed - includes string literals)'))
      raw_symbols.extend(dex_symbols)
  elif pak_files and pak_info_file:
    pak_symbols_by_id = _FindPakSymbolsFromFiles(
        section_ranges, pak_files, pak_info_file, output_directory)
  if elf_path:
    elf_overhead_symbol = models.Symbol(
        models.SECTION_OTHER, elf_overhead_size, full_name='Overhead: ELF file')
    _ExtendSectionRange(section_ranges, models.SECTION_OTHER, elf_overhead_size)
    other_symbols.append(elf_overhead_symbol)
    other_symbols.extend(other_elf_symbols)
  if pak_symbols_by_id:
    logging.debug('Extracting pak IDs from symbol names, and creating symbols')
    object_paths_by_pak_id = {}
    if opts.analyze_native:
      object_paths_by_pak_id = _CreatePakObjectMap(object_paths_by_name)
    pak_raw_symbols = _ParsePakSymbols(
        pak_symbols_by_id, object_paths_by_pak_id)
    raw_symbols.extend(pak_raw_symbols)
  other_symbols.sort(key=lambda s: (s.IsOverhead(), s.full_name.startswith(
      '**'), s.address, s.full_name))
  raw_symbols.extend(other_symbols)
  _ExtractSourcePathsAndNormalizeObjectPaths(raw_symbols, object_source_mapper,
                                             address_source_mapper)
  dir_metadata.PopulateComponents(raw_symbols, source_directory)
  logging.info('Converting excessive aliases into shared-path symbols')
  _CompactLargeAliasesIntoSharedSymbols(raw_symbols, knobs)
  logging.debug('Connecting nm aliases')
  _ConnectNmAliases(raw_symbols)
  if opts.relocations_mode:
    raw_symbols = _OverwriteSymbolSizesWithRelocationCount(
        raw_symbols, tool_prefix, elf_path)
  section_sizes = {k: size for k, (address, size) in section_ranges.items()}
  container = models.Container(name=container_name,
                               metadata=metadata,
                               section_sizes=section_sizes)
  for symbol in raw_symbols:
    symbol.container = container
  if not opts.relocations_mode:
    file_format.SortSymbols(raw_symbols, check_already_mostly_sorted=True)
  return container, raw_symbols
def CreateContainerAndSymbols ( knobs = None , opts = None , container_name = None , metadata = None , map_path = None , tool_prefix = None , output_directory = None , source_directory = None , elf_path = None , apk_path = None , mapping_path = None , resources_pathmap_path = None , apk_so_path = None , pak_files = None , pak_info_file = None , linker_name = None , size_info_prefix = None ) : assert elf_path or not opts . relocations_mode , ( '--relocations-mode requires a ELF file' ) knobs = knobs or SectionSizeKnobs ( ) if apk_path and apk_so_path : apk_elf_result = parallel . ForkAndCall ( _ElfInfoFromApk , ( apk_path , apk_so_path , tool_prefix ) ) else : apk_elf_result = None outdir_context = None object_source_mapper = None address_source_mapper = None section_ranges = { } raw_symbols = [ ] if opts . analyze_native and output_directory : if map_path : object_source_mapper , ninja_elf_object_paths = _ParseNinjaFiles ( output_directory , elf_path ) else : ninja_elf_object_paths = None logging . info ( 'Parsing source path info via dwarfdump' ) address_source_mapper = dwarfdump . CreateAddressSourceMapper ( elf_path , tool_prefix ) if ninja_elf_object_paths : elf_object_paths , thin_archives = ar . ExpandThinArchives ( ninja_elf_object_paths , output_directory ) known_inputs = set ( elf_object_paths ) known_inputs . update ( ninja_elf_object_paths ) else : elf_object_paths = [ ] known_inputs = None if opts . analyze_native and object_source_mapper : thin_archives = set ( p for p in object_source_mapper . IterAllPaths ( ) if p . endswith ( '.a' ) and ar . IsThinArchive ( os . path . join ( output_directory , p ) ) ) else : thin_archives = None outdir_context = _OutputDirectoryContext ( elf_object_paths = elf_object_paths , known_inputs = known_inputs , output_directory = output_directory , thin_archives = thin_archives ) if opts . analyze_native : section_ranges , raw_symbols , object_paths_by_name = _ParseElfInfo ( map_path , elf_path , tool_prefix , opts . track_string_literals , outdir_context = outdir_context , linker_name = linker_name ) if apk_elf_result : section_ranges , elf_overhead_size = _ParseApkElfSectionRanges ( section_ranges , metadata , apk_elf_result ) elif elf_path : with tempfile . NamedTemporaryFile ( suffix = os . path . basename ( elf_path ) ) as f : strip_path = path_util . GetStripPath ( tool_prefix ) subprocess . run ( [ strip_path , '-o' , f . name , elf_path ] , check = True ) section_ranges = readelf . SectionInfoFromElf ( f . name , tool_prefix ) elf_overhead_size = _CalculateElfOverhead ( section_ranges , f . name ) if elf_path : raw_symbols , other_elf_symbols = _AddUnattributedSectionSymbols ( raw_symbols , section_ranges ) pak_symbols_by_id = None other_symbols = [ ] if apk_path and size_info_prefix and not opts . relocations_mode : pak_symbols_by_id = _FindPakSymbolsFromApk ( opts , section_ranges , apk_path , size_info_prefix ) dex_size , other_symbols = _ParseApkOtherSymbols ( section_ranges , apk_path , apk_so_path , resources_pathmap_path , size_info_prefix , metadata , knobs ) if opts . analyze_java : dex_symbols = apkanalyzer . CreateDexSymbols ( apk_path , mapping_path , size_info_prefix ) dex_method_size = int ( round ( sum ( s . pss for s in dex_symbols if s . section_name == models . SECTION_DEX_METHOD ) ) ) section_ranges [ models . SECTION_DEX_METHOD ] = ( 0 , dex_method_size ) section_ranges [ models . SECTION_DEX ] = ( 0 , dex_size - dex_method_size ) dex_other_size = int ( round ( sum ( s . pss for s in dex_symbols if s . section_name == models . SECTION_DEX ) ) ) unattributed_dex = section_ranges [ models . SECTION_DEX ] [ 1 ] - dex_other_size assert unattributed_dex >= - 5 , ( 'Dex symbols take up more space than ' 'the dex sections have available' ) if unattributed_dex > 0 : dex_symbols . append ( models . Symbol ( models . SECTION_DEX , unattributed_dex , full_name = '** .dex (unattributed - includes string literals)' ) ) raw_symbols . extend ( dex_symbols ) elif pak_files and pak_info_file : pak_symbols_by_id = _FindPakSymbolsFromFiles ( section_ranges , pak_files , pak_info_file , output_directory ) if elf_path : elf_overhead_symbol = models . Symbol ( models . SECTION_OTHER , elf_overhead_size , full_name = 'Overhead: ELF file' ) _ExtendSectionRange ( section_ranges , models . SECTION_OTHER , elf_overhead_size ) other_symbols . append ( elf_overhead_symbol ) other_symbols . extend ( other_elf_symbols ) if pak_symbols_by_id : logging . debug ( 'Extracting pak IDs from symbol names, and creating symbols' ) object_paths_by_pak_id = { } if opts . analyze_native : object_paths_by_pak_id = _CreatePakObjectMap ( object_paths_by_name ) pak_raw_symbols = _ParsePakSymbols ( pak_symbols_by_id , object_paths_by_pak_id ) raw_symbols . extend ( pak_raw_symbols ) other_symbols . sort ( key = lambda s : ( s . IsOverhead ( ) , s . full_name . startswith ( '**' ) , s . address , s . full_name ) ) raw_symbols . extend ( other_symbols ) _ExtractSourcePathsAndNormalizeObjectPaths ( raw_symbols , object_source_mapper , address_source_mapper ) dir_metadata . PopulateComponents ( raw_symbols , source_directory ) logging . info ( 'Converting excessive aliases into shared-path symbols' ) _CompactLargeAliasesIntoSharedSymbols ( raw_symbols , knobs ) logging . debug ( 'Connecting nm aliases' ) _ConnectNmAliases ( raw_symbols ) if opts . relocations_mode : raw_symbols = _OverwriteSymbolSizesWithRelocationCount ( raw_symbols , tool_prefix , elf_path ) section_sizes = { k : size for k , ( address , size ) in section_ranges . items ( ) } container = models . Container ( name = container_name , metadata = metadata , section_sizes = section_sizes ) for symbol in raw_symbols : symbol . container = container if not opts . relocations_mode : file_format . SortSymbols ( raw_symbols , check_already_mostly_sorted = True ) return container , raw_symbols
Creates a Container (with sections sizes) and symbols for a SizeInfo.
Creates a Container ( with sections sizes ) and symbols for a SizeInfo .
"""Creates a Container (with sections sizes) and symbols for a SizeInfo.

  Args:
    knobs: Instance of SectionSizeKnobs.
    opts: Instance of ContainerArchiveOptions.
    container_name: Name for the created Container. May be '' if only one
        Container exists.
    metadata: Metadata dict from CreateMetadata().
    map_path: Path to the linker .map(.gz) file to parse.
    tool_prefix: Prefix for c++filt & nm (required).
    output_directory: Build output directory. If None, source_paths and symbol
        alias information will not be recorded.
    source_directory: Path to source root.
    elf_path: Path to the corresponding unstripped ELF file. Used to find symbol
        aliases and inlined functions. Can be None.
    apk_path: Path to the .apk file to measure.
    mapping_path: Path to the .mapping file for DEX symbol processing.
    resources_pathmap_path: Path to the pathmap file that maps original
        resource paths to shortened resource paths.
    apk_so_path: Path to an .so file within an APK file.
    pak_files: List of paths to .pak files.
    pak_info_file: Path to a .pak.info file.
    linker_name: A coded linker name (see linker_map_parser.py).
    size_info_prefix: Path to $out/size-info/$ApkName.

  Returns:
    A tuple of (container, raw_symbols).
    containers is a Container instance that stores metadata and section_sizes
    (section_sizes maps section names to respective sizes).
    raw_symbols is a list of Symbol objects.
  """ # Extraction takes around 1 second, so do it in parallel. # Finds all objects passed to the linker and creates a map of .o -> .cc. # Start by finding elf_object_paths so that nm can run on them while the # linker .map is being parsed. # When we don't know which elf file is used, just search all paths. # Strip ELF before capturing section information to avoid recording # debug sections. # Can modify |section_ranges|. # Can modify |section_ranges|. # We can't meaningfully track section size of dex methods vs other, so # just fake the size of dex methods as the sum of symbols, and make # "dex other" responsible for any unattributed bytes. # Compare against -5 instead of 0 to guard against round-off errors. # Can modify |section_ranges|. # Always have .other come last. # Sorting for relocations mode causes .data and .data.rel.ro to be interleaved # due to setting all addresses to 0.
A tuple of (container, raw_symbols).
containers is a Container instance that stores metadata and section_sizes
(section_sizes maps section names to respective sizes).
raw_symbols is a list of Symbol objects.
A tuple of ( container raw_symbols ) . containers is a Container instance that stores metadata and section_sizes ( section_sizes maps section names to respective sizes ) . raw_symbols is a list of Symbol objects .
knobs
Instance of SectionSizeKnobs.
Instance of SectionSizeKnobs .
opts
Instance of ContainerArchiveOptions.
Instance of ContainerArchiveOptions .
container_name
Name for the created Container. May be '' if only one
Container exists.
Name for the created Container . May be ' ' if only one Container exists .
metadata
Metadata dict from CreateMetadata().
Metadata dict from CreateMetadata () .
map_path
Path to the linker .map(.gz) file to parse.
Path to the linker . map ( . gz ) file to parse .
tool_prefix
Prefix for c++filt & nm (required).
Prefix for c ++ filt & nm ( required ) .
output_directory
Build output directory. If None, source_paths and symbol
alias information will not be recorded.
Build output directory . If None source_paths and symbol alias information will not be recorded .
source_directory
Path to source root.
Path to source root .
elf_path
Path to the corresponding unstripped ELF file. Used to find symbol
aliases and inlined functions. Can be None.
Path to the corresponding unstripped ELF file . Used to find symbol aliases and inlined functions . Can be None .
apk_path
Path to the .apk file to measure.
Path to the . apk file to measure .
mapping_path
Path to the .mapping file for DEX symbol processing.
Path to the . mapping file for DEX symbol processing .
resources_pathmap_path
Path to the pathmap file that maps original
resource paths to shortened resource paths.
Path to the pathmap file that maps original resource paths to shortened resource paths .
apk_so_path
Path to an .so file within an APK file.
Path to an . so file within an APK file .
pak_files
List of paths to .pak files.
List of paths to . pak files .
pak_info_file
Path to a .pak.info file.
Path to a . pak . info file .
linker_name
A coded linker name .
A coded linker name .
size_info_prefix
Path to $out/size-info/$ApkName.
Path to $out / size - info / $ApkName .