gpt4 book ai didi

c++ - C/C++ 链接器 CALL16 reloc at xxxxx not against global symbol

转载 作者:太空狗 更新时间:2023-10-29 21:09:22 27 4
gpt4 key购买 nike

我在链接时遇到这些错误,这两条消息都与同一个目标文件有关。

CALL16 reloc at 0x5f8 not against global symbol

could not read symbols: Bad value

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

有什么解决这个问题的技巧吗?

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

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

我也尝试了以下但没有成功:
-mno-explicit-relocs
-mexplicit-relocs
-mlong-调用
-mno-long-calls
-mxgot
-mno-xgot


同时,此时我将回到源头并进行更多调查。

最佳答案

啊哈!感谢我的一位同事,我们发现了这个问题。

问题是:

有函数的前向声明/原型(prototype)。

void FooBarIsBest(void);

稍后在文件中定义函数。

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

这里的问题是在原型(prototype)中省略了关键字 static。所以这就像定义了一个全新的函数。

CALL16 引用被 gcc 用于可重定位代码。该文件的汇编代码显示 CALL16 被用于此函数...这是错误的,因为此函数是本地函数。

有趣的是,这段代码用于编译和链接旧版本的 gcc (3.2.2)。另一个教训。 :)

关于c++ - C/C++ 链接器 CALL16 reloc at xxxxx not against global symbol,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/517563/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com