iar等效符号__bss_end__

发布于 2025-02-12 19:28:33 字数 1683 浏览 2 评论 0原文

我想知道Cortex-M的RAM中静态数据的末端在哪里。 GCC CMSIS Linker脚本提供了__ BSS_END __的符号,我只是采用其地址。有同等的IAR吗?还是我必须用一个变量进行虚拟部分,然后将其放在readwrite之后?

这是我(非常标准的)IAR链接脚本:

/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */

/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;

/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__   = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__     = (0x00000000+0x00010000-1);
define symbol __ICFEDIT_region_RAM_start__   = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__     = (0x20000000+0x00002000-1);

/*-Sizes-*/
if ( !isdefinedsymbol( __ICFEDIT_size_cstack__ ) )
{ define symbol __ICFEDIT_size_cstack__   = 0x400; }

if ( !isdefinedsymbol( __ICFEDIT_size_heap__ ) )
{ define symbol __ICFEDIT_size_heap__     = 0x800; }

/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };

initialize by copy { readwrite };

keep { section .intvec };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };

place in ROM_region   { readonly };
place in RAM_region   { readwrite,
                        block CSTACK,
                        block HEAP };

I want to know where is the end of my static data in RAM of Cortex-M. GCC CMSIS linker scripts provide a symbol for __bss_end__ and I simply take its address. Is there an IAR equivalent? Or do I have to make a dummy section with a single variable and place it after readwrite?

This is my (very standard) IAR linker script:

/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */

/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;

/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__   = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__     = (0x00000000+0x00010000-1);
define symbol __ICFEDIT_region_RAM_start__   = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__     = (0x20000000+0x00002000-1);

/*-Sizes-*/
if ( !isdefinedsymbol( __ICFEDIT_size_cstack__ ) )
{ define symbol __ICFEDIT_size_cstack__   = 0x400; }

if ( !isdefinedsymbol( __ICFEDIT_size_heap__ ) )
{ define symbol __ICFEDIT_size_heap__     = 0x800; }

/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };

initialize by copy { readwrite };

keep { section .intvec };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };

place in ROM_region   { readonly };
place in RAM_region   { readwrite,
                        block CSTACK,
                        block HEAP };

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

香草可樂 2025-02-19 19:28:33

如果创建一个块,请将数据放入其中并放置块,您可以使用__ section_begin()__ section_end()将指针纳入此开始和结束堵塞。

示例链接器配置:

/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;

/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__   = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__     = (0x00000000+0x00010000-1);
define symbol __ICFEDIT_region_RAM_start__   = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__     = (0x20000000+0x00002000-1);

/*-Sizes-*/
if ( !isdefinedsymbol( __ICFEDIT_size_cstack__ ) )
{ define symbol __ICFEDIT_size_cstack__   = 0x400; }

if ( !isdefinedsymbol( __ICFEDIT_size_heap__ ) )
{ define symbol __ICFEDIT_size_heap__     = 0x800; }

/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };
define block RWDATA    { readwrite }; /* Create block for readwrite to find its boundaries */

initialize by copy { readwrite };

keep { section .intvec };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };

place in ROM_region   { readonly };
place in RAM_region   { block RWDATA, block CSTACK, block HEAP };

以及访问信息的代码

#include <stdio.h>
#pragma language = extended
#pragma section  = "RWDATA"

int main(void)
{
  char const *rw_start = __section_begin("RWDATA");
  char const *rw_end = __section_end("RWDATA");
  printf("rw_start = %x, rw_end = %x\n", rw_start, rw_end);
}

If you create a block, put the data in it and place the block you can use __section_begin() and __section_end() to get pointers to the beginning and the end of this block.

Example linker configuration:

/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;

/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__   = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__     = (0x00000000+0x00010000-1);
define symbol __ICFEDIT_region_RAM_start__   = 0x20000000;
define symbol __ICFEDIT_region_RAM_end__     = (0x20000000+0x00002000-1);

/*-Sizes-*/
if ( !isdefinedsymbol( __ICFEDIT_size_cstack__ ) )
{ define symbol __ICFEDIT_size_cstack__   = 0x400; }

if ( !isdefinedsymbol( __ICFEDIT_size_heap__ ) )
{ define symbol __ICFEDIT_size_heap__     = 0x800; }

/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
define region ROM_region   = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
define region RAM_region   = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];

define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };
define block RWDATA    { readwrite }; /* Create block for readwrite to find its boundaries */

initialize by copy { readwrite };

keep { section .intvec };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };

place in ROM_region   { readonly };
place in RAM_region   { block RWDATA, block CSTACK, block HEAP };

And the code to access the information

#include <stdio.h>
#pragma language = extended
#pragma section  = "RWDATA"

int main(void)
{
  char const *rw_start = __section_begin("RWDATA");
  char const *rw_end = __section_end("RWDATA");
  printf("rw_start = %x, rw_end = %x\n", rw_start, rw_end);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文