I need to compile a small assembly file (.S) to THUMB, but MacOS's as
tool generates ARM machine code:
$ cat > code.S
.text
L0:
push {lr}
bl L1
L1:
pop {r0}
blx r0
pop {pc}
$ as -arch armv7 code.S
$ otool -t -v a.out
a.out:
(__TEXT,__text) section
L0:
00000000 e92d4000 stmdb sp!, {lr}
00000004 ebffffff bl 0x8
L1:
00000008 e8bd0001 ldm sp!, {r0}
0000000c e12fff30 blx r0
00000010 e8bd8000 ldm sp!, {pc}
As you can see it generates ARM machine code. How do I make it generate THUMB?
OK, thanks to Notlikethat I found what I was looking for in the thread he linked. I'll just sum it up here.
The solution was to add the assembler directive
.thumb_func
before every label I wished to "flag" as THUMB. The result:Thanks for all the help!