Cracking libxul |
|||||||
|
|
Posted by: stak For a while now I've been wanting to take a look inside libxul to see why it's so big. In particular I wanted to know what the impact of using templates so heavily in our code was - things like nsTArray and nsRefPtr are probably used on hundreds of different types throughout our codebase. Last night I was have trouble sleeping so I decided to crack open libxul and see if I could figure it out. I didn't persist enough to get the exact answers I wanted, but I got close enough. It was also kind of fun and I figured I'd post about it partly as an educational thing and partly to inspire others to dig deeper into this.
objdump -d libxul.so > libxul.disasm
awk 'BEGIN { addr=0; label="";}
/:$/ && !/Disassembly of section/ { naddr = sprintf("%d", "0x" $1);
print (naddr-addr), label;
addr=naddr;
label=$2 }'
libxul.disasm > libxul.sizes
awk '{ total += $1 } END { print total }' libxul.sizes
40263032
sort -rn libxul.sizes | head -n 20 57984 <_ZL9InterpretP9JSContextRN2js8RunStateE>: 43798 <_ZN20nsHtml5AttributeName17initializeStaticsEv>: 41614 <_ZN22nsWindowMemoryReporter14CollectReportsEP25nsIMemoryReporterCallbackP11nsISupports>: 39792 <_Z7JS_Initv>: 32722 <vp9_fdct32x32_sse2>: 28674 <encode_mcu_huff>: 24365 <_Z7yyparseP13TParseContext>: 21800 <_ZN18nsHtml5ElementName17initializeStaticsEv>: 20558 <_ZN7mozilla3dom14PContentParent17OnMessageReceivedERKN3IPC7MessageE.part.1247>: 20302 <_ZN16nsHtml5Tokenizer9stateLoopI23nsHtml5ViewSourcePolicyEEiiDsiPDsbii>: 18367 <sctp_setopt>: 17900 <vp9_find_best_sub_pixel_comp_tree>: 16952 <_ZN7mozilla3dom13PBrowserChild17OnMessageReceivedERKN3IPC7MessageE>: 16096 <vp9_sad64x64x4d_sse2>: 15996 <_ZN7mozilla12_GLOBAL__N_119WebGLImageConverter3runILNS_16WebGLTexelFormatE17EEEvS3_NS_29WebGLTexelPremultiplicationOpE>: 15594 <_ZN7mozilla12_GLOBAL__N_119WebGLImageConverter3runILNS_16WebGLTexelFormatE16EEEvS3_NS_29WebGLTexelPremultiplicationOpE>: 14963 <vp9_idct32x32_1024_add_sse2>: 14838 <_ZN7mozilla12_GLOBAL__N_119WebGLImageConverter3runILNS_16WebGLTexelFormatE4EEEvS3_NS_29WebGLTexelPremultiplicationOpE>: 14792 <_ZN7mozilla12_GLOBAL__N_119WebGLImageConverter3runILNS_16WebGLTexelFormatE21EEEvS3_NS_29WebGLTexelPremultiplicationOpE>: 14740 <_ZN16nsHtml5Tokenizer9stateLoopI19nsHtml5SilentPolicyEEiiDsiPDsbii>:
grep "<_ZN13nsTArray_Impl" libxul.sizes | awk '{ total += $1 } END { print total }'
377522
|
||||||
|
(c) Kartikaya Gupta, 2004-2025. User comments owned by their respective posters. All rights reserved. You are accessing this website via IPv4. Consider upgrading to IPv6! |
objdump -T libxul.so
or
readelf -s libxul.so