tools/binary_size/libsupersize/linker_map_parser.py
def DeduceObjectPathsFromThinMap(raw_symbols, extras):
  """Uses Thin-LTO object paths to find object_paths of symbols. """
  thin_map = extras.get('thin_map', None)  # |address| -> |thin_obj|
  if not thin_map:  # None or empty.
    logging.info('No thin-object-path found: Skipping object path deduction.')
    return

  # Build map of |thin_obj| -> |object_paths|.
  thin_obj_to_object_paths = collections.defaultdict(set)
  logging.info('Building map of thin-object-path -> object path.')
  for symbol in raw_symbols:
    if symbol.object_path:
      thin_obj = thin_map.get(symbol.address, None)
      if thin_obj:
        thin_obj_to_object_paths[thin_obj].add(symbol.object_path)

  # For each symbol without |object_path|, translate |address| -> |thin_obj| ->
  # |object_paths|. If unique, then assign to symbol. Stats are kept, keyed on
  # |len(object_paths)|.
  # Example symbols this happens with: ".L.ref.tmp", "** outlined function".
  logging.info('Assigning object paths to using ThinLTO paths.')
  ref_tmp_popu = [0] * 3
  ref_tmp_pss = [0] * 3
  for symbol in raw_symbols:
    if not symbol.object_path:
      thin_obj = thin_map.get(symbol.address)
      # Ignore non-native symbols.
      if thin_obj:
        count = 0
        object_paths = thin_obj_to_object_paths.get(thin_obj)
        if object_paths is not None:
          count = min(len(object_paths), 2)  # 2+ maps to 2.
          # We could create path aliases when count > 1, but it wouldn't
          # necessarily be correct. That occurs when *another* symbol from the
          # same .o file contains a path alias, but not necessarily this symbol.
          if count == 1:
            symbol.object_path = next(iter(object_paths))
        ref_tmp_popu[count] += 1
        ref_tmp_pss[count] += symbol.pss

  # As of Mar 2019:
  #   No match: 2 symbols with total PSS = 20
  #   Assigned (1 object path): 1098 symbols with total PSS = 55454
  #   Ambiguous (2+ object paths): 2315 symbols with total PSS = 41941
  logging.info('Object path deduction results for pathless symbols:')
  logging.info('  No match: %d symbols with total PSS = %d', ref_tmp_popu[0],
               ref_tmp_pss[0])
  logging.info('  Assigned (1 object path): %d symbols with total PSS = %d',
               ref_tmp_popu[1], ref_tmp_pss[1])
  logging.info('  Ambiguous (2+ object paths): %d symbols with total PSS = %d',
               ref_tmp_popu[2], ref_tmp_pss[2])
Uses Thin-LTO object paths to find object_paths of symbols. 
Uses Thin-LTO object paths to find object_paths of symbols.
Uses Thin - LTO object paths to find object_paths of symbols .
def DeduceObjectPathsFromThinMap(raw_symbols, extras):
  thin_map = extras.get('thin_map', None)  
  if not thin_map:  
    logging.info('No thin-object-path found: Skipping object path deduction.')
    return
  thin_obj_to_object_paths = collections.defaultdict(set)
  logging.info('Building map of thin-object-path -> object path.')
  for symbol in raw_symbols:
    if symbol.object_path:
      thin_obj = thin_map.get(symbol.address, None)
      if thin_obj:
        thin_obj_to_object_paths[thin_obj].add(symbol.object_path)
  logging.info('Assigning object paths to using ThinLTO paths.')
  ref_tmp_popu = [0] * 3
  ref_tmp_pss = [0] * 3
  for symbol in raw_symbols:
    if not symbol.object_path:
      thin_obj = thin_map.get(symbol.address)
      if thin_obj:
        count = 0
        object_paths = thin_obj_to_object_paths.get(thin_obj)
        if object_paths is not None:
          count = min(len(object_paths), 2)  
          if count == 1:
            symbol.object_path = next(iter(object_paths))
        ref_tmp_popu[count] += 1
        ref_tmp_pss[count] += symbol.pss
  logging.info('Object path deduction results for pathless symbols:')
  logging.info('  No match: %d symbols with total PSS = %d', ref_tmp_popu[0],
               ref_tmp_pss[0])
  logging.info('  Assigned (1 object path): %d symbols with total PSS = %d',
               ref_tmp_popu[1], ref_tmp_pss[1])
  logging.info('  Ambiguous (2+ object paths): %d symbols with total PSS = %d',
               ref_tmp_popu[2], ref_tmp_pss[2])
def DeduceObjectPathsFromThinMap ( raw_symbols , extras ) : thin_map = extras . get ( 'thin_map' , None ) if not thin_map : logging . info ( 'No thin-object-path found: Skipping object path deduction.' ) return thin_obj_to_object_paths = collections . defaultdict ( set ) logging . info ( 'Building map of thin-object-path -> object path.' ) for symbol in raw_symbols : if symbol . object_path : thin_obj = thin_map . get ( symbol . address , None ) if thin_obj : thin_obj_to_object_paths [ thin_obj ] . add ( symbol . object_path ) logging . info ( 'Assigning object paths to using ThinLTO paths.' ) ref_tmp_popu = [ 0 ] * 3 ref_tmp_pss = [ 0 ] * 3 for symbol in raw_symbols : if not symbol . object_path : thin_obj = thin_map . get ( symbol . address ) if thin_obj : count = 0 object_paths = thin_obj_to_object_paths . get ( thin_obj ) if object_paths is not None : count = min ( len ( object_paths ) , 2 ) if count == 1 : symbol . object_path = next ( iter ( object_paths ) ) ref_tmp_popu [ count ] += 1 ref_tmp_pss [ count ] += symbol . pss logging . info ( 'Object path deduction results for pathless symbols:' ) logging . info ( '  No match: %d symbols with total PSS = %d' , ref_tmp_popu [ 0 ] , ref_tmp_pss [ 0 ] ) logging . info ( '  Assigned (1 object path): %d symbols with total PSS = %d' , ref_tmp_popu [ 1 ] , ref_tmp_pss [ 1 ] ) logging . info ( '  Ambiguous (2+ object paths): %d symbols with total PSS = %d' , ref_tmp_popu [ 2 ] , ref_tmp_pss [ 2 ] )
Uses Thin-LTO object paths to find object_paths of symbols.
Uses Thin - LTO object paths to find object_paths of symbols .
"""Uses Thin-LTO object paths to find object_paths of symbols. """ # |address| -> |thin_obj| # None or empty. # Build map of |thin_obj| -> |object_paths|. # For each symbol without |object_path|, translate |address| -> |thin_obj| -> # |object_paths|. If unique, then assign to symbol. Stats are kept, keyed on # |len(object_paths)|. # Example symbols this happens with: ".L.ref.tmp", "** outlined function". # Ignore non-native symbols. # 2+ maps to 2. # We could create path aliases when count > 1, but it wouldn't # necessarily be correct. That occurs when *another* symbol from the # same .o file contains a path alias, but not necessarily this symbol. # As of Mar 2019: #   No match: 2 symbols with total PSS = 20 #   Assigned (1 object path): 1098 symbols with total PSS = 55454 #   Ambiguous (2+ object paths): 2315 symbols with total PSS = 41941
raw_symbols
extras