From: Shriramana Sharma <samjnaa@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: -ffunction-sections -Wl,--gc-sections trick and class members
Date: Thu, 19 Apr 2007 20:08:40 +0530 [thread overview]
Message-ID: <46277EF0.900@gmail.com> (raw)
I learnt from the good people on this list that usage of:
-fdata-sections -ffunction-sections -Wl,--gc-sections
will ensure that only those sections of object modules get linked to the
target which are actually used in the target.
Recently I was musing on whether I can use this when I recompile the Qt
4 libraries for static linking. But the thing is that the Qt libraries
are already very optimized in this aspect -- in that there is a separate
source file per class and consequently a separate object file per class.
However I was wondering whether even then I could do my
hyper-optimization because I will be using only a small number of
functions in each class. It is highly unlikely that I (or anyone else)
is going to use all member functions of a class.
Then I thought how I could possibly prevent linking a function which was
part of a class definition. To my understanding at runtime whenever a
class is loaded into memory (I'm not talking about the individual
instances) its members including functions are all loaded into memory.
If a particular function is not present for loading, wouldn't that be a
fatal error?
So the long and short of it is, are these options useful to filter out
unused class members or not?
Thanks as always,
Shriramana Sharma.
next reply other threads:[~2007-04-19 14:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-19 14:38 Shriramana Sharma [this message]
2007-04-19 15:13 ` -ffunction-sections -Wl,--gc-sections trick and class members Glynn Clements
2007-04-26 17:30 ` Shriramana Sharma
2007-05-04 13:31 ` Glynn Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46277EF0.900@gmail.com \
--to=samjnaa@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).