Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Sep 2013 08:52:01 +0200
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Adrian Chadd <adrian@freebsd.org>
Cc:        Ed Schouten <ed@80386.nl>, FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: -ffunction-sections, -fdata-sections and -Wl,--gc-sections
Message-ID:  <B432059E-24BD-4799-9060-A3692DF78477@FreeBSD.org>
In-Reply-To: <CAJ-Vmok6kTizGaoxoAC5Gx0gDgpCYCSk3s4a%2BdhQsuTRZdBDaw@mail.gmail.com>
References:  <CAJOYFBBGY0GosPwG1B=1MKyapChEtX-O97r2zhXpGS8o7WO3gA@mail.gmail.com> <CAJ-Vmok6kTizGaoxoAC5Gx0gDgpCYCSk3s4a%2BdhQsuTRZdBDaw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Sep 16, 2013, at 03:08, Adrian Chadd <adrian@freebsd.org> wrote:
>> The results are interesting. On amd64:
>> 
>> - devd suddenly becomes 500 KB in size, instead of a megabyte,
>> - init's size drops from 900 KB to 600 KB,
>> - clang becomes a megabyte smaller.
>> 
> 
> .. so, I'd like to know specific information as to why these three are now
> smaller. So what's going on?


This is simply unreferenced code and data being eliminated.  It is quite
normal for libraries (libc, the LLVM libs, etc) to contain functions
that aren't called by the program you are linking.  However, any .o file
with multiple functions in it will be linked in as a whole, even if just
one of the functions is called.

I really think functions and data should always be separately "packaged"
in object files, but for some reason this has never been the default for
GNU tools, and everybody has apparently copied the behavior. :-)

-Dimitry


[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.20 (Darwin)

iEYEARECAAYFAlI2qp0ACgkQsF6jCi4glqNK2QCgxv0f/dTe+zYeVvpnz0kZfu80
N98AoNrFoJIo0eKO4vL8cRE5i2tL/r9k
=MnYI
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B432059E-24BD-4799-9060-A3692DF78477>