I have a file, foo.S, which contains ARM thumb instructions, on an Ubuntu 22.04 x86_64 machine. Is it possible to convert this into an ARM object file using as
from binutils
or do I need to create a cross-compiler toolchain? I tried
$ as -mthumb foo.S -o foo.o
However, I got
as: unrecognized option '-mthumb'
even though that’s one of the options listed in man as
.
2
Answers
A minimal and deterministic procedure for assembling a .S file targeting the T32 instruction set on an Ubuntu 22.04 x86_64 machine could be to install the latest Arm toolchain for arm-none-eabi
if you don’t have
wget
installed, just execute:sudo apt-get install wget
, or downloadarm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz
using a WEB browser into you home directory.Once done:
You can now assemble your program using the command:
Please note that a file with the .S extension usually requires to be processed using cpp, the C preprocessor – this is why the command is using
arm-none-eabi-gcc
, and notarm-none-eabi-as
.run
then the code can be compiled with
example: