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]

Do weak variables waste mem?


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"


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