Do weak variables waste mem?
Thomas Schmid
scth2000@yahoo.de
Tue Feb 24 14:14:00 GMT 2015
Hello,
I have question concerning weak variables and ld:
In my example (see source at the end) there are 2 weak variables in <inc.h>.
These 2 variables should be used in "s1.c" and "s2.c".
If <s1.c> is compiled and linked (gcc s1.c -nostdlib), the size of section .bss is 8 bytes.
If <s1.c> and <s2.c> are compiled and linked together (gcc s1.c s2.c -nostdlib),
the size of section .bss is 16 bytes, but the symbol table (objdump -t) shows,
that only the first 8 bytes are used.
For me it looks like a waste of mem. Why is there space left on the end of section .bss?
Thanks in advance!
Source:
<inc.h:>
int var1 __attribute__((__weak__));
int var2 __attribute__((__weak__));
<s1.c>
#include "inc.h"
<s2.c>
#include "inc.h"
More information about the Binutils
mailing list