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.

[参考译文] MSP430FR6043:找出".ote.text"GCC 段的开头和结尾

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1311053/msp430fr6043-figure-out-the-start-and-end-of-either-text-gcc-sections

器件型号:MSP430FR6043

使用"-mcode-region= "我们可以 在链接器脚本中的每个段周围使用开始/结束标记来计算每个段的 CRC、以便在编译后处理步骤中进行计算。

msp430fr6043.ld 中的示例:

  .lower.text :
  {
    . = ALIGN(2);
    __CRC_ADDR_FRAM_LOWER_TEXT_START = .; /* FRAM address for CRC-16 post-build calc and check */
    *(.lower.text.* .lower.text)
    __CRC_ADDR_FRAM_LOWER_TEXT_END = .; /* FRAM address for CRC-16 post-build calc and check */
  } > FRAM=0xff

  .upper.text :
  {
    . = ALIGN(2);
    __CRC_ADDR_FRAM_UPPER_TEXT_START = .; /* FRAM address for CRC-16 post-build calc and check */
    *(.upper.text.* .upper.text)
    __CRC_ADDR_FRAM_UPPER_TEXT_END = .; /* FRAM address for CRC-16 post-build calc and check */
  } > HIFRAM=0xff

  .text :
  {
    PROVIDE (_start = .);
    __CRC_ADDR_FRAM_TEXT_START = .; /* FRAM address for CRC-16 post-build calc and check */

    . = ALIGN(2);
    KEEP (*(SORT(.crt_*)))

    . = ALIGN(2);
    KEEP (*(.lowtext))

    . = ALIGN(2);
    *(.text .stub .text.* .gnu.linkonce.t.* .text:*)

    KEEP (*(.text.*personality*))
    /* .gnu.warning sections are handled specially by elf32.em.  */
    *(.gnu.warning)
    *(.interp .hash .dynsym .dynstr .gnu.version*)
    PROVIDE (__etext = .);
    PROVIDE (_etext = .);
    PROVIDE (etext = .);
    . = ALIGN(2);
    KEEP (*(.init))
    KEEP (*(.fini))
    KEEP (*(.tm_clone_table))
    __CRC_ADDR_FRAM_TEXT_END = .; /* FRAM address for CRC-16 post-build calc and check */
  } > FRAM=0xff

然后、make 可以调用 msp430-elf-objdump 以找出这些标记、并使用 srec_cat 来计算 CRC 并将其注入到最终二进制中 (在专用存储器标头中)、这样做会按预期工作。

但是、在构建"-mcode-region=时、 任一 "结果包含由链接器放置在低或高 FRAM 中的.ober.text 段:

遗憾的是、所有这些.obery.text 段 都被放置在 指定的链接器脚本标记之外。 得到的映射文件示例:

.lower.text     0x000000000000fe16       0x18
                0x000000000000fe16                . = ALIGN (0x2)
                0x000000000000fe16                __CRC_ADDR_FRAM_LOWER_TEXT_START = .
 *(.lower.text.* .lower.text)
                0x000000000000fe16                __CRC_ADDR_FRAM_LOWER_TEXT_END = .
 .either.text.some_function_1
                0x000000000000fe16       0x10 out.nNvRL3.ltrans0.ltrans.o
 .either.text.__udivhi3
                0x000000000000fe26        0x8 gcc/msp430-elf/9.3.1/large\libgcc.a(lib2divHI.o)
                0x000000000000fe26                __mspabi_divu

.upper.text     0x000000000001443c     0x1b70
                0x000000000001443c                . = ALIGN (0x2)
                0x000000000001443c                __CRC_ADDR_FRAM_UPPER_TEXT_START = .
 *(.upper.text.* .upper.text)
                0x000000000001443c                __CRC_ADDR_FRAM_UPPER_TEXT_END = .
 *()
 .either.text.some_function_2.constprop.0
                0x000000000001443c       0x3a out.nNvRL3.ltrans0.ltrans.o
 *()
 .either.text.some_function_3.constprop.0
                0x0000000000014476       0x5e out.nNvRL3.ltrans0.ltrans.o
 *()
 .either.text.some_function_4.constprop.0
                0x00000000000144d4      0x10c out.nNvRL3.ltrans0.ltrans.o
 *()
 .either.text.some_function_5
                0x00000000000145e0       0x10 out.nNvRL3.ltrans0.ltrans.o
 *()
 .either.text.some_function_6
                0x00000000000145f0       0x44 out.nNvRL3.ltrans0.ltrans.o
 *()
 .either.text. ... etc

 *()
 .either.text.__mspabi_srll
                0x0000000000015f10        0xe gcc/msp430-elf/9.3.1/large\libgcc.a(srli.o)
                0x0000000000015f18                __mspabi_srll
 *()
 .either.text.memcpy
                0x0000000000015f1e       0x20 msp430-elf/lib/large\libc.a(lib_a-memcpy.o)
                0x0000000000015f1e                memcpy
 *()
 .either.text.memmove
                0x0000000000015f3e       0x54 msp430-elf/lib/large\libc.a(lib_a-memmove.o)
                0x0000000000015f3e                memmove
 *()
 .either.text.memset
                0x0000000000015f92       0x1a msp430-elf/lib/large\libc.a(lib_a-memset.o)
                0x0000000000015f92                memset

.text           0x000000000000fe2e      0x14c
                0x000000000000fe2e                PROVIDE (_start = .)
                0x000000000000fe2e                __CRC_ADDR_FRAM_TEXT_START = .
                0x000000000000fe2e                . = ALIGN (0x2)
 *(SORT_BY_NAME(.crt_*))
 .crt_0000start
                0x000000000000fe2e        0x4 msp430-elf/lib/large/crt0.o
                0x000000000000fe2e                __crt0_start
 .crt_0100init_bss
                0x000000000000fe32       0x10 msp430-elf/lib/large\libcrt.a(crt_bss.o)
                0x000000000000fe32                __crt0_init_bss
 .crt_0300movedata
                0x000000000000fe42       0x14 msp430-elf/lib/large\libcrt.a(crt_movedata.o)
                0x000000000000fe42                __crt0_movedata
 .crt_0800call_main
                0x000000000000fe56        0x6 msp430-elf/lib/large\libcrt.a(crt_main.o)
                0x000000000000fe56                __crt0_call_main
                0x000000000000fe5c                . = ALIGN (0x2)
 *(.lowtext)
 .lowtext       0x000000000000fe5c      0x11e out.nNvRL3.ltrans0.ltrans.o
                0x000000000000fe5c                IRQ_comm
                0x000000000000ff42                IRQ_timer
                0x000000000000ff60                IRQ_UNMI
                0x000000000000ff7a                . = ALIGN (0x2)
 *(.text .stub .text.* .gnu.linkonce.t.* .text:*)
 *(.text.*personality*)
 *(.gnu.warning)
 *(.interp .hash .dynsym .dynstr .gnu.version*)
                [!provide]                        PROVIDE (__etext = .)
                [!provide]                        PROVIDE (_etext = .)
                [!provide]                        PROVIDE (etext = .)
                0x000000000000ff7a                . = ALIGN (0x2)
 *(.init)
 *(.fini)
 *(.tm_clone_table)
                0x000000000000ff7a                __CRC_ADDR_FRAM_TEXT_END = .

如上所示、所有.ther.text 都被放置在任何开始/结束配对标记之外。
是否有办法确定这些.obler.text 段的开头和结尾、以便也可对其计算 CRC?
谢谢 !