Skip to content

Commit 48ae46c

Browse files
committed
fix
1 parent d7b5dec commit 48ae46c

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

src/launchpad/size/insights/apple/main_binary_export_metadata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def generate(self, input: InsightsInput) -> MainBinaryExportMetadataResult | Non
1717
if not analysis.is_main_binary:
1818
continue
1919

20-
dyld_info = analysis.dyld_info
21-
if dyld_info is None:
20+
linkedit_info = analysis.linkedit_info
21+
if linkedit_info is None:
2222
continue
2323

24-
export_trie_size = dyld_info.export_trie_size
24+
export_trie_size = linkedit_info.export_trie_size
2525
if export_trie_size >= self.MIN_EXPORTS_THRESHOLD:
2626
export_files.append(
2727
FileSavingsResult(

tests/integration/size/test_treemap_generation.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,27 @@ def find_node_by_path(root: TreemapElement, path: str) -> TreemapElement | None:
361361
# Verify __LINKEDIT segment
362362
has_linkedit = "__LINKEDIT" in main_exe_sections
363363
assert has_linkedit
364-
linkedit_size = main_exe_sections["__LINKEDIT"].size
364+
linkedit = main_exe_sections["__LINKEDIT"]
365+
linkedit_size = linkedit.size
365366
assert linkedit_size == 269360
366367

368+
# Verify __LINKEDIT has children (symbol table, string table, etc.)
369+
linkedit_children = {child.name: child for child in linkedit.children}
370+
assert len(linkedit_children) == 6, "__LINKEDIT should have exactly 6 child components"
371+
372+
# Verify expected __LINKEDIT components exist
373+
assert "Symbol Table" in linkedit_children, "Symbol table should be present"
374+
assert "String Table" in linkedit_children, "String table should be present"
375+
assert "Function Starts" in linkedit_children, "Function starts should be present"
376+
377+
# Verify exact sizes for __LINKEDIT components
378+
assert linkedit_children["Symbol Table"].size == 11072, "Symbol table size mismatch"
379+
assert linkedit_children["String Table"].size == 16584, "String table size mismatch"
380+
assert linkedit_children["Function Starts"].size == 13584, "Function starts size mismatch"
381+
assert linkedit_children["Chained Fixups"].size == 87616, "Chained fixups size mismatch"
382+
assert linkedit_children["Export Trie"].size == 85056, "Export trie size mismatch"
383+
assert linkedit_children["Code Signature"].size == 43488, "Code signature size mismatch"
384+
367385
# Verify Unmapped section (track size changes)
368386
has_unmapped = "Unmapped" in main_exe_sections
369387
assert has_unmapped

tests/unit/test_main_binary_export_metadata_insight.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from launchpad.size.insights.apple.main_binary_export_metadata import MainBinaryExportMetadataInsight
44
from launchpad.size.insights.insight import InsightsInput
5-
from launchpad.size.models.apple import DyldInfo, MachOBinaryAnalysis
5+
from launchpad.size.models.apple import LinkEditInfo, MachOBinaryAnalysis
66
from launchpad.size.models.common import BaseAppInfo, FileAnalysis
77
from launchpad.size.models.insights import MainBinaryExportMetadataResult
88

@@ -26,7 +26,7 @@ def test_generate_with_main_binary_and_dyld_exports_trie(self):
2626
swift_metadata=None,
2727
is_main_binary=True,
2828
header_size=32,
29-
dyld_info=DyldInfo(export_trie_size=5000),
29+
linkedit_info=LinkEditInfo(export_trie_size=5000),
3030
)
3131

3232
insights_input = InsightsInput(
@@ -42,7 +42,7 @@ def test_generate_with_main_binary_and_dyld_exports_trie(self):
4242
assert result.total_savings == 5000
4343

4444
def test_generate_with_main_binary_without_dyld_exports_trie(self):
45-
"""Test that no insight is generated when main binary has no dyld_info."""
45+
"""Test that no insight is generated when main binary has no linkedit_info."""
4646
main_binary_analysis = MachOBinaryAnalysis(
4747
binary_absolute_path=Path("MyApp"),
4848
binary_relative_path=Path("MyApp"),
@@ -56,7 +56,7 @@ def test_generate_with_main_binary_without_dyld_exports_trie(self):
5656
swift_metadata=None,
5757
is_main_binary=True,
5858
header_size=32,
59-
dyld_info=None, # No dyld_info
59+
linkedit_info=None, # No linkedit_info
6060
)
6161

6262
insights_input = InsightsInput(
@@ -85,7 +85,7 @@ def test_generate_with_no_main_binary(self):
8585
swift_metadata=None,
8686
is_main_binary=False, # Not a main binary
8787
header_size=32,
88-
dyld_info=DyldInfo(export_trie_size=5000), # Has export trie but not main binary
88+
linkedit_info=LinkEditInfo(export_trie_size=5000), # Has export trie but not main binary
8989
)
9090

9191
insights_input = InsightsInput(
@@ -114,7 +114,7 @@ def test_generate_with_main_binary_but_empty_export_trie(self):
114114
swift_metadata=None,
115115
is_main_binary=True,
116116
header_size=32,
117-
dyld_info=DyldInfo(export_trie_size=0), # Zero-size export trie
117+
linkedit_info=LinkEditInfo(export_trie_size=0), # Zero-size export trie
118118
)
119119

120120
insights_input = InsightsInput(
@@ -156,7 +156,7 @@ def test_generate_with_multiple_binaries_one_main(self):
156156
swift_metadata=None,
157157
is_main_binary=True,
158158
header_size=32,
159-
dyld_info=DyldInfo(export_trie_size=8000),
159+
linkedit_info=LinkEditInfo(export_trie_size=8000),
160160
)
161161

162162
# Create framework binary (non-main)
@@ -173,7 +173,7 @@ def test_generate_with_multiple_binaries_one_main(self):
173173
swift_metadata=None,
174174
is_main_binary=False,
175175
header_size=32,
176-
dyld_info=DyldInfo(export_trie_size=3000), # Framework also has export trie but won't be included
176+
linkedit_info=LinkEditInfo(export_trie_size=3000), # Framework also has export trie but won't be included
177177
)
178178

179179
insights_input = InsightsInput(
@@ -203,7 +203,7 @@ def test_generate_with_export_trie_below_threshold(self):
203203
swift_metadata=None,
204204
is_main_binary=True,
205205
header_size=32,
206-
dyld_info=DyldInfo(export_trie_size=512), # Below MIN_EXPORTS_THRESHOLD (1024)
206+
linkedit_info=LinkEditInfo(export_trie_size=512), # Below MIN_EXPORTS_THRESHOLD (1024)
207207
)
208208

209209
insights_input = InsightsInput(
@@ -232,7 +232,7 @@ def test_generate_with_export_trie_at_threshold(self):
232232
swift_metadata=None,
233233
is_main_binary=True,
234234
header_size=32,
235-
dyld_info=DyldInfo(export_trie_size=1024), # Exactly at MIN_EXPORTS_THRESHOLD
235+
linkedit_info=LinkEditInfo(export_trie_size=1024), # Exactly at MIN_EXPORTS_THRESHOLD
236236
)
237237

238238
insights_input = InsightsInput(

0 commit comments

Comments
 (0)