C/C ++链接程序CALL16重定位在xxxxx处,不针对全局符号 [英] C/C++ linker CALL16 reloc at xxxxx not against global symbol

查看:143
本文介绍了C/C ++链接程序CALL16重定位在xxxxx处,不针对全局符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

链接时出现这些错误,两条消息都与同一个目标文件有关.

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

could not read symbols: Bad value

第二条消息似乎是我遇到CALL16错误的原因,但是文件编译正常.

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?

仅供参考,我正在交叉编译MIPS目标并使用gcc 4.1.2

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

编辑:到目前为止还没有运气:
这是我使用的标志: -fPIC,-Wl,-rpath,-Wl,-O1

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

我还尝试了以下操作,但未成功:
-mno-explicit-relocs
-mexplicit-relocs
-mlong-calls
-mno-long-calls
-mxgot
-mno-xgot

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.

推荐答案

啊! 感谢我的一位同事,我们找到了问题.

Aha! Thanks to a colleague of mine, we found 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
} 

这里的问题是在原型中没有关键字static.这样就好像正在定义一个全新的功能.

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.

gcc将CALL16参考用于可重定位的代码.该文件的汇编代码表明此功能正在使用CALL16 ...这是错误的,因为此功能是本地的.

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.

有趣的是,该代码用于编译&链接与旧版本的gcc(3.2.2)很好. 吸取了另一个教训. :)

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

这篇关于C/C ++链接程序CALL16重定位在xxxxx处,不针对全局符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆