Re: -ffunction-sections -Wl,--gc-sections trick and class members

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

 



Shriramana Sharma wrote:

> > OTOH, I suspect that virtual methods are always "used" when
> > intialising the virtual method table, so it's less likely that they
> > could be omitted.
> > 
> > If you want a definite answer, test it.
> 
> Well I tested it and it is obvious that the trick is able to weed out 
> unused class members too -- run the contents of the attachment.
> 
> But I did not comprehend how you suspect that having virtual function (I 
> presume methods are the same as functions) will create different 
> results.

Non-virtual methods are referenced directly from the object file in
which they are used. If you don't call them, they won't be referenced.

Virtual methods are called through a function pointer in the virtual
method table. The only direct reference to the function will be in the
code which initialised the table. But that initialisation will occur
regardless of whether or not anything calls the method.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux