tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Trivial program size inflation

> On Jun 30, 2023, at 11:30 PM, wrote:
> Le Fri, Jun 30, 2023 at 01:37:10PM -0400, Mouse a écrit :
>> Based on something at work, I was looking at executable sizes.  I
>> eventually tried a program stripped about as far down as I could:
>> int main(void);
>> int main(void)
>> {
>> return(0);
>> }
>> and built it -static.  size on the resulting binary:

Ok, so:

the-ripe-vessel:thorpej 10$ cat nop.c
int main(void) { return 0; }
the-ripe-vessel:thorpej 11$ cc -static nop.c
the-ripe-vessel:thorpej 12$ size a.out       
   text    data     bss     dec     hex filename
 581799   28928 2176553 2787280  2a87d0 a.out
the-ripe-vessel:thorpej 13$ cc --version
cc (nb1 20210411) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

the-ripe-vessel:thorpej 14$ 

Should be pretty trivial to see what’s in there…

the-ripe-vessel:thorpej 15$ nm a.out | wc -l
the-ripe-vessel:thorpej 16$ nm a.out | grep printf
0000000000470176 T __vfprintf_unlocked_l
000000000046e96d T _snprintf
000000000046e9fc T _snprintf_l
0000000000410319 T _snprintf_ss
0000000000474706 T _vfprintf_l
000000000046e95b T _vsnprintf
000000000046e720 T _vsnprintf_l
000000000046d440 T _vsnprintf_ss
00000000004370cf T je_malloc_cprintf
0000000000437151 T je_malloc_printf
0000000000436fcc T je_malloc_snprintf
000000000043704e T je_malloc_vcprintf
0000000000434da1 T je_malloc_vsnprintf
000000000046e96d W snprintf
000000000046e9fc W snprintf_l
0000000000410319 W snprintf_ss
00000000004746b1 T vfprintf
0000000000474706 W vfprintf_l
000000000046e95b W vsnprintf
000000000046e720 W vsnprintf_l
000000000046d440 W vsnprintf_ss
the-ripe-vessel:thorpej 17$ 

Hmmm, who is calling stdio routines here?

the-ripe-vessel:thorpej 19$ nm a.out | grep "je_" | wc -l
the-ripe-vessel:thorpej 20$ 

Oh look, the entirety of jemalloc seems to be included in the binary.  WTF knows why that’s happening, but apparently it is, and jemalloc pulls in a ton of additional stuff.

Someone should maybe take a look into that.

-- thorpej

Home | Main Index | Thread Index | Old Index