public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* static executable bloat
@ 1999-08-19  0:29 Zack Weinberg
  1999-08-19  5:24 ` Andreas Schwab
  0 siblings, 1 reply; 23+ messages in thread
From: Zack Weinberg @ 1999-08-19  0:29 UTC (permalink / raw)
  To: libc-hacker

H.J. Lu wrote:
> > This is what I'm trying to solve:
> > 
> > $ cat t1.c
> > int main(void) { return 0; }
> > $ cat t2.c
> > int main(void) { return 0; }
> > 
> > void abort(void) { while(1); }
> > void atexit(void *x) { return; }
> > void exit(int x) { _exit(x); }
> > 
> > void *__libc_stack_end;
> > $ gcc -static t1.c -o t1
> > $ gcc -static t2.c -o t2
> > $ ls -l t1 t2
> > -rwxrwxr-x   1 zack     zack       222102 Aug 18 09:12 t1
> > -rwxrwxr-x   1 zack     zack         6215 Aug 18 09:12 t2
> > 
> > I want t1 to not be 220k.  The problem appears to be that the
> > implementations of abort and atexit suck in all kinds of stuff
> > transitively - mainly via libio.  I thought, late last night, that it
> > had to do with pthreads being referenced despite those being weak
> > symbols, but I was wrong.
> > 
> 
> Add -Wl,-Map,map. You should see what/why they are included in "map".

Yes, that works beautifully, thank you.

The problem is nothing to do with weak symbols.  It's very simple:

- abort flushes all open FILEs, so it pulls in stdio
- atexit and exit refer to malloc, and the malloc checking code pulls
  in stdio
- __libc_stack_end is defined only in dl-support.c, which pulls in the
  rest of the static libdl, which uses stdio

and

- stdio is 100k by itself
- the wide char support in stdio references the gconv infrastructure and
  the static libdl, which (with everything that uses) is another 100k

I spent a lot of time today bashing at this, but there is no easy fix.
I guess this is just a "libio should be smaller" whine.  Note that an
awful lot of places in there know when a stream is wide; it seems to
me that this ought to be hidden in the jump table.  There's no reason
why not to redirect _IO_setb instead of having _IO_setb and _IO_wsetb,
for example.

zw

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~1999-08-22 11:05 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-19  0:29 static executable bloat Zack Weinberg
1999-08-19  5:24 ` Andreas Schwab
1999-08-19  9:39   ` Roland McGrath
1999-08-19  9:57     ` Ulrich Drepper
1999-08-19 11:04       ` Roland McGrath
1999-08-19 11:08         ` Ulrich Drepper
1999-08-19 14:59           ` Thorsten Kukuk
1999-08-19 15:06             ` Ulrich Drepper
1999-08-19 15:17               ` Thorsten Kukuk
1999-08-19 15:41                 ` Ulrich Drepper
1999-08-20  7:20                   ` scottb
1999-08-21 16:21                     ` Philip Blundell
1999-08-22  9:20                       ` H.J. Lu
1999-08-22 10:06                         ` Ulrich Drepper
1999-08-22 10:11                           ` H.J. Lu
1999-08-22 10:44                             ` Ulrich Drepper
1999-08-22 11:05                         ` Philip Blundell
1999-08-21 17:57                   ` Cristian Gafton
1999-08-21 17:56                 ` Cristian Gafton
1999-08-21 17:54               ` Cristian Gafton
1999-08-19 17:45           ` Geoff Keating
1999-08-19 17:49             ` Ulrich Drepper
1999-08-19  9:57   ` Zack Weinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).