I'm working in a C project that has a call to ld in its build system like this:
ld --allow-multiple-definition --architecture mips -EB --relocatable a.o b.o c.o -o mylib.a a.o b.o c.o
But I've ran into a problem with the size of this command line (around 32 thousand chars with all the object files needed - and using cygwin) so I started to study a few modifications to it. One of them was to remove the second referecens to the same objects. Like this:
ld --allow-multiple-definition --architecture mips -EB --relocatable a.o b.o c.o -o mylib.a
However, this broke things down. I get lots and lots of undefined references all over the place.
Why did this happen? What is the difference between both calls? I'm reading ld's docs but so far no good.
BONUS
If you are lucky enough, your ld version might have the --start-group objs.o --end-group option to take care of things like that.