Do weak variables waste mem?

Thomas Schmid scth2000@yahoo.de
Wed Feb 25 23:31:00 GMT 2015





Alan Modra schrieb am 24.02.2015 23:33:
> You have defined two copies of the variables.  Without the
> __attribute__((__weak__)) you also have two definitions of each
> variable, but some compilers (including gcc) treat them specially - as
> common variables.  You should instead declare the variables as extern

> in the header, and define them in one of the source files.

When you say "two copies of the variables", you mean that each object uses its own variable?
When i look at the symbol table, only one variable is used.


I agree that defining the variables explicitly is the better solution, but this declarations are generated and not easy to change.

In reality these variables are also declared with __attribute__((__section__())) to put these special variables together. They are finally put back to .bss via linkerscript.



More information about the Binutils mailing list