4

I have an iOS application which uses a lot of different static libraries and frameworks (some third party as well). I want to be able to attribute the contribution of the static libs, frameworks & app code to the final app binary size. I came across a previously asked similar question here at: Find size contributed by each external library on iOS

The answer by 'fullofsquirells' is relevant and is well-explained. However, using the link map file approach, if I add up the sizes of all the sections or all the symbols I don't get the final binary size.

More details: My iOS Application's final ipa is ~50 MB. The uncompressed app payload is ~90 MB and contains approx. 50 MB code and 40 MB resources. The 50 MB code binary contains two binary slices corresponding to armv7 and arm64. I can get the separate slices using 'lipo' and each are of approximately similar size, 23 MB(armv7) and 27 MB(arm64).

Using the linkmap approach I am able to get the sizes from the sections as well as from the symbols for each slice (note there is a separate linkmap file for each slice). The problem is if I sum up the sizes of all the sections or all the symbols it does not total upto the app binary size for that slice.

Supposing I have the symbols & sections for arm64 in symbols_arm64.txt & sections_arm64.txt, then:

cat symbols_arm64.txt |grep -e "0x" | awk '{print $2}'| xargs printf "%d\n"|paste -sd+ -|bc

cat sections_arm64.txt |grep -e "0x" | awk '{print $2}'| xargs printf "%d\n"|paste -sd+ -|bc

Both of these return values which are closer to ~15 MB. I was expecting that both of these would be closer to 27 MB.

What is contributing the missing 12 MB?

Community
  • 1
  • 1
bullzi
  • 61
  • 6

1 Answers1

1

In addition to the data and text sections that are enlisted in the second section in the link map file, there is an additional section called "linkEdit" section. This section is used by the DYLD. More info about LinkEdit at: http://newosxbook.com/articles/DYLD.html One can get rid of it by setting the DEPLOYMENT_POSTPROCESSING to "YES". This will strip off all the symbols, and among other things will also remove the LinkEdit section from the final binary. Infact it is recommended to do so in the release binary, when the app size is a concern. More info about this is present in an Apple Tech note: https://developer.apple.com/library/mac/technotes/tn2004/tn2123.html

bullzi
  • 61
  • 6