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: figure out the start and end of ".either.text" GCC sections

Part Number: MSP430FR6043


When building for MSP430FR6043 with "-mcode-region=none" we can use start/end markers surrounding each section in the linker script to calculate per-sections' CRCs in a post-build step.

Example from 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

Then make can invoke msp430-elf-objdump to figure out those markers and use srec_cat to calculate CRCs and inject them into the final binary (in a dedicated memory header) and this works as expected.

However when building with "-mcode-region=either" the result contains .either.text sections which are placed by the linker in either low or high FRAM:

Unfortunately all these .either.text sections are placed outside of the specified linker script markers. Example of a resulted map file:

.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 = .

As can be seen above, all the .either.text are placed outside any start/end pairing markers.
Is there a way to figure out the start and end of these .either.text sections so that a CRC can be calculated on them too?
Thank you!

**Attention** This is a public forum