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
.
run
sudo sh -c 'apt update;apt install binutils-arm-none-eabi;'
then the code can be compiled with
arm-none-eabi-as -mthumb foo.S -o foo.o
example:
$ echo nop > foo.S
$ arm-none-eabi-as -mthumb foo.S -o foo.o
$ echo $?
0
$ file foo.o
foo.o: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped