Skip to content

Commit 416af31

Browse files
authored
Fix various iOS treemap inaccuracies (#473)
1 parent 30b5a96 commit 416af31

File tree

8 files changed

+338
-200
lines changed

8 files changed

+338
-200
lines changed

src/launchpad/size/analyzers/apple.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,19 @@ def _extract_segments_info(self, binary: lief.MachO.Binary) -> List[SegmentInfo]
563563

564564
section_infos: List[SectionInfo] = []
565565
for section in command.sections:
566+
if section.segment.file_size == 0:
567+
logger.warning(
568+
"size.apple.skip_segment.zero_file_size",
569+
extra={
570+
"segment_name": segment_name,
571+
"section_name": section.name,
572+
},
573+
)
574+
continue
575+
566576
section_name = self._parse_lief_name(section.name)
567-
section_infos.append(SectionInfo(name=section_name, size=section.size))
577+
is_zerofill = section.type == lief.MachO.Section.TYPE.ZEROFILL
578+
section_infos.append(SectionInfo(name=section_name, size=section.size, is_zerofill=is_zerofill))
568579

569580
segments.append(
570581
SegmentInfo(

src/launchpad/size/models/apple.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class SectionInfo:
116116

117117
name: str
118118
size: int
119+
is_zerofill: bool # True if this section doesn't occupy file space (e.g., __bss)
119120

120121

121122
@dataclass

src/launchpad/size/models/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# so we can update treemap logic and not give users confusing diffs.
1616
# Patch versions are ignored.
1717
ANDROID_ANALYSIS_VERSION = "1.0.0"
18-
APPLE_ANALYSIS_VERSION = "1.1.0"
18+
APPLE_ANALYSIS_VERSION = "1.2.0"
1919

2020

2121
class BaseAppInfo(BaseModel):

src/launchpad/size/symbols/swift_aggregator.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@ def is_swift_symbol(mangled_name: str) -> bool:
3232
Includes:
3333
- _$s: Modern Swift mangling
3434
- _Tt: Older Swift mangling
35-
- __IVARS__Tt: ObjC runtime metadata for Swift classes
36-
- __DATA__Tt: Data section symbols for Swift types
35+
- __Tt: Swift classes exposed to ObjC with metadata
3736
"""
38-
if mangled_name.startswith("_$s") or mangled_name.startswith("_Tt"):
39-
return True
40-
# Swift classes exposed to ObjC have metadata with Swift mangling
41-
if "__Tt" in mangled_name:
37+
if mangled_name.startswith("_$s") or mangled_name.startswith("_Tt") or mangled_name.startswith("__Tt"):
4238
return True
4339
return False
4440

0 commit comments

Comments
 (0)