This is the mail archive of the
mailing list for the binutils project.
Do weak variables waste mem?
- From: Thomas Schmid <scth2000 at yahoo dot de>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 24 Feb 2015 13:01:15 +0000 (UTC)
- Subject: Do weak variables waste mem?
- Authentication-results: sourceware.org; auth=none
- Reply-to: Thomas Schmid <scth2000 at yahoo dot de>
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!
int var1 __attribute__((__weak__));
int var2 __attribute__((__weak__));