Re: Missing(?) symbols in 'nm' output
Re: Missing(?) symbols in 'nm' output
- Subject: Re: Missing(?) symbols in 'nm' output
- From: Nick Blievers <email@hidden>
- Date: Mon, 30 Jan 2012 07:56:35 +1100
I don't think you are going to be able to reliably figure out the size of the last symbol in the __text section (btw __TEXT is the segment, __text is the section, segments contain sections) using this method. The gap is probably made up of some other sections (symbol_stub, cstring) that may be any size.
If you use otool -lh you can see the address ranges of each section, and using the start address to the end of the __text section should give you a size for that last symbol. The 's' symbols probably live in the __const section. This is obviously going to make your script a fair bit more complex... but maybe you are better off using 'otool -vt' to dump out the text section, and parse that? Might be easier.
Hope this helps,
Nick
On 30/01/2012, at 6:04 AM, Jens Alfke wrote:
> As I mentioned in a previous thread, I’m trying to figure out the size of the various functions/methods/data in a Mach-O binary. Yesterday I wrote a simple Ruby script that postprocesses the output of “nm -n” to subtract the addresses of adjacent symbols to determine their sizes.
>
> Mostly this works fine, but a few symbols show up as much too large. For example, in this instance _MYAfterDelay is a simple function that should occupy maybe a hundred bytes, but from the ‘nm’ output it looks like its size is 38601 bytes:
>> ...
>> 000000000001fd89 t -[NSObject(MYBlockUtils) my_run_as_block]
>> 000000000001fd97 t _MYAfterDelay
>> 0000000000029460 s _kDefaultTDChangesOptions
>> 0000000000029488 s _kDefaultTDQueryOptions
>
>
> Presumably there is something else occupying most of that intervening space, but ‘nm’ doesn’t tell me what it is. This may have something to do with the fact that _MYAfterDelay is the last symbol in the TEXT section, according to the output (since it’s sorted by address.)
>
> Anyone have enough understanding of the Mach-O format to know what might be going on? I’ve tried other options to ‘nm’ but didn’t find anything that showed me any other symbols in that gap.
>
> —Jens
>
>
> _______________________________________________
> 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
_______________________________________________
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