C/C++ linker CALL16 reloc at xxxxx not against global symbol

风格不统一 提交于 2019-12-04 01:42:10

问题


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:


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. :)




回答2:


Try -mlong-calls flag to the compiler.

Also see the manual for more specific MIPS options.



来源:https://stackoverflow.com/questions/517563/c-c-linker-call16-reloc-at-xxxxx-not-against-global-symbol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!