4
votes

We are working on some code for ARM Cortex M4 on a STM32 chip.

My understanding is that Cortex-M4 has some 32 bit instructions but these are not 32 bit ARM instructions they are just a few special instructions. I thought the glue was for transitioning between ARM and thumb instructions sets. So why does the linker script need the glue

.text :
{
. = ALIGN(4);
*(.text)           /* .text sections (code) */
*(.text*)          /* .text* sections (code) */
*(.glue_7)         /* glue arm to thumb code */
*(.glue_7t)        /* glue thumb to arm code */

Can I remove the glue_7 and glue_7t since the processor only supports thump instructions? Would there be any flash memory freed up by doing this?

1
That section of linker code just says to put glue code there if there is any. If there isn't any glue, nothing is emitted. Look at your link map to see whether there's any space to be reclaimed.Dave M.
you can do whatever you want in your linker script and bootstrap. its yours.old_timer
if it breaks then library, etc then put it back. there shouldnt be any code in thereold_timer
inter work is for going to/from thumb arm instructions yes and the thumb2 extensions are not arm instructions they are thumb instructions as documented (you read the arm docs yes?) you have to stay in thumb mode otherwise you get a fault.old_timer
@marc: old_timer's comment is the correct answer to your question: these sections are here for historical reasons, and were never removed.Frant

1 Answers

3
votes

The posted script is always going to create the sections for ARM/thumb code calling thumb/ARM, if there is nothing to call, the sections are empty. An empty section is benign.

If you want to remove unused sections without modifying the linker, a clean way is performing the dead code elimination, via --gc-sections:

Once the objects and static libraries are created with these options, the linker can perform the dead code elimination. You can do this by setting the -Wl,--gc-sections option to gcc command or in the -largs section of gnatmake. This will perform a garbage collection of code and data never referenced.