1
votes

When working directly with ARM assembly I can use .thumb and .thumb_func and their analogous arm directives to instruct the assembler which flavor of instructions to output.

Is there a matching compiler directive when developing C code? The GCC documentation I've seen mentions various command line options to allow thumb and arm code to work in the same binary but the output looks like it's an entire binary that's in either thumb or ARM. I want to be able to specify how individual functions are compiled.

If not, is there another way to accomplish this? I was thinking I could compile multiple times and then manually splice the disassemble to manually splice the functions together in a new binary but I'm hoping there's an easier way.

2
isolate the functions in their own files and compile each file and set of functions in it for one or the other mode.old_timer

2 Answers

1
votes

Looks like what you want is a target function attribute. Have a look at the arm and thumb attributes at https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/ARM-Function-Attributes.html#ARM-Function-Attributes

These should allow you to compile individual functions in a file for A32 or T32.

0
votes

Don't use gcc documentation from any other site then gcc, because it might be outdated. From gcc doc:

-mthumb
-marm
Select between generating code that executes in ARM and Thumb states. The default for most configurations is to generate code that executes in ARM state, but the default can be changed by configuring GCC with the --with-mode=state configure option.

You can also override the ARM and Thumb mode for each function by using the target("thumb") and target("arm") function attributes (see ARM Function Attributes) or pragmas (see Function Specific Option Pragmas).