内存部分处理错误
我收到链接时间错误:
WARNING: /home/gulevich/development/camac-fedorov/camac/linux/k0607-lsi6/camac-k0607-lsi6.o (.ctors): unexpected non-allocatable section.
Did you forget to use "ax"/"aw" in a .S file?
Note that for example <linux/init.h> contains
section definitions for use in .S files.
导致错误的代码(C 源代码中的汇编):
# if defined(__ELF__)
# define __SECTION_FLAGS ", \"aw\" , @progbits"
/* writable flag needed for ld ".[cd]tors" sections bug workaround) */
# elif defined(__COFF__)
# define __SECTION_FLAGS ", \"dr\""
/* untested, may be writable flag needed */
# endif
asm
(
".section .ctors" __SECTION_FLAGS "\n"
".globl __ctors_begin__\n"
"__ctors_begin__:\n"
".previous\n"
);
有什么方法可以解决此问题吗?这个想法是在某个内存部分的开头放置一个变量__ctors_begin__
。该代码是遗留代码,使用不同的构建系统和较旧的编译器可以正常工作。
我之前问题的答案中解释了此汇编代码的含义。
I'm getting a link time error:
WARNING: /home/gulevich/development/camac-fedorov/camac/linux/k0607-lsi6/camac-k0607-lsi6.o (.ctors): unexpected non-allocatable section.
Did you forget to use "ax"/"aw" in a .S file?
Note that for example <linux/init.h> contains
section definitions for use in .S files.
The code causing the error (assembly in C source):
# if defined(__ELF__)
# define __SECTION_FLAGS ", \"aw\" , @progbits"
/* writable flag needed for ld ".[cd]tors" sections bug workaround) */
# elif defined(__COFF__)
# define __SECTION_FLAGS ", \"dr\""
/* untested, may be writable flag needed */
# endif
asm
(
".section .ctors" __SECTION_FLAGS "\n"
".globl __ctors_begin__\n"
"__ctors_begin__:\n"
".previous\n"
);
Is there any way to fix this? The idea is to put a varaible __ctors_begin__
at the beginning of a certain memory section. This code is a legacy that worked fine using a different build system and older compiler.
Meaning of this assembly code explained in an answer to my previous question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
可能性很大,但是 .ctors 部分是按照您在链接描述文件中想要的方式定义的吗? ld iirc 有一个详细选项来显示链接描述文件。
very long shot but is the section .ctors is defined like you want in the linker script? ld iirc has a verbose option to show the linker script.
长镜头:
也许您的链接器需要 ELF 格式(而不是 COFF),并且由于某种原因未定义
__ELF__
?您是否检查过此特定构建的预处理器输出?A long shot:
Perhaps your linker is expecting ELF format (instead of COFF), and for some reason
__ELF__
is not defined? Have you checked the preprocessor output for this particular build?我会检查 __SECTION_FLAGS 的值,以确保它确实包含 ax 或 aw。我还要确保
__COFF__
未定义,而__ELF__
已定义。如果做不到这一点,可能是时候获取(可能的)编译器/链接器的先前或未来版本,并查看是否可以解决您的问题。也许您可以将代码编译为 C++,并以某种方式让编译器/链接器/链接脚本执行它们应该执行的操作?完全不知道,但这就是我要开始的地方。I would dobule check the value of
__SECTION_FLAGS
just to be sure that it indeed contains ax or aw. I'd also be sure that__COFF__
is not defined and that__ELF__
is. Failing that, it might be time to grab (is possible) a previous or future version of the compiler/linker and see if that fixes your problem. Perhaps you could compile your code as C++ and somehow let the compiler/linker/link scritps do what they are supposed to do? Dunno completely, but this is where I would start.各部分工作正常。所以我会忽略这个警告。
Sections work fine. So I'll ignore this warning.