macro_controller
macro_controller

Reputation: 1519

Change default ARM gcc option to thumb

I want to change the behavior of the ARM toolchain arm-linux-gnueabi-gcc in my Linux machine, that the compiled code will be in Thumb mode as default - same as passing the -mthumb flag.

I came across this document, which under the section of --with-mode describes exactly what I try to achieve. However, I couldn't understand from their explanation how can I actually set this option.

Can anyone clarify this for me, or suggest another way to achieve my goal?

Upvotes: 0

Views: 782

Answers (1)

KamilCuk
KamilCuk

Reputation: 140970

You can "mask" the executable file /usr/bin/arm-linux-gnueabi-gcc with your own script that is named the same inside /usr/local/bin.

  • Create a file /usr/local/bin/arm-linux-gnueabi-gcc
  • With the content
    • #!/bin/sh
    • /usr/bin/arm-linux-gnueabi-gcc -mthumb "$@"
  • Add executable permissions to /usr/local/bin/arm-linux-gnueabi-gcc

Because PATH should list /usr/local/bin directory before /usr/bin, when you type arm-linux-gnueabi-gcc without the path in your console, your script will chosen first and will execute the real arm-linux-gnueabi-gcc executable with the additional option.

Upvotes: 1

Related Questions