> > > 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.
>
> Is perhaps -ffunction-sections and/or -fdata-sections added
> automatically? Those would break musl like experienced.

Thanks for that tip, but I didn't change the sections in the linker script. I didn't add any flags either. I attach the single test case cleaned up a bit. I ran this on the buildroot toolchain (standard config with uclibc and with 2.24.0 binutils) with 4.8.2 and the result is 42. I rebuilt the toolchain only changing the compiler version to 4.9.2 and the result is 0.

This corroborates what I was seeing (or not as in the case of the prompt not appearing in busybox) with my builds also.

Thomo