-ffunction-sections, -fdata-sections and -Wl,--gc-sections
Dimitry Andric
dim at FreeBSD.org
Mon Sep 16 06:52:18 UTC 2013
On Sep 16, 2013, at 03:08, Adrian Chadd <adrian at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20130916/a8119bad/attachment.sig>
More information about the freebsd-current
mailing list