Mario A Guzman February 2016

Otool - Get file size only

I'm using Otool to look into a compiled library (.a) and I want to see what the file size of each component in the binary is. I see that

otool -l [lib.a]

will show me this information but there is also a LOT of other information I do not need. Is there a way I can just see the file size and not everything else? I can't seem to find it if there is.

Answers


Thomas Dickey February 2016

The size command does that, e.g.,

size lib.a

will show the size of each object stored in the lib.a archive. For example:

$ size libasprintf.a
   text    data     bss     dec     hex filename
      0       0       0       0       0 lib-asprintf.o (ex libasprintf.a)
    639       8       1     648     288 autosprintf.o (ex libasprintf.a)

on most systems. OS X format is a little different:

$ size libl.a
__TEXT  __DATA  __OBJC  others  dec     hex
86      0       0       32      118     76      libl.a(libmain.o)
75      0       0       32      107     6b      libl.a(libyywrap.o)

Oddly (though "everyone" implements it), I do not see size on the POSIX site. OS X has a manual page for it.

Post Status

Asked in February 2016
Viewed 2,134 times
Voted 6
Answered 1 times

Search




Leave an answer