0
\$\begingroup\$

Last night there was an attempt to have CMake build a binary instead of the IDE. Got it to compile and spit out an .elf file, however I noticed when I was trying to compare the IDE .elf vs the CMake .elf I happened to spot a slight text section difference.

IDE .elf arm-none-eabi-size:
   text    data     bss     dec     hex filename
   6516       8    1936    8460    210c xxx.elf

CMake .elf arm-none-eabi-size:
   text    data     bss     dec     hex filename
   6912       8    1936    9547    254b xxx.elf

I futher investiagted and dissambled both and found theres 2 functions within the CMake .elf that the IDE .elf doesnt have, shown here:

    Disassembly of section .text:

080002a0 <deregister_tm_clones>:
 80002a0:   4803        ldr r0, [pc, #12]   ; (80002b0 <deregister_tm_clones+0x10>)
 80002a2:   4b04        ldr r3, [pc, #16]   ; (80002b4 <deregister_tm_clones+0x14>)
 80002a4:   4283        cmp r3, r0
 80002a6:   d002        beq.n   80002ae <deregister_tm_clones+0xe>
 80002a8:   4b03        ldr r3, [pc, #12]   ; (80002b8 <deregister_tm_clones+0x18>)
 80002aa:   b103        cbz r3, 80002ae <deregister_tm_clones+0xe>
 80002ac:   4718        bx  r3
 80002ae:   4770        bx  lr
 80002b0:   24000000    strcs   r0, [r0], #-0
 80002b4:   24000000    strcs   r0, [r0], #-0
 80002b8:   00000000    andeq   r0, r0, r0

080002bc <register_tm_clones>:
 80002bc:   4805        ldr r0, [pc, #20]   ; (80002d4 <register_tm_clones+0x18>)
 80002be:   4906        ldr r1, [pc, #24]   ; (80002d8 <register_tm_clones+0x1c>)
 80002c0:   1a0b        subs    r3, r1, r0
 80002c2:   0fd9        lsrs    r1, r3, #31
 80002c4:   eb01 01a3   add.w   r1, r1, r3, asr #2
 80002c8:   1049        asrs    r1, r1, #1
 80002ca:   d002        beq.n   80002d2 <register_tm_clones+0x16>
 80002cc:   4b03        ldr r3, [pc, #12]   ; (80002dc <register_tm_clones+0x20>)
 80002ce:   b103        cbz r3, 80002d2 <register_tm_clones+0x16>
 80002d0:   4718        bx  r3
 80002d2:   4770        bx  lr
 80002d4:   24000000    strcs   r0, [r0], #-0
 80002d8:   24000000    strcs   r0, [r0], #-0
 80002dc:   00000000    andeq   r0, r0, r0

The target is a STM32H743ZI using arm-none-eabi-g++ & arm-none-eabi-gcc compilers. The project uses both C and C++

My question is, where the heck did this come from? How to get rid of it? and why does the CMake .elf does this whereas the IDE .elf doesnt?

\$\endgroup\$
4
  • \$\begingroup\$ There should be a "flag" to have make report spawned commands verbosely. There may be an equivalent facility in the IDE. \$\endgroup\$
    – greybeard
    Jan 20, 2023 at 14:40
  • \$\begingroup\$ @greybeard Verbose for the make, or the linker, or both? \$\endgroup\$
    – Leoc
    Jan 20, 2023 at 14:41
  • 1
    \$\begingroup\$ I'd first try to figure out which commands were started and all the ("command line") parameters used. more likely than not, some compiler driver (like cc) invoked the linker specifying one runtime object (like crt0.o). \$\endgroup\$
    – greybeard
    Jan 20, 2023 at 14:46
  • \$\begingroup\$ @greybeard We did try doing that but couldnt find a difference in flags. Ill try it again and update you. \$\endgroup\$
    – Leoc
    Jan 20, 2023 at 14:52

1 Answer 1

2
\$\begingroup\$

These functions are for transactional memory support. What they do is mentioned in this Stack Overflow answer.

Apparently, your IDE and the command-line compiler are different versions, or use different configurations. Try --fno-gnu-tm to disable it.

\$\endgroup\$
10
  • \$\begingroup\$ Holy, I have to try this thank you! Why would different versions add this in? \$\endgroup\$
    – Leoc
    Jan 20, 2023 at 14:57
  • \$\begingroup\$ It might not yet have been supported in an earlier version. Or somebody decided that nobody is using it anyway. \$\endgroup\$
    – CL.
    Jan 20, 2023 at 14:59
  • \$\begingroup\$ Thank you, yes just confirmed the CMAKE .elf was compiled using 9.x compiler whereas the IDE .elf was using 10.3 compiler \$\endgroup\$
    – Leoc
    Jan 20, 2023 at 15:02
  • \$\begingroup\$ Btw, just curious I am trying to find '--fno-gnun-tm' and cant seem to find it how did you know to use that? \$\endgroup\$
    – Leoc
    Jan 20, 2023 at 15:06
  • 1
    \$\begingroup\$ Yes; see gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html. \$\endgroup\$
    – CL.
    Jan 20, 2023 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.