gpt4 book ai didi

c - 如何在 GNU LD 中实现自定义输出部分?

转载 作者:行者123 更新时间:2023-11-30 16:33:51 24 4
gpt4 key购买 nike

我正在尝试弄清楚如何在应用程序的 LD 文件中定义自定义输出部分。到目前为止,这就是我想出的......

MEMORY
{
...
m_my_custom_section (RW) : ORIGIN = 0x00002400, LENGTH = 0x00000400
...
}

SECTIONS
{
...
.my_custom_section :
{
. = ALIGN(4);
KEEP(*(.my_custom_section))
. = ALIGN(4);
} > m_my_custom_section
...
}

不幸的是,这就是我陷入困境的地方。我不确定如何指定在应用程序链接时将代码的哪些部分分配给该部分。任何帮助都会很棒。 :)

最佳答案

我相信我找到了答案here in @Mike Kinghan's comment :

In Standard C or C++ there are no syntactic means to define sections. Section definition normally is entirely the compiler's business. A compiler may have non-standard extensions that let you assign an object to a named section. For GCC see the documentation of __attribute__ ((section ("<section-name>"))) in Common Variable Attributes and Common Function Attributes Such extensions are for specialized purposes.

关于c - 如何在 GNU LD 中实现自定义输出部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49562744/

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