On 2006-06-15, Yvan Castilloux <[email protected]> wrote:

> I've made quite amount of research on how to do this.... people tellme to 
> invoke the ld command as the following:
>
> msp430-ld -r -o lib.o $(OBJECTS)

That looks right.  I've done that for other targets, but I've
never tried it for MSP430.

> However my problem is that all global variables that are not
> initialized in the declaration statement cause the classic
> error "undefined reference".

Bummer. :)

> I just wonder if it would be an error specific to msp430-ld.

It sure looks like it is.

I compiled and incrementally linked the following two files:

---------file1.c---------------
extern int i;

int foo(void)
{
  return i+1;
}
------------------------------

---------file2.c---------------
extern int foo(void);

int i;

int bar(void)
{
  return i + foo();
}
------------------------------

It worked fine using gcc for IA32, ARM, H8, and AVR.

But it fails for MSP430:

  $ msp430-ld -r -o foo.o file1.o file2.o
  file1.o: In function foo':file1.c:(.text+0x6): undefined reference to i'
  file2.o: In function bar':file2.c:(.text+0xa): undefined reference to i'

Like you said, it's only a problem for uninitialized variables.
If I add an initializer to the declaration of "i", then it's
OK.

> I sent an email to the binutils mailing list and I'm still
> waiting for an answer.

-- 
Grant Edwards                   grante             Yow!  I'll show you MY
                                  at               telex number if you show
                               visi.com            me YOURS...


Reply via email to