>
> only the object files with referenced symbols are linked from an archive
>
> so only a.o with the given main.o because of the symbol f
>
> now if you make some reference in main.c such that b.o should
> be included but main still returns 0 that would be a bug
>
> eg. add a void g(void){} to b.c and call it from main.c

Ok, thanks for that info. It appears that there is a problem in gcc 4.9 and not 4.8.3. Come to think of it this I only noticed the prompt being wrong when using  gcc 4.9. I will check this with the git version of gcc also. I attach the code also.

This is from 4.8
************************************************************
Running with ...
gcc (Gentoo 4.8.2-r1 p1.4-ssptest, pie-0.5.9-ssptest) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Case A: 42
************************************************************
ar: creating a.a

a.o:
0000000000000000 r dummy
0000000000000000 T f
0000000000000000 V hasfoo

b.o:
0000000000000000 d foo
0000000000000000 T g
0000000000000000 R hasfoo
Case B: 42
************************************************************

and this is from 4.9
************************************************************
Running with ...
x86_64-buildroot-linux-musl-gcc (Buildroot 2014.05-git-00965-gf077df0-dirty) 4.9.0
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Case A: 0
************************************************************
ar: creating a.a

a.o:
0000000000000000 r dummy
0000000000000000 T f
0000000000000000 V hasfoo

b.o:
0000000000000000 d foo
0000000000000000 T g
0000000000000000 R hasfoo
Case B: 0
************************************************************