This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Do weak variables waste mem?





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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]