This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TM4C129EKCPDT:二进制映像大小

Guru**** 1821780 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1259823/tm4c129ekcpdt-size-of-binary-image

器件型号:TM4C129EKCPDT

您好!

我不熟悉 CCS。 我正在尝试找到一种在链接命令文件中创建全局符号的方法、以表示分配的最高闪存地址(等于映像大小 - 1)、以便我可以在代码中引用此值。 例如:

extern DWORD __IMAGE_SIZE;
#pragma DATA_SECTION (Header、".imgheader")
CONST IMG_HEADER 报头={
      (DWORD)&__image_size、

      __DATE__,
      __TIME__,
};

这是我的链接命令文件:

--retain=g_pfnVectors
--retain=标题

内存
{
   Flash (RX):origin = 0x00000000,length = 0x00008000
   SRAM (rwx):origin = 0x20000000、length = 0x00040000

部分
{
   .intvecs:  >0x00000000
   .imgheader:   > 0x00000200
   .text  :  >闪存
   .const :  >闪存
   cinit :  >闪存
   请输入您的密码 :  > FLASH
   init_array:> FLASH
   .dume:>闪存
      {
         __image_size =.;
      }

   .vtable:  > 0x20000000
   .data  :  > SRAM
   bss   :  > SRAM
   .sysmem:  > SRAM
   .stack :  > SRAM

__STACK_TOP =_STACK + 512;

如果上次分配了.dummy 段、我尝试获取指针值、该值将是二进制映像的大小(二进制映像由编译后命令生成)。 但此方法不起作用、因为没有为.dummy 段分配任何内容、_image_size 的值为0。

我的问题是、在链接时获取二进制大小的正确方法是什么?