[SOLVED]: How to interpret library sizes reported by "size"
[SOLVED]: How to interpret library sizes reported by "size"
- Subject: [SOLVED]: How to interpret library sizes reported by "size"
- From: David Hoerl <email@hidden>
- Date: Fri, 25 Apr 2014 15:12:23 -0400
On 4/25/14, 2:24 PM, Kyle Sluder wrote:
On Fri, Apr 25, 2014, at 11:14 AM, David Hoerl wrote:
I have an iOS library (.a) and would like to determine the actual size
it will consume when linked into an app (client asked).
So, after a long time poking around trying to find the right tool, I
tripped on "size" (who would ever have guessed that name!):
$ size -arch arm64 myLib.a
__TEXT __DATA __OBJC others dec hex
18436 7156 0 42642 68234 10a8a myLib.a(a.o)
1659 528 0 7209 9396 24b4 myLib.a(b.o)
...
I know what text and data are, but have no clue as to what "others"
means. This is library is a Foundation Objective C library.
Can anyone shed some light on what "others" might be? Its significantly
larger than the "text" segment.
You can get a list of all the sections in a binary by using otool -l.
They'll be listed as part of the LC_SEGMENT or LC_SEGMENT_64 load
command. That'll tell you what sections the "other" column covers. (I'm
not sure knowing that has much use other than personal edification.)
--Kyle Sluder
Kyle's suggestion helped me figure out how to solve this. In addition to
"otool -l -arch arm64 lib.a", you can use "size -m -arch arm64 lib.a" to
see all segments and their sizes.
When I use the latter command on my library, I get a slew of segments
with prefix names of "__debug":
myLib.a(a.o):
Segment : 47665
Section (__TEXT, __text): 9832
Section (__DWARF, __debug_info): 9625
Section (__DWARF, __debug_abbrev): 867
Section (__DWARF, __debug_aranges): 64
Section (__DWARF, __debug_macinfo): 0
Section (__DWARF, __debug_line): 2142
Section (__DWARF, __debug_loc): 7237
Section (__DWARF, __debug_str): 4750
Section (__DWARF, __debug_ranges): 240
Section (__DATA, __data): 0
Section (__TEXT, __literal8): 16
...
Section (__DWARF, __apple_names): 2364
Section (__DWARF, __apple_objc): 196
Section (__DWARF, __apple_namespac): 36
Section (__DWARF, __apple_types): 1924
To get a reasonable figure, I need to get the full segment size and
subtract out the size of all the "__debug" prefixed segments.
# Get the full size of all object files in the library
$ size -m -arch arm64 *.a | grep '^.total' | sed -n -e 's/^.total //p' |
awk '{s+=$1} END {print s}'
381423
$
# Get the size of the debugging sections:
$ size -m -arch arm64 *.a | grep __debug_ | sed -n -e 's/^.*: //p' |
awk '{s+=$1} END {print s}'
212702
$
Total is thus 381423 - 212702 = 168721 # more or less
David
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden