29 table_stats_symbol = {}
31 section_total_size = 0
39 lines =
open(filename, encoding=
'utf-8', errors=
'ignore').readlines()
41 line_stripped = line[:-1]
42 if "# Object files:" == line_stripped:
45 elif "# Sections:" == line_stripped:
48 elif "# Symbols:" == line_stripped:
51 elif "# Dead Stripped Symbols:" == line_stripped:
56 segs = re.search(
'(\[ *[0-9]*\]) (.*)', line_stripped)
57 table_tag[segs.group(1)] = segs.group(2)
59 if state ==
"section":
60 if len(line_stripped) == 0
or line_stripped[0] ==
'#':
62 segs = re.search(
'^(.+?)\s+(.+?)\s+.*', line_stripped)
63 section_total_size +=
int(segs.group(2), 16)
66 if len(line_stripped) == 0
or line_stripped[0] ==
'#':
68 segs = re.search(
'^.+?\s+(.+?)\s+(\[.+?\]).*', line_stripped)
71 target = table_tag[segs.group(2)]
72 target_stripped = re.search(
'^(.*?)(\(.+?\))?$', target).
group(1)
73 size =
int(segs.group(1), 16)
74 if not target_stripped
in table_stats_symbol:
75 table_stats_symbol[target_stripped] = 0
76 table_stats_symbol[target_stripped] += size
77 if 'BoringSSL' in target_stripped:
78 boringssl_size += size
79 elif 'libgRPC-Core' in target_stripped:
81 elif 'libgRPC-RxLibrary' in target_stripped
or \
82 'libgRPC' in target_stripped
or \
83 'libgRPC-ProtoLibrary' in target_stripped:
85 elif 'libProtobuf' in target_stripped:
88 for target
in table_stats_symbol:
89 symbol_total_size += table_stats_symbol[target]
91 return core_size, objc_size, boringssl_size, protobuf_size, symbol_total_size
95 filename = sys.argv[1]
96 core_size, objc_size, boringssl_size, protobuf_size, total_size =
parse_link_map(
98 print((
'Core size:{:,}'.
format(core_size)))
99 print((
'ObjC size:{:,}'.
format(objc_size)))
100 print((
'BoringSSL size:{:,}'.
format(boringssl_size)))
101 print((
'Protobuf size:{:,}\n'.
format(protobuf_size)))
102 print((
'Total size:{:,}'.
format(total_size)))
105 if __name__ ==
"__main__":