I don't know if I'm missing something but I'm running into problems linking 
archived objects together.

I'm using msp430-gcc as front-end for linking:

msp430-gcc -mmcu=msp430x449 -O main.o moduleA.a moduleB.a moduleC.a -o 
output.elf
where the moduleX.a originates from the corresponding directory X and was made 
with msp430-ar

What I observed was that the order how the archives are grouped does matter.
With a certain order, I'm able to build the project (e.g. moduleA.a moduleB.a 
moduleC.a).
But when using a different order (e.g moduleC.a moduleB.a moduleA.a) I get a 
couple of link errors:
"moduleB.a(objectb.o)(.text+0x4): undefined reference to `<variable name>'"
<variable name> however is defined in objecta.o in moduleA.a

I didn't run into this problem when the project was still smaller (fewer 
objects). I can build the current project with IAR without any problems.

I'm not a expert to ld but I like to theorize that the lookup table in 
msp430-ld where all symbols are listed is not big enough.

Any ideas?

This is because the link is a one (or two pass I forget) link and does not discover symbols in later files when it needs them in the ones it has already linked.

Yes in binutils the order does matte. This is by you sometimes see -lc -lgcc -lc when running gcc with -v

Hope that helps,

--
Peter Jansen
Australian Antarctic Division


Reply via email to