views:

271

answers:

2

I'm getting these errors while linking, both messages have to do with the same object file.

CALL16 reloc at 0x5f8 not against global symbol

and

could not read symbols: Bad value

The 2nd message seems to be the reason I'm getting the CALL16 error, but the file compiles just fine.

Any tips on fixing this?

FYI, I'm cross compiling for a MIPS target and using gcc 4.1.2

EDIT: No luck so far:
Here are my flags used: -fPIC,-Wl,-rpath,-Wl,-O1

I've also tried the following without success:
-mno-explicit-relocs
-mexplicit-relocs
-mlong-calls
-mno-long-calls
-mxgot
-mno-xgot


Meanwhile, I'll go back to the source at this point and investigate more.

+1  A: 

Try -mlong-calls flag to the compiler.

Also see the manual for more specific MIPS options.

Iulian Şerbănoiu
+1  A: 

Aha! Thanks to a colleague of mine, we found the issue.

Here was the issue:

There was a forward declaration/prototype of a function.

void FooBarIsBest(void);

Later on in the file the function was defined.

static void FooBarIsBest(void)
{
    // do the best
}

The issue here was that in the prototype the keyword static was left out. So it was like a whole new function was being defined.

The CALL16 reference is used by gcc for relocatable code. The assembly code of the file showed that CALL16 was being used on this function... Which is wrong, as this function is local.

Interestingly, this code used to compile & link just fine with an older version of gcc (3.2.2). Another lessoned learned. :)

Steve Lazaridis
good catch by 'colleague'
Matt Davison
Exactly :) Thanks to Marco -- he's the man.
Steve Lazaridis